コード例 #1
0
ファイル: FeedForm.cs プロジェクト: moling3650/Smart.MES.POD
        //自动投料事件
        private void kryptonButton1_Click(object sender, EventArgs e)
        {
            SelGridForm gridform = new SelGridForm(lotlist);

            gridform.ShowDialog();
            if (gridform.WIP != null)
            {
                lotWIP        = gridform.WIP;
                ktxt_lot.Text = lotWIP.lot_no;
                ktxt_lot_KeyPress(sender, new KeyPressEventArgs((char)13));
            }
        }
コード例 #2
0
ファイル: FeedForm.cs プロジェクト: moling3650/Smart.MES.POD
        //批次
        private void ktxt_lot_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && !ktxt_lot.ReadOnly)
            {
                if (string.IsNullOrWhiteSpace(ktxt_lot.Text))
                {
                    Component.Tool.DisplayResult(txt_resgx, false, "装料批次不能为空");
                    return;
                }
                string lot = ktxt_lot.Text.Trim().Replace("#", "");
                try
                {
                    string mat_code = string.Empty;
                    if (lotWIP == null)
                    {
                        string order_no = ktxtOrder.Text;
                        if (order_no == "")
                        {
                            MessageBox.Show("工单号不可为空,请选择工单", "提示");
                            return;
                        }
                        //根据批次号及工单获取物料编号
                        mat_code = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "GetMat_codeBylot", lot + "," + order_no);
                        if (mat_code == "")
                        {
                            MessageBox.Show("该工单和批次未能获取物料编号,请确认工单号及批次号", "提示");
                            return;
                        }
                    }
                    else
                    {
                        mat_code = lotWIP.mat_code;
                    }
                    DateTime MaterialInputTime = Convert.ToDateTime(Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "GetWipInputTimeByLot", lot + "," + mat_code));
                    string   strwip_valid      = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Product", "GetWip_validByProductCode", mat_code);
                    if (strwip_valid != "")
                    {
                        decimal  wip_valid = Convert.ToDecimal(strwip_valid);
                        TimeSpan ts        = DateTime.Now - MaterialInputTime;
                        decimal  h         = ts.Hours;
                        if (h > wip_valid)
                        {
                            DialogResult result = KryptonMessageBox.Show("该物料已超出时效时间,确定继续使用吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (result == System.Windows.Forms.DialogResult.No)
                            {
                                return;
                            }
                        }
                    }

                    ILE.IResult res = BLL.WIP.Check_WIP_Lot(ktxtOrder.Text, lot);
                    if (res.Result)
                    {
                        res = BLL.WIP.Get_WIP_LotInfo(ktxtOrder.Text, lot);
                        if (!res.Result)
                        {
                            Component.Tool.DisplayResult(txt_resgx, res.Result, res.ExtMessage);
                            return;
                        }
                        List <LEDAO.V_Material_WIP> wip = JsonConvert.DeserializeObject <List <LEDAO.V_Material_WIP> >(res.obj.ToString());
                        if (lotWIP == null)
                        {
                            if (wip.Count == 1)
                            {
                                lotWIP = wip[0];
                            }

                            //多个wip_id,弹窗选择
                            if (wip.Count > 1)
                            {
                                SelGridForm gridform = new SelGridForm(wip);
                                gridform.ShowDialog();
                                if (gridform.WIP != null)
                                {
                                    lotWIP        = gridform.WIP;
                                    ktxt_lot.Text = lotWIP.lot_no;
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        //判断是否是最小批次
                        if (!BLL.WIP.Check_Mbm(ktxtOrder.Text))
                        {
                            //是否可分批投入
                            if (BLL.WIP.Check_Mat_Split(Convert.ToInt32(lotWIP.id), ktxtOrder.Text))
                            {
                                UserForm.NumForm num = new UserForm.NumForm();
                                num.ShowDialog();
                                switch (num.State)
                                {
                                case 1:
                                    if (lotWIP.lot_qty < num.Num)
                                    {
                                        Component.Tool.DisplayResult(txt_resgx, false, "当前批次记录不能大于" + lotWIP.lot_qty);
                                        return;
                                    }
                                    lotWIP.lot_qty = num.Num;
                                    break;

                                case 2:
                                    break;

                                default:
                                    return;
                                }
                            }
                        }

                        int id = Convert.ToInt32(lotWIP.id);
                        res = BLL.WIP.Get_WIP_Point(kcb_Station.SelectedValue.ToString(), ktxtOrder.Text, id);


                        //判断是否有安装点
                        if (res.Result)
                        {
                            pointList = JsonConvert.DeserializeObject <List <string> >(res.obj.ToString());
                            if (pointList.Count > 0)
                            {
                                ktxt_piont.Visible    = true;
                                kryptonLabel2.Visible = true;
                                ktxt_piont.Focus();
                            }
                        }
                        else
                        {
                            res = BLL.WIP.Sumit_FeedMatToStation(id, null, kcb_Station.SelectedValue.ToString(), ktxtOrder.Text, ktxt_emp.Text, lotWIP.lot_qty);
                            deWork();
                            DataBind();
                        }
                    }
                    else
                    {
                        ktxt_lot.Text = "";
                    }

                    Component.Tool.DisplayResult(txt_resgx, res.Result, res.ExtMessage);
                }
                catch (Exception exc)
                {
                    KryptonMessageBox.Show(exc.Message);
                }
                finally
                {
                    lotWIP = null;
                }
            }
        }