Beispiel #1
0
        private void butSave_Click(object sender, System.EventArgs e)
        {
            if (this.textBox2.Text.Trim().Length == 0)
            {
                baseForm.CreateMessageBox(Public_MessageBox.Warning, System.Windows.Forms.MessageBoxButtons.OK, "警告信息", "请先输入箱号");
                return;
            }
            int cartonNo = int.Parse(textBox2.Text);
            ////201306 George   --Begin
            if (cartonDt.Rows.Count <= 0)
            {

                //    baseForm.CreateMessageBox(Public_MessageBox.Warning ,   MessageBoxButtons.OK,         null, "没有输入数据");
                //    return ;
                DialogResult result = baseForm.CreateMessageBox(Public_MessageBox.Question,
                                                                 MessageBoxButtons.YesNo,
                                                     null, "没有输入数据,你是否要装空箱?");

                if (result == DialogResult.Yes)
                {    //空箱装,但要输入密码验证
                    frmLineCheck frm = new frmLineCheck();
                    DialogResult res = frm.ShowDialog();
                    if (res == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                    else
                    {
                        ////装空箱
                        if (saveCarton(cartonNo + ""))
                        {
                            this.txtOpened.Text = (int.Parse(txtOpened.Text) + 1) + "";
                            baseForm.CreateMessageBox(Public_MessageBox.Error, MessageBoxButtons.OK,
                                                       null, "保存成功!");
                            return;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {   //空箱不装,返回
                    return;
                }

            }
            ////201306 George   --End
            String checkresult = "";
            #region check with original info
            wsPAD.IwsPADClient client = new wsPAD.IwsPADClient();
            try
            {
                #region 构造当前箱
                DataTable curentCarton = (from p in boxDt.AsEnumerable()
                                          where p.Field<string>("cartonNumber") == cartonNo.ToString()
                                          select p).CopyToDataTable();
                curentCarton.TableName = "curentCarton";
                curentCarton.Columns.Add(new DataColumn("poid", typeof(System.String)));
                curentCarton.Columns.Add(new DataColumn("customerid", typeof(System.String)));
                foreach (DataRow item in curentCarton.Rows)
                {
                    item["poid"] = poID;
                    item["customerid"] = customerid;
                }
                #endregion
                //check 条件
                checkresult = client.PackBoxCheckGroup(curentCarton);
                if (checkresult == "OK")
                {

                    List<string> status = (from p in cartonDt.AsEnumerable()
                                           where p.Field<string>("cartonNumber") == cartonNo.ToString()
                                           select p.Field<string>("valid")).ToList<string>();
                    if (status[0] == "否")
                    {
                        #region 不满箱
                        string[] butText = { "直接封箱", "暂时保存" };
                        DialogResult result = baseForm.CreateMessageBox(Public_MessageBox.Question,
                                                                           MessageBoxButtons.YesNo,
                                                          null, "本箱不满箱,是否要封箱?", butText);

                        if (result == DialogResult.No)
                        {
                            this.saveTempInfo(curentCarton);
                            #region 修改为已经保存
                            for (int i = 0; i < cartonDt.Rows.Count; i++)
                            {
                                if (cartonDt.Rows[i]["cartonNumber"].ToString() == textBox2.Text)
                                {
                                    cartonDt.Rows[i]["status"] = "已保存(暂存线上)";

                                    break;
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            ////201307  George --Begin
                        //    frmLineCheck frm = new frmLineCheck();
                        //    DialogResult res = frm.ShowDialog();
                        //    if (res == System.Windows.Forms.DialogResult.Cancel)
                        //    {
                        //        return;
                        //    }
                            ////201307  George --End
                            saveCarton(curentCarton);
                            #region 修改为已经保存
                            for (int i = 0; i < cartonDt.Rows.Count; i++)
                            {
                                if (cartonDt.Rows[i]["cartonNumber"].ToString() == textBox2.Text)
                                {
                                    cartonDt.Rows[i]["status"] = "已保存";
                                    break;
                                }
                            }
                            ////201306 George --begin
                            this.txtOpened.Text = (int.Parse(txtOpened.Text) + 1) + "";
                            ////201306 George --end
                        }
                            #endregion
                        #endregion
                    }
                    else
                    {
                        #region 满箱
                        saveCarton(curentCarton);
                        #region 修改为已经保存
                        for (int i = 0; i < cartonDt.Rows.Count; i++)
                        {
                            if (cartonDt.Rows[i]["cartonNumber"].ToString() == textBox2.Text)
                            {
                                cartonDt.Rows[i]["status"] = "已保存";
                                break;
                            }
                        }
                        ////201306 George --begin
                        this.txtOpened.Text = (int.Parse(txtOpened.Text) + 1) + "";
                        ////201306 George --end
                        #endregion
                    }

                        #endregion
                }
                else
                {
                    baseForm.CreateMessageBox(Public_MessageBox.Error,
                                                 MessageBoxButtons.OK,
                                                  null, checkresult);
                }

            }
            catch (Exception ex)
            {
                MESMsgBox.ShowError(ExceptionParser.Parse(ex));
            }
            finally
            {
                baseForm.ResetCursor();
                baseForm.CloseWCF(client);
            }
            #endregion
        }
Beispiel #2
0
        private void butSaveRow_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.Length == 0 || textType.Text.Length == 0 || textSize.Text.Length == 0 || textPairQty.Text.Length == 0 || textColor.Text.Length == 0)
            {
                baseForm.CreateMessageBox(Public_MessageBox.Error, System.Windows.Forms.MessageBoxButtons.OK, "输入错误", "款号,颜色,尺码,数量必须输入");
            }
            try
            {
                #region create table if it's null
                if (cartonDt == null)
                {
                    cartonDt = new DataTable("carton");
                    cartonDt.TableName = "carton";
                    cartonDt.Columns.Add(new DataColumn("cartonNumber", typeof(System.String)));
                    cartonDt.Columns.Add(new DataColumn("qty", typeof(System.Int32)));
                    cartonDt.Columns.Add(new DataColumn("qty2", typeof(System.Int32)));
                    cartonDt.Columns.Add(new DataColumn("valid", typeof(System.Int32)));
                    cartonDt.Columns.Add(new DataColumn("status", typeof(System.String)));

                }

                if (boxDt == null)
                {
                    boxDt = new DataTable("box");
                    boxDt.TableName = "box";
                    boxDt.Columns.Add(new DataColumn("cartonNumber", typeof(System.String)));
                    boxDt.Columns.Add(new DataColumn("type", typeof(System.String)));
                    boxDt.Columns.Add(new DataColumn("color", typeof(System.String)));
                    boxDt.Columns.Add(new DataColumn("size", typeof(System.String)));
                    boxDt.Columns.Add(new DataColumn("qty", typeof(System.Int32)));
                    boxDt.Columns.Add(new DataColumn("qty2", typeof(System.Int32)));
                }
                #endregion

                #region check befor save
                #region 构造当前箱
                DataTable checkCarton = new DataTable("box");
                checkCarton.TableName = "box";
                checkCarton.Columns.Add(new DataColumn("cartonNumber", typeof(System.String)));
                checkCarton.Columns.Add(new DataColumn("type", typeof(System.String)));
                checkCarton.Columns.Add(new DataColumn("color", typeof(System.String)));
                checkCarton.Columns.Add(new DataColumn("size", typeof(System.String)));
                checkCarton.Columns.Add(new DataColumn("qty", typeof(System.Int32)));
                checkCarton.Columns.Add(new DataColumn("qty2", typeof(System.Int32)));
                checkCarton.Columns.Add(new DataColumn("poid", typeof(System.String)));
                checkCarton.Columns.Add(new DataColumn("customerid", typeof(System.String)));

                DataRow dr3 = checkCarton.NewRow();
                dr3["cartonNumber"] = textBox2.Text;
                dr3["type"] = textType.Text;
                dr3["color"] = textColor.Text;
                dr3["size"] = textSize.Text;
                dr3["qty"] = int.Parse(textPairQty.Text); ;
                dr3["qty2"] = int.Parse(textPairQty.Text);
                dr3["poid"] = poID;
                dr3["customerid"] = customerid;

                checkCarton.Rows.Add(dr3);

                #endregion
                wsPAD.IwsPADClient client = new wsPAD.IwsPADClient();
                try
                {
                    //check 条件
                    string checkresult = client.PackBoxCheckGroup(checkCarton);
                    if (checkresult != "OK")
                    {
                        //检查条件不通过
                        baseForm.CreateMessageBox(Public_MessageBox.Error,
                                                     MessageBoxButtons.OK,
                                                      null, checkresult);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MESMsgBox.ShowError(ExceptionParser.Parse(ex));
                }
                finally
                {
                    baseForm.ResetCursor();
                    baseForm.CloseWCF(client);
                }

                #endregion
                #region 获得开箱信息
                int openQtyGroup = 0;
                int openQtyBox = 0;
                string cartonNumber = textBox2.Text;
                DataSet rs = getOpenDetail(cartonNumber);
                if (rs != null)
                {
                    var resultGroup1 = (from p in rs.Tables[0].AsEnumerable()
                                        where p.Field<string>("styleno") == textType.Text
                                        && p.Field<string>("color") == textColor.Text
                                        && p.Field<string>("size") == textSize.Text
                                        select p).ToList();
                    if (resultGroup1.Count != 0)
                    {
                        DataRow currentGroup = resultGroup1[0];
                        openQtyGroup = int.Parse(currentGroup["pairqty"].ToString());
                    }

                    var openQtyOfCarton = (from p in rs.Tables[0].AsEnumerable()
                                           //   where p.Field<string>("styleno") == textType.Text
                                           //  && p.Field<string>("color") == textColor.Text
                                           //  && p.Field<string>("size") == textSize.Text
                                           select p.Field<Decimal>("pairqty")).Sum();

                    if (openQtyOfCarton != 0)
                    {
                        openQtyBox = (int)openQtyOfCarton;
                    }
                }
                #endregion

                #region 封箱与开箱数量不符

                if (openQtyBox == 0)   //没有开箱
                {
                    baseForm.CreateMessageBox(Public_MessageBox.Error, System.Windows.Forms.MessageBoxButtons.OK,
                                                   "提示信息", "没有开箱数据 ");
                    return;
                }
                else
                {
                    //已经开箱,但与开箱数量不符
                    if (openQtyGroup != int.Parse(textPairQty.Text))
                    {
                        DialogResult resultDlg = baseForm.CreateMessageBox(Public_MessageBox.Question, System.Windows.Forms.MessageBoxButtons.YesNo, "提示信息", "输入的数据与开箱数据不一致,是否继续?");
                        if (resultDlg == DialogResult.No)
                        {
                            return;  //放弃本次输入
                        }  ////201306 George --begin
                        else
                        {
                            frmLineCheck frm = new frmLineCheck();
                            DialogResult res = frm.ShowDialog();
                            if (res == System.Windows.Forms.DialogResult.Cancel)
                            {
                                return;
                            }

                        }
                        ////201306 George --end
                    }
                }
                #endregion

                #region WIP 不够Move
                int wip = getWIPQty(textType.Text, textColor.Text, textSize.Text);
                if (wip < int.Parse(textPairQty.Text))
                {
                    baseForm.CreateMessageBox(Public_MessageBox.Error, System.Windows.Forms.MessageBoxButtons.OK,
                                                   "提示信息", "线上没有这么多制品,你输入的数量不对");
                    return;
                }

                #endregion

                #region if carton don't exists, insert it

                var result = (from p in cartonDt.AsEnumerable()
                              where p.Field<string>("cartonNumber") == textBox2.Text
                              select p).ToList();

                if (result == null || result.Count == 0)
                {
                    //put data to new table
                    DataRow dr = cartonDt.NewRow();
                    dr["cartonNumber"] = textBox2.Text;
                    dr["qty"] = openQtyBox;
                    dr["qty2"] = 0;
                    dr["valid"] = "";

                    dr["status"] = "未保存";
                    cartonDt.Rows.Add(dr);
                }
                else
                {
                    //如已经保存到数据库,不可以再修改//////////
                    string status = result[0]["status"].ToString();
                    if (status == "已保存")
                    {
                        baseForm.CreateMessageBox(Public_MessageBox.Warning, MessageBoxButtons.OK, "警告信息", "已经保存到数据库,不可以修改!");
                        return;
                    }
                    ////////////////////////////////////////////

                }
                #endregion

                #region if group exists, update qty, else insert
                var resultGroup = (from p in boxDt.AsEnumerable()
                                   where p.Field<string>("cartonNumber") == textBox2.Text
                                   && p.Field<string>("type") == textType.Text
                                   && p.Field<string>("color") == textColor.Text
                                   && p.Field<string>("size") == textSize.Text
                                   select p);

                if (resultGroup.ToList().Count > 0)
                {
                    foreach (DataRow item in resultGroup)
                    {
                        item["qty2"] = int.Parse(textPairQty.Text);
                    }
                }
                else
                {
                    DataRow dr2 = boxDt.NewRow();
                    dr2["cartonNumber"] = textBox2.Text;
                    dr2["type"] = textType.Text;
                    dr2["color"] = textColor.Text;
                    dr2["size"] = textSize.Text;
                    dr2["qty"] = openQtyGroup;
                    dr2["qty2"] = int.Parse(textPairQty.Text);
                    boxDt.Rows.Add(dr2);

                }
                #endregion

                #region   update shoes qty of this carton
                var curentCarton = (from p in cartonDt.AsEnumerable()
                                    where p.Field<string>("cartonNumber") == textBox2.Text
                                    select p).ToList();

                var qtyOfCarton = (from p in boxDt.AsEnumerable()
                                   where p.Field<string>("cartonNumber") == textBox2.Text
                                   select p.Field<Int32>("qty2")).Sum();

                DataRow currentCarton = curentCarton[0];
                currentCarton["qty2"] = qtyOfCarton;
                currentCarton["status"] = "未保存";

                if (qtyOfCarton == openQtyBox)
                {
                    currentCarton["valid"] = "是";
                }
                else
                {
                    currentCarton["valid"] = "否";
                }

                #endregion

                #region bind data
                try
                {
                    this.ultraGrid1.SetDataBinding(ds, "");
                }
                catch (Exception ex)
                {
                    ;// MicroMESMsgBox.ShowError(ExceptionParser.Parse(ex));
                }

                #endregion

                #region 展开当前箱,闭合其他箱
                foreach (UltraGridRow row in this.ultraGrid1.Rows)
                {
                    if (null != row.ChildBands)
                    {
                        string carton1 = row.GetCellValue("cartonNumber").ToString();
                        if (carton1 == textBox2.Text)
                        {

                            row.Activate();
                            row.ExpandAll();
                        }
                        else
                        {
                            row.CollapseAll();
                        }
                    }

                }
                #endregion

                System.Windows.Forms.ToolTip toolTip2 = new System.Windows.Forms.ToolTip();
                toolTip2.IsBalloon = true;
                toolTip2.UseAnimation = true;
                toolTip2.UseFading = true;
                toolTip2.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
                toolTip2.SetToolTip(butSave, "如果是本箱数据已经输入完成,请单击这里保存");
                toolTip2.Show("如果是本箱数据已经输入完成,请单击这里保存", butSave, 1000);

                toolTip.SetToolTip(panelType, "如果本箱还没完成,请继续选择款号");
                toolTip.Show("如果本箱还没完成,请继续选择款号", panelType, 2000);
            }
            catch (Exception ex)
            {
                return;
            }
            finally
            {
                ;
            }
        }