| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- 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.configureEntity;
- using Core.Mes.Client.Comm.Control;
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Tool;
- using Pur.Pop_upWindow;
- namespace Pur.configure
- {
- public partial class FrmUoms : FrmPmsBase
- {
- public FrmUoms()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- try
- {
- this.Cursor = Cursors.WaitCursor;
- get_PurUoms();
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- break;
- case "doAdd":
- add_PurUoms();
- break;
- case "doModify":
- upd_PurUoms();
- break;
- case "doDelete":
- del_PurUoms();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询采购单位
- /// </summary>
- /// <param name="configureMEntity"></param>
- public void get_PurUoms()
- {
- PurUomsEntity UomsEntity = new PurUomsEntity();
- UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE_QUERY.Text.Trim();//库存单位编码
- UomsEntity.UomCode = txt_UOM_CODE_QUERY.Text.Trim();//采购单位编码
- UomsEntity.WeightUnit = txt_WEIGHT_UNIT_QUERY.Text.Trim();//库存单位
- UomsEntity.UomName = txt_UOM_NAME_QUERY.Text.Trim();//采购单位名称
- UomsEntity.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.UomsService", "get_PurUoms", new object[] { UomsEntity });
- //按创建时间降序
- if (dt.Rows.Count > 0)
- {
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- }
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表
- }
-
- /// <summary>
- /// 增加采购单位
- /// </summary>
- /// <param name="configureMEntity"></param>
- public void add_PurUoms()
- {
- PurUomsEntity UomsEntity = new PurUomsEntity();
- UomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
- UomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位
- UomsEntity.Validflag = "1";
- int num = this.execute<int>("com.hnshituo.pur.configure.service.UomsService", "count", new object[] { UomsEntity });
- if (num>0)
- {
- MessageUtil.ShowTips("添加失败:因为已存在相同的采购单位和库存单位");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确定添加?") == DialogResult.No && ValidInput())
- {
- return;
- }
- UomsEntity.UomConefficient = txt_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_UOM_CONEFFICIENT.Text);//转换系数
- UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
- //UomsEntity.UomCode = txt_UOM_CODE.Text;//txt_UOM_CODE.Text;//采购单位编码
- UomsEntity.UomCode = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_Uoms", "Uom_Code", txt_WEIGHT_UNIT_CODE.Text + "-", "2" });
- UomsEntity.CreateName = UserInfo.GetUserName();
- UomsEntity.CreateUserid = UserInfo.GetUserID();
-
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doInsert", new object[] { UomsEntity});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("添加成功!");
- get_PurUoms();//查询采购单位
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "UomCode", UomsEntity.UomCode);//激活当前行
- }
- /// <summary>
- /// 修改采购单位
- /// </summary>
- /// <param name="configureMEntity"></param>
- public void upd_PurUoms()
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No && ValidInput())
- {
- return;
- }
- if (ultraGrid1.ActiveRow != null)
- {
- PurUomsEntity UomsEntity = new PurUomsEntity();
- UomsEntity.UomConefficient = txt_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_UOM_CONEFFICIENT.Text);//转换系数
- UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
- UomsEntity.UomCode = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
- UomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位
- UomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
- UomsEntity.UpdateName = UserInfo.GetUserName();
- UomsEntity.UpdateUserid = UserInfo.GetUserID();
- UomsEntity.Validflag = "1";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doUpdate", new object[] { UomsEntity});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("修改成功!");
- get_PurUoms();//查询采购单位
- ConfigureClassCommon.doActiveSelRow(ultraGrid1, "UomCode", UomsEntity.UomCode);//激活当前行
- }
- else
- {
- MessageUtil.ShowTips("请选择一条采购单位");
- return;
- }
- }
- /// <summary>
- /// 删除采购单位
- /// </summary>
- /// <param name="configureMEntity"></param>
- public void del_PurUoms()
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否确定删除?") == DialogResult.No)
- {
- return;
- }
- if (ultraGrid1.ActiveRow != null)
- {
- PurUomsEntity UomsEntity = new PurUomsEntity();
- UomsEntity.UomCode = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
- UomsEntity.DeleteTime = System.DateTime.Now;
- UomsEntity.DeleteName = UserInfo.GetUserName();
- UomsEntity.DeleteUserid = UserInfo.GetUserID();
- UomsEntity.Validflag = "0";
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doUpdate", new object[] { UomsEntity});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("删除成功!");
- get_PurUoms();//查询采购单位
- }
- else
- {
- MessageUtil.ShowTips("请选择一条采购单位");
- return;
- }
- }
- /// <summary>
- /// 验证必填项
- /// </summary>
- /// <returns></returns>
- private bool ValidInput()
- {
- if (string.IsNullOrEmpty(txt_UOM_NAME.Text.Trim()))
- {
- MessageBox.Show("请输入采购单位名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- //if (string.IsNullOrEmpty(txt_UOM_CODE.Text.Trim()))
- //{
- // MessageBox.Show("请输入采购单位编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return false;
- //}
- if (string.IsNullOrEmpty(txt_WEIGHT_UNIT.Text.Trim()))
- {
- MessageBox.Show("请输入采购单位名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (string.IsNullOrEmpty(txt_WEIGHT_UNIT_CODE.Text.Trim()))
- {
- MessageBox.Show("请输入采购单位编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- if (string.IsNullOrEmpty(txt_UOM_CONEFFICIENT.Text.Trim()))
- {
- MessageBox.Show("请输入转换系数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- else if (!StringUtil.IsNumber(txt_UOM_CONEFFICIENT.Text.Trim()))
- {
- MessageBox.Show("转换系数必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 激活grid列表
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- txt_UOM_CONEFFICIENT.Text = ultraGrid1.ActiveRow.Cells["UOMCONEFFICIENT"].Value.ToString();
- txt_WEIGHT_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();
- txt_UOM_CODE.Text = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();
- txt_WEIGHT_UNIT.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();
- txt_UOM_NAME.Text = ultraGrid1.ActiveRow.Cells["UOMNAME"].Value.ToString();
- }
- private void txt_WEIGHT_UNIT_CODE_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
- frm.ShowDialog();
- if (!String.IsNullOrEmpty(frm.QstrWeightCode))
- {
- txt_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;
- txt_WEIGHT_UNIT.Text = frm.QstrWeightName;
- }
- }
- private void txt_UOM_NAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
- frm.ShowDialog();
- if (!String.IsNullOrEmpty(frm.QstrWeightCode))
- {
- txt_UOM_CODE.Text = frm.QstrWeightCode;
- txt_UOM_NAME.Text = frm.QstrWeightName;
- }
- }
- }
- }
|