228 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			228 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSBLL;
 | |
| using AIMSModel;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Windows.Forms;
 | |
| 
 | |
| namespace AIMS.PublicUI.UI
 | |
| {
 | |
|     public partial class frmSelectOperation : Form
 | |
|     {
 | |
|         private int currentPage = 0;
 | |
|         private int total = 0;
 | |
|         private int pages = 0;
 | |
|         private DataTable SelectLeftdt;
 | |
|         public List<int> SelectRightData = new List<int>();
 | |
|         public frmSelectOperation()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|         }
 | |
| 
 | |
|         private void frmSelectOperation_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (AIMSExtension.PublicMethod.RoleName.Contains("增加手术"))
 | |
|             {
 | |
|                 btnAddOperation.Visible = true;
 | |
|             }
 | |
|             ControlExtension.SetDgvAttribute(dgvOperation);
 | |
|             ControlExtension.SetDgvAttribute(dgvSelectOperation);  
 | |
| 
 | |
|             SelectLeftdt = BOperation.GetDataTable("");
 | |
| 
 | |
|             this.currentPage = 0;
 | |
|             this.total = SelectLeftdt.Rows.Count;
 | |
|             if (this.total % 15 == 0)
 | |
|             {
 | |
|                 this.pages = this.total / 15;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 this.pages = this.total / 15 + 1;
 | |
|             }
 | |
|             this.labPage.Text = this.currentPage + 1 + "/" + this.pages;
 | |
|             this.dgvOperation.DataSource = this.GetTableByCurrentPage(this.currentPage, SelectLeftdt);
 | |
| 
 | |
|             if (SelectRightData.Count > 0)
 | |
|             {
 | |
|                 foreach (int RowId in SelectRightData)
 | |
|                 {
 | |
|                     Operation OperationObj = BOperation.GetModel(RowId);
 | |
|                     dgvSelectOperation.Rows.Add(OperationObj.Id, OperationObj.IcdCode, OperationObj.Name);
 | |
| 
 | |
|                 }
 | |
|             }
 | |
|             txtHelpCode.Focus();
 | |
|         }
 | |
|         private DataTable GetTableByCurrentPage(int currPage, DataTable dt)
 | |
|         {
 | |
|             DataTable dataTable = dt.Clone();
 | |
|             int num = currPage * 15;
 | |
|             for (int i = num; i < num + 15 && i != this.total; i++)
 | |
|             {
 | |
|                 DataRow dataRow = dataTable.NewRow();
 | |
|                 dataRow["Id"] = Convert.ToInt32(dt.Rows[i]["Id"]);
 | |
|                 dataRow["IcdCode"] = dt.Rows[i]["IcdCode"].ToString();
 | |
|                 dataRow["Name"] = dt.Rows[i]["Name"].ToString();
 | |
|                 //dataRow["level"] = dt.Rows[i]["level"].ToString();
 | |
|                 dataTable.Rows.Add(dataRow);
 | |
|             }
 | |
|             return dataTable;
 | |
|         }
 | |
| 
 | |
|         private void btnOk_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (dgvSelectOperation.Rows.Count > 0)
 | |
|             {
 | |
|                 SelectRightData.Clear();
 | |
|                 for (int i = 0; i < dgvSelectOperation.Rows.Count; i++)
 | |
|                 {
 | |
|                     SelectRightData.Add(int.Parse(dgvSelectOperation.Rows[i].Cells["SelectIdColumn"].Value.ToString()));
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 SelectRightData.Clear();
 | |
|             }
 | |
|             Close();
 | |
|         }
 | |
| 
 | |
|       
 | |
| 
 | |
|         private void btnToRight_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             dgvOperation_CellDoubleClick(null, null);
 | |
|         }
 | |
| 
 | |
|         private void btnToLeft_Click(object sender, EventArgs e)
 | |
|         {            
 | |
|             if (dgvSelectOperation.Rows.Count > 0)
 | |
|             {
 | |
|                 dgvSelectOperation.Rows.RemoveAt(dgvSelectOperation.CurrentRow.Index);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void txtHelpCode_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             this.dgvOperation.AutoGenerateColumns = false;
 | |
|             this.SelectLeftdt = BOperation.GetDataTable(txtHelpCode.Text.Trim());
 | |
| 
 | |
|             this.dgvOperation.DataSource = this.SelectLeftdt;
 | |
|             this.currentPage = 0;
 | |
|             this.total = this.SelectLeftdt.Rows.Count;
 | |
|             if (this.total % 15 == 0)
 | |
|             {
 | |
|                 this.pages = this.total / 15;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 this.pages = this.total / 15 + 1;
 | |
|             }
 | |
|             this.labPage.Text = this.currentPage + 1 + "/" + this.pages;
 | |
|             this.dgvOperation.DataSource = this.GetTableByCurrentPage(this.currentPage, this.SelectLeftdt);
 | |
|         }
 | |
|          
 | |
|         private void dgvOperation_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 | |
|         {
 | |
|             if (dgvOperation.Rows.Count > 0)
 | |
|             {
 | |
|                 int num = Convert.ToInt32(this.dgvOperation.CurrentRow.Cells["Id"].Value);
 | |
| 
 | |
|                 DataTable SelectDataTable =  GetDgvToTable(dgvSelectOperation);
 | |
| 
 | |
|                 foreach (DataRow row in SelectDataTable.Rows)
 | |
|                 {
 | |
|                     if (Convert.ToInt32(row["SelectIdColumn"]) == num)
 | |
|                     {
 | |
|                         MessageBox.Show("已选择!");
 | |
|                         return;
 | |
|                     }
 | |
|                 }
 | |
|                 dgvSelectOperation.Rows.Add(
 | |
|                 dgvOperation.CurrentRow.Cells["Id"].Value.ToString(),
 | |
|                 dgvOperation.CurrentRow.Cells["IcdCodeColumn"].Value.ToString(),
 | |
|                 dgvOperation.CurrentRow.Cells["NameColumn"].Value.ToString());
 | |
| 
 | |
|             }
 | |
|         }
 | |
|         public static DataTable GetDgvToTable(DataGridView dgv)
 | |
|         {
 | |
|             DataTable dt = new DataTable();
 | |
| 
 | |
|             // 列强制转换
 | |
|             for (int count = 0; count < dgv.Columns.Count; count++)
 | |
|             {
 | |
|                 DataColumn dc = new DataColumn(dgv.Columns[count].Name.ToString());
 | |
|                 dt.Columns.Add(dc);
 | |
|             }
 | |
| 
 | |
|             // 循环行
 | |
|             for (int count = 0; count < dgv.Rows.Count; count++)
 | |
|             {
 | |
|                 DataRow dr = dt.NewRow();
 | |
|                 for (int countsub = 0; countsub < dgv.Columns.Count; countsub++)
 | |
|                 {
 | |
|                     dr[countsub] = Convert.ToString(dgv.Rows[count].Cells[countsub].Value);
 | |
|                 }
 | |
|                 dt.Rows.Add(dr);
 | |
|             }
 | |
|             return dt;
 | |
|         }
 | |
|         private void labUp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 | |
|         {
 | |
|             if (this.total != 0 && this.currentPage != 0)
 | |
|             {
 | |
|                 this.currentPage--;
 | |
|                 this.dgvOperation.DataSource = this.GetTableByCurrentPage(this.currentPage, SelectLeftdt);
 | |
|                 this.labPage.Text = this.currentPage + 1 + "/" + this.pages;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void labDown_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 | |
|         {
 | |
|             if (this.total != 0 && this.currentPage + 1 != this.pages)
 | |
|             {
 | |
|                 this.currentPage++;
 | |
|                 this.dgvOperation.DataSource = this.GetTableByCurrentPage(this.currentPage, this.SelectLeftdt);
 | |
|                 this.labPage.Text = this.currentPage + 1 + "/" + this.pages;
 | |
|             }
 | |
|         }
 | |
|         private void btnAddOperation_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Operation OperationObj = new Operation();
 | |
|             OperationObj.Name = txtHelpCode.Text.Trim();
 | |
|             OperationObj.IcdCode = "";
 | |
|             OperationObj.HelpCode = AIMSExtension.PublicMethod.GetFirstLetter(OperationObj.Name);
 | |
|             OperationObj.IsValid = 1;
 | |
|             OperationObj.UseRate = 1;
 | |
|             OperationObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
 | |
|             OperationObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
 | |
|             OperationObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
 | |
|             if (OperationObj.Name == "")
 | |
|             {
 | |
|                 MessageBox.Show("名称不能为空!");
 | |
|                 return;
 | |
|             }
 | |
|             if (BOperation.IsExit(OperationObj.Name))
 | |
|             {
 | |
|                 MessageBox.Show("该事件已存在");
 | |
|                 return;
 | |
|             }
 | |
|             BOperation.Add(OperationObj);
 | |
| 
 | |
|             txtHelpCode_TextChanged(null, null);
 | |
|             dgvOperation_CellDoubleClick(null, null);
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void dgvSelectOperation_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 | |
|         { 
 | |
|             if (dgvSelectOperation.Rows.Count > 0)
 | |
|             {
 | |
|                 dgvSelectOperation.Rows.RemoveAt(dgvSelectOperation.CurrentRow.Index);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |