using System; using System.Collections.Generic; using System.Configuration; using System.Drawing; using System.Windows.Forms; using QMAPP.FJC.Entity; using QMAPP.FJC.Entity.Basic; using QMAPP.FJC.Entity.Operation; using QMAPP.FJC.Entity.SendPlan; using QMAPP.ServicesAgent; using QMAPP.WinForm.Common; using QMFrameWork.Common.Serialization; using QMFrameWork.Data; using QMAPP.FJC.Entity; using QMAPP.Entity; namespace QMAPP.WinForm.Forms.SendPlan { /// /// 搪塑条码打印 /// public partial class SendPlanPrintForm : Form { List
mainList = new List
(); string typeSelected = ""; public SendPlanPrintForm() { InitializeComponent(); } #region 窗体载入 private void Form_Load(object sender, EventArgs e) { BasicData basicData = new BasicData(); //初始化控件属性 this.DGView.AutoGenerateColumns = false; ////加载料架列表 this.comType.DataSource = basicData.GetMaterialShelfTypeList("",true); this.comType.DisplayMember = "MARERIALSHELFTYPENAME"; this.comType.ValueMember = "PID"; } #endregion /// /// 打印 /// /// /// private void tsbPrint_Click(object sender, EventArgs e) { string barCode = ""; PrintBarCode(barCode); } /// /// 打印条码 /// /// private void PrintBarCode(string barCode) { string xmlPath = @"E:\富维江森\代码\B9\APPB9\QMAPP.WinForm\XMLResources\SendInfo.xml"; BarcodeLib.BarCodeGenerate generate = new BarcodeLib.BarCodeGenerate(xmlPath); generate.PrintBarCode(barCode); } /// /// 行序号 /// /// /// private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGView.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } /// /// 料架类别下拉事件 /// /// /// private void comType_SelectedIndexChanged(object sender, EventArgs e) { if (this.mainList.Count > 0 && !this.typeSelected.Equals(this.comType.SelectedValue)) { if (MessageBox.Show(Resource1.SendInfoHadProduct, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) == DialogResult.OK) { MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType; this.lblCounts.Text = type.CAPACITY.ToString(); this.typeSelected = type.PID; this.mainList.Clear(); this.DGView.DataSource = new List
(); } else { this.comType.SelectedValue = this.typeSelected; } } else { MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType; this.lblCounts.Text = type.CAPACITY.ToString(); this.typeSelected = type.PID; } } /// /// 扫码枪或者点击增加方法 /// /// /// private void ValidateAndAddCode(string proCode) { if (this.comType.SelectedValue == null) { MessageBox.Show(Resource1.SendInfoSelect); return; } if (string.IsNullOrEmpty(this.lblCounts.Text.Trim())) { MessageBox.Show(Resource1.SendInfoNotNull); return; } if (this.mainList.Count >= Convert.ToInt32(this.lblCounts.Text.Trim())) { MessageBox.Show(Resource1.SendInfoWasFull); return; } if (!string.IsNullOrEmpty(proCode)) { //首先判断是否在列表中存在 if (this.mainList.FindAll(m => m.EPIDERMISCODE == proCode).Count > 0 || this.mainList.FindAll(m => m.SKELETONCODE == proCode).Count > 0) { MessageBox.Show(this.txtCode.Text + Resource1.SendInfoWasHad); return; } #region 获取零件信息 Main searchModel = new Main(); searchModel.publicCode = proCode; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); List
list = agent.InvokeServiceFunction>(B9IPCService.MainBLL_GetAllList.ToString(), searchModel); if (list.Count <= 0)//是否存在该零件 { MessageBox.Show(this.txtCode.Text +Resource1.SendInfoNotFoundCode); return; } Main model = list[0]; #endregion #region 判断零件状态 if (!model.STATUS.Equals(EnumGeter.PRODUCTSTAUTS.QUALIFIED.GetHashCode().ToString()))//合格 { if (model.STATUS.Equals(EnumGeter.PRODUCTSTAUTS.REPAIR.GetHashCode().ToString()))//合格 { MessageBox.Show(this.txtCode.Text +Resource1.SendInfoRepaired); return; } else { MessageBox.Show(this.txtCode.Text + Resource1.SendInfoWadBad); return; } } //是否已出库 if (EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString().Equals(model.OUTFLAG) ==false) { MessageBox.Show(this.txtCode.Text + Resource1.SendInfoNotOk); return; } //是否已完成 if (EnumGeter.COMPLETEFLAG.COMPLETED.GetHashCode().ToString().Equals(model.COMPLETEFLAG) == false) { MessageBox.Show(this.txtCode.Text + "该本体正在加工中,未完成"); return; } #endregion #region 判断零件属性是否与料架属性匹配 //获取该产品的属性 //ProductAttribute attribute = new ProductAttribute(); //attribute.MPPID = model.EID; //List listAttribute = agent.InvokeServiceFunction>(B9BasicService.ProductAttributeBLL_GetAllList.ToString(), attribute); //if (listAttribute.Count <= 0) //{ // MessageBox.Show(Resource1.SendInfoCantFind); // return; //} //attribute = listAttribute[0]; //判断是否与料架属性匹配 MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType; //判断产品类别type.PRODUCTTYPE; if (!type.VERSION.Equals(model.HB)) { MessageBox.Show(this.txtCode.Text + Resource1.SendInfoNotFIt); return; } if (!type.COLORCODE.Equals(model.COLOR)) { MessageBox.Show(this.txtCode.Text + Resource1.SendInfoColorNotFit); return; } #endregion //添加到零件列表 mainList.Add(model); this.DGView.DataSource = new List
(); this.DGView.DataSource = mainList; this.txtCode.Text = ""; if (mainList.Count.ToString().Equals(this.lblCounts.Text.Trim()))//判断是否装满 { if (MessageBox.Show(Resource1.SendInfoReadySend, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) == DialogResult.OK) { SaveInfo(); } } } } /// /// 保存发运方法 /// public void SaveInfo() { if (mainList.Count <= 0) { MessageBox.Show(Resource1.SendInfoNotProduct); return; } SendPlanInfo sendPlanInfo = new SendPlanInfo(); sendPlanInfo.SENDCODE = DateTime.Now.ToString("yyyyMMddHHmmss"); //生成贴车单号 sendPlanInfo.PRODUCESHIFTNAME = ClientContext.produceShift.PRODUCESHIFTNAME;//班组 sendPlanInfo.PRODUCESHIFTTCODE = ClientContext.produceShift.PRODUCESHIFTTCODE;//班组 sendPlanInfo.COUNT = mainList.Count; sendPlanInfo.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); //获取当前料架 MaterialShelfType type = this.comType.SelectedItem as MaterialShelfType; sendPlanInfo.SPID = type.PID; sendPlanInfo.MARERIALSHELFTYPECODE = type.MARERIALSHELFTYPECODE; sendPlanInfo.MARERIALSHELFTYPENAME = type.MARERIALSHELFTYPENAME; sendPlanInfo.PRODUCTTYPE = type.PRODUCTTYPE; sendPlanInfo.VERSION = type.VERSION; sendPlanInfo.COLORCODE = type.COLORCODE; sendPlanInfo.mainList = this.mainList; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataResult result = agent.InvokeServiceFunction>(B9IPCService.SendPlanInfoBLL_InsertAndUpdateMain.ToString(), sendPlanInfo); MessageBox.Show(result.Msg); //保存成功 if (result.IsSuccess) { this.mainList.Clear(); this.DGView.DataSource = new List
(); } } /// /// 添加条码 /// /// /// private void stbAdd_Click(object sender, EventArgs e) { ValidateAndAddCode(this.txtCode.Text.Trim()); this.txtCode.Text = ""; } /// /// 保存条码 /// /// /// private void tsbSave_Click(object sender, EventArgs e) { SaveInfo(); this.DialogResult = System.Windows.Forms.DialogResult.OK; } /// /// 删除选中条码 /// /// /// private void stbDelete_Click(object sender, EventArgs e) { if (this.DGView.SelectedRows.Count > 0) { string selectKey = this.DGView.SelectedRows[0].Cells["Pid"].Value.ToString(); this.mainList.RemoveAll(m => m.PID == selectKey); this.DGView.DataSource = new List
(); this.DGView.DataSource = this.mainList; } } /// /// 打开查询 /// /// /// private void tsbSearch_Click(object sender, EventArgs e) { SendPlanSearchForm form = new SendPlanSearchForm(); form.MdiParent = this.ParentForm; form.Show(); } /// /// 回车事件 /// /// /// private void SendPlanPrintForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter)//如果输入的是回车键 { this.stbAdd_Click(sender, e);//触发button事件 } } private void txtCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.stbAdd_Click(sender, e); } } } }