| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- 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 Pur.Entity;using Pur.Entity;
- using Pur.Entity.configureEntity;
- using Core.Mes.Client.Comm.Control;
- using Infragistics.Win.UltraWinGrid;
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Tool;
- using Pur.require_plan;
- using Infragistics.Win;
- namespace Pur.Pop_upWindow
- {
- public partial class FrmPop_upDeliveryLocation : FrmPmsBase
- {
- public String tips = "0";
- public String isNotAll = "1";//0全部
- public String isCK = "1";//不可以修改
- public String isJIT = "";
- public FrmPop_upDeliveryLocation()
- {
- isCK = "0";//非弹出对话框不需要控制权限
- isNotAll = "0";
- InitializeComponent();
- }
- public FrmPop_upDeliveryLocation(OpeBase ob)
- {
- this.ob = ob;
- InitializeComponent();
- }
- public FrmPop_upDeliveryLocation(OpeBase opeBase, string strd,String strisJIT)
- {
- // TODO: Complete member initialization
- this.ob = opeBase;
- this.isNotAll = strd;
- this.isJIT = strisJIT;
- InitializeComponent();
- }
- /** 交付地点编码 */
- private string deliveryLocationCode;
- public string DeliveryLocationCode
- {
- get { return deliveryLocationCode; }
- set { deliveryLocationCode = value; }
- }
- /** 交付地点 */
- private string deliveryLocation;
- public string DeliveryLocation
- {
- get { return deliveryLocation; }
- set { deliveryLocation = value; }
- }
- private void FrmPop_upDeliveryLocation_Load(object sender, EventArgs e)//load
- {
- ultraExpandableGroupBox1.Expanded = false;
- txt_isDefault.SelectedIndex = 0;
- Cop_isDefault.SelectedIndex = 0;
- txt_isJit.SelectedIndex = 0;
- QueryDz();
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- }
- /// <summary>
- /// toolbar菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)// toolbar菜单
- {
- switch (ToolbarKey)
- {
- case "Query":
- {
- QueryDz();
- }
- break;
- case "Add"://新增
- {
- AddDz();
- }
- break;
- case "update":
- {
- updateDz();
- }
- break;
- case "delete"://删除
- {
- deleteDz();
- }
- break;
- case "ESC":
- {
- EscDz();
- }
- break;
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key.ToString())
- {
- case "Query":
- {
- QueryDz();
-
- }
- break;
- case "Add":
- {
- AddDz();
- }
- break;
- case "update":
- {
- updateDz();
- }
- break;
- case "delete":
- {
- deleteDz();
- }
- break;
- case "conFirmation":
- {
- conFirmationDz();
- }
- break;
- case "doClear":
- {
- clearDz();
- }
- break;
- case "ESC":
- {
- EscDz();
- }
- break;
- }
- }
- /// <summary>
- ///
- /// </summary>
- private void EscDz()
- {
- this.Close();
- }
- /// <summary>
- /// 确认
- /// </summary>
- private void conFirmationDz()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- this.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
- this.DeliveryLocation = uge.Cells["DeliveryLocation"].Value.ToString();
- tips = "1";
- this.Close();
- }
- private void clearDz()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- this.DeliveryLocationCode = "";
- this.DeliveryLocation = "";
- tips = "1";
- this.Close();
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void deleteDz()// 删除
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- UltraGridRow uge = ultraGrid1.ActiveRow;
- DeliveryLocationDz Dz = new DeliveryLocationDz();
- Dz.Validflag = "0";
- Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
- Dz.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Dz.DeleteTime = DateTime.Now;
- Dz.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- if (testDZ(Dz.DeliveryLocationCode) == false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定删除该地址?") == DialogResult.No)
- {
- return;
- }
- CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate", new object[] { Dz });
- if (cRt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败" + cRt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- QueryDz();
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private bool testDZ(String dz)
- {
- DeliveryLocationDz cRt = this.execute<DeliveryLocationDz>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { dz });
- if (cRt == null)
- {
- MessageUtil.ShowTips("地址不存在,可能已被废除");
- return false;
- }
- if (cRt.Validflag == "0")
- {
- MessageUtil.ShowTips("地址信息已作废");
- return false;
- }
- if (isCK == "1")
- {
- if (cRt.OrgId != UserInfo.GetDeptid())
- {
- MessageUtil.ShowTips("非地址所属科室/单位,无权限删改");
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void updateDz()// 修改
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- UltraGridRow uge = ultraGrid1.ActiveRow;
- DeliveryLocationDz Dz = new DeliveryLocationDz();
- if (testInput() == false)
- {
- return;
- }
- Dz.InvPhysic = txtPhysicCode.Text.Trim();
- Dz.InvPhysicName = txtPhysic.Text.Trim();
- Dz.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Dz.UpdateTime = DateTime.Now;
- Dz.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- Dz.IsJit = txt_isJit.Value.ToString().Trim();
- Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
- Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
- Dz.IsDefault = Cop_isDefault.Value.ToString();
- if (testDZ(Dz.DeliveryLocationCode) == false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定修改该地址?") == DialogResult.No)
- {
- return;
- }
- CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate_D", new object[] { Dz });
- if (cRt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败:" + cRt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("修改成功!");
- QueryDz();
- comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", Dz.DeliveryLocationCode);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败;" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- private void AddDz()// 新增
- {
- ////
- //if (Cop_isDefault.Text.Equals("否"))
- //{
- // DeliveryLocationDz Dz1 = new DeliveryLocationDz();
- // Dz1.Validflag = "1";
- // Dz1.IsDefault = "1";
- // DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "find", new object[] { Dz1,0,0});
- // if (dt.Rows.Count != 0)
- // {
- // CoreResult cRt1 = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "update_is", new object[] { });
- // }
-
- //}
- try
- {
- this.Cursor = Cursors.WaitCursor;
- DeliveryLocationDz Dz = new DeliveryLocationDz();
- if (testInput() == false)
- {
- return;
- }
- Dz.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Dz.CreateTime = DateTime.Now;
- Dz.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- Dz.OrgId = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid();
- Dz.OrgName = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment();
- Dz.OwnerName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Dz.OwnerUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- Dz.DeliveryLocationCode = getDELIVERY_LOCATION_CODE();//后台复写
- Dz.InvPhysic = txtPhysicCode.Text.Trim();
- Dz.IsJit = txt_isJit.Value.ToString().Trim();
- Dz.InvPhysicName = txtPhysic.Text.Trim();
- Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
- Dz.IsDefault = Cop_isDefault.Value.ToString();
- Dz.Validflag = "1";
- CoreResult cRt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doInsert_D", new object[] { Dz });
- if (cRt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败:" + cRt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- QueryDz();
- comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", cRt.Resultmsg);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private bool testInput()
- {
- if (Cop_deliveryLocation.Text.ToString().Trim() == "")
- {
- MessageUtil.ShowTips("请输入有效地址");
- Cop_deliveryLocation.Focus();
- return false;
- }
- if (Cop_isDefault.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请指定是否为默认值!");
- Cop_isDefault.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txtPhysic.Text.Trim()))
- {
- MessageUtil.ShowTips("请指定默认入库库区!");
- txtPhysic.Focus();
- return false;
- }
- if (String.IsNullOrEmpty(txtPhysicCode.Text.Trim()))
- {
- MessageUtil.ShowTips("请指定默认入库库区,库区编码不能为空!");
- txtPhysic.Focus();
- return false;
- }
- if (txt_isJit.SelectedIndex==-1)
- {
- MessageUtil.ShowTips("请指定是否为JIT交付地址!");
- txt_isJit.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void QueryDz()// 查询
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- DeliveryLocationDz Dz = new DeliveryLocationDz();
- Dz.DeliveryLocationCode = txt_deliveryLocationCode.Text.ToString().Trim();
- Dz.DeliveryLocation = txt_deliveryLocation.Text.ToString().Trim();
- Dz.IsDefault = txt_isDefault.Value == null ? "" : txt_isDefault.Value.ToString().Trim();
- Dz.Validflag = "1";
- if (isNotAll == "1")
- {
- Dz.OrgId = UserInfo.GetDeptid();
- }
- Dz.IsJit = isJIT;
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "doQuery_D", new object[] { Dz });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("查询数据失败:"+ex);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)//激活行
- {
- String code=ultraGrid1.ActiveRow.Cells["deliveryLocationCode"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(code))
- {
- return;
- }
- DeliveryLocationDz cRt = this.execute<DeliveryLocationDz>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { code });
- Cop_deliveryLocationCode.Text = cRt.DeliveryLocationCode;
- Cop_deliveryLocation.Text = cRt.DeliveryLocation;
- Cop_isDefault.Value = cRt.IsDefault;
- txtPhysic.Text = cRt.InvPhysicName;
- txtPhysicCode.Text = cRt.InvPhysic;
- txt_isJit.Value = cRt.IsJit;
- }
- /// <summary>
- /// 获取交付地点编码
- /// </summary>
- /// <returns></returns>
- public String getDELIVERY_LOCATION_CODE()// 获取交付地点编码
- {
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.DeliveryLocationService", "findAll", new object[] { });
- string code = "0";
- code = (dt.Rows.Count+1).ToString();
- while (code.Length < 5)
- {
- code = "0" + code;
- }
- return code;
- }
- private void txtPhysic_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- frmPopActualSeat popAs = new frmPopActualSeat(this.ob, "0");
- popAs.ShowDialog();
- if (popAs.Tips=="1")
- {
- txtPhysic.Text = popAs.DeliveryLocation;
- txtPhysicCode.Text = popAs.DeliveryLocationCode;
- }
- }
- }
- }
|