| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using System.Collections;
- namespace Core.LZMes.Client.UIM
- {
- public partial class UIM010010 : FrmBase
- {
- public UIM010010()
- {
- InitializeComponent();
- }
- private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
- {
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery();
- break;
- case "Add":
- this.DoAdd();
- break;
- case "Update":
- this.DoUpdate();
- break;
- case "Delete":
- this.DoDelete();
- break;
- case "Save":
- break;
- case "Exit":
- this.Close();
- break;
- }
- }
- private void DoQuery()
- {
- try
- {
- int areaType = -1 == this.ultraComboEditor1.SelectedIndex ? 0 : int.Parse(this.ultraComboEditor1.SelectedItem.DataValue.ToString());
- this.dataSet1.Tables[0].Clear();
-
- CoreClientParam ccp = new CoreClientParam();
- //ccp.InvokeID = "C06010103";
- ccp.ServerName = "UIM.UIM010010";
- ccp.MethodName = "queryYardArea";
- ccp.ServerParams = new object[] { areaType };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- Console.WriteLine(this.dataSet1.Tables[0].ToString());
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoAdd()
- {
- try
- {
- if (-1 == this.ultraComboEditor2.SelectedIndex)
- {
- MessageBox.Show("请选择区域类型!");
- this.ultraComboEditor2.Focus();
- return;
- }
- if(null == this.textBox2.Text || "".Equals(this.textBox2.Text))
- {
- MessageBox.Show("请输入区域名称!");
- this.textBox2.Focus();
- return;
- }
- string areaName = this.textBox2.Text;//区域名称
- int areaType = int.Parse(this.ultraComboEditor2.SelectedItem.DataValue.ToString());//区域类型
- string hSail = this.checkBox1.Checked ? "1" : "0";//是否可以外卖
- string remark = this.textBox3.Text;//备注
- string regId = this.UserInfo.GetUserID();//操作人
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM010010";
- ccp.MethodName = "addArea";
- ccp.ServerParams = new object[] {areaType,areaName,hSail,remark,regId};
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (0 != ccp.ReturnCode) return;
- DoQuery();
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoUpdate()
- {
- try
- {
- if (null == this.textBox2.Text || "".Equals(this.textBox2.Text))
- {
- MessageBox.Show("请输入区域名称!");
- this.textBox2.Focus();
- return;
- }
- long areaNo = long.Parse(this.ultraGrid1.ActiveRow.Cells["area_no"].Text);//区域编号
- string areaName = this.textBox2.Text;//区域名称
- int areaType = int.Parse(this.ultraComboEditor2.SelectedItem.DataValue.ToString());//区域类型
- string hSail = this.checkBox1.Checked ? "1" : "0";//是否可以外卖
- string remark = this.textBox3.Text;//备注
- string regId = this.UserInfo.GetUserID();//操作人
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM010010";
- ccp.MethodName = "updateArea";
- ccp.ServerParams = new object[] { areaNo, areaType, areaName, hSail, remark, regId };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (0 != ccp.ReturnCode) return;
- this.DoQuery();
- MessageBox.Show("修改成功!");
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoDelete()
- {
- try
- {
- long areaNo = -1;
- Infragistics.Win.UltraWinGrid.UltraGridRow row = this.ultraGrid1.ActiveRow;
- string delParam = "";
- if (row != null)
- {
- areaNo = long.Parse(row.Cells["area_no"].Text);
- delParam += areaNo + "|";
- if (hasYardInArea(areaNo))
- {
- MessageBox.Show("区域下存在垛位信息,请先删除对应垛位。");
- return;
- }
- }
- else
- {
- MessageBox.Show("请选择要删除的区域。");
- return;
- }
- if(MessageBox.Show(this,"是否确认删除?","删除",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
- {
- if (!"".Equals(delParam))
- {
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM010010";
- ccp.MethodName = "delArea";
- ccp.ServerParams = new object[] { delParam };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != 0) return;
- }
- this.ultraGrid1.DeleteSelectedRows(false);
- MessageBox.Show("删除成功!");
- DoQuery();
- }
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- this.textBox2.Text = uRow.Cells["area_name"].Text;
- this.textBox3.Text = uRow.Cells["remark"].Text;
- this.ultraComboEditor2.Text = uRow.Cells["area_type"].Text;
- this.checkBox1.Checked = "是".Equals(uRow.Cells["h_sail"].Text) ? true : false;
- }
- //判断区域下是否存在垛位
- private bool hasYardInArea(long areaNo)
- {
- try
- {
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM010010";
- ccp.MethodName = "hasYardInArea";
- ccp.ServerParams = new object[] { areaNo };
- ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
- int count = int.Parse(ccp.ReturnObject.ToString());
- if (count < 1)
- {
- return false;
- }
- return true;
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- return true;
- }
- }
- private void UIM010010_Load(object sender, EventArgs e)
- {
- }
- private void ultraComboEditor1_ValueChanged(object sender, EventArgs e)
- {
- }
- }
- }
|