//确定
        private void button1_Click(object sender, EventArgs e)
        {
            string Faultreason_code = ((Tools.ComboboxItem) this.comboBox1.SelectedItem).Value.ToString();// 选中故障原因
            string Grade            = this.comboBox2.Text.ToString();
            string Remarks          = this.textBox2.Text.ToString();
            string ExceptionJson    = string.Empty;

            try
            {
                P_Machine_Exception Exception = new P_Machine_Exception()
                {
                    exception_code       = Guid.NewGuid(),
                    faultphenomenon_code = Faultreason_code,
                    machine_code         = machine_code,
                    state         = 1,
                    grade         = Grade,
                    submit_time   = DateTime.Now,
                    submit_person = Ecode,
                    remarks       = Remarks,
                };
                string strJson = JsonToolsNet.ObjectToJson(Exception);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineException", strJson);
                MessageBox.Show("上报成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("上报失败", "提示");
                return;
            }
            this.Close();
        }
Пример #2
0
 //不良数输完,添加不良
 private void ktb_NGnum_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         if (text_empcode.Text == "")
         {
             MessageBox.Show("请输入工号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             text_empcode.Focus();
             return;
         }
         if (ktb_NGcoude.Text == "")
         {
             MessageBox.Show("请输入不良代码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             ktb_NGcoude.Focus();
             return;
         }
         if (ktb_NGnum.Text == "")
         {
             MessageBox.Show("请输入不良数量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (checkNGCode())
         {
             ktb_NGnum.Focus();
         }
         else
         {
             ktb_NGcoude.Text = null;
             ktb_NGcoude.Focus();
             return;
         }
         try
         {
             P_OQC_NGList ngList = new P_OQC_NGList()
             {
                 oqc_order_no = ktb_oqcoreder.Text.Trim(),
                 order_no     = ktb_orderNo.Text.Trim(),
                 ng_code      = ktb_NGcoude.Text.Trim(),
                 ng_qty       = Convert.ToDecimal(ktb_NGnum.Text.Trim()),
                 input_time   = DateTime.Now,
                 emp_code     = text_empcode.Text.Trim()
             };
             string strJson = JsonToolsNet.ObjectToJson(ngList);
             Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.OQC", "CreateNGList", strJson);
             MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             LoadGridView();
             ktb_NGcoude.Text = null;
             ktb_NGnum.Text   = null;
             ktb_NGcoude.Focus();
         }
         catch (Exception)
         {
             MessageBox.Show("请输入正确的不良数量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             ktb_NGnum.Text = null;
             ktb_NGnum.Focus();
             return;
         }
     }
 }
Пример #3
0
        //装载
        private void button1_Click(object sender, EventArgs e)
        {
            string Sparepart_code = this.textBox1.Text.Trim().ToString().ToUpper();

            if (Sparepart_code == "")
            {
                MessageBox.Show("备件编码不可为空", "提示");
                return;
            }
            string             Json          = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineSparepart", Sparepart_code + "," + machine_code);
            List <B_Sparepart> ListSparepart = JsonConvert.DeserializeObject <List <B_Sparepart> >(Json);

            if (ListSparepart != null)
            {
                string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineSparepartRecords_1", Sparepart_code + "," + machine_code);
                List <P_Sparepart_Records> ListSparepartRecords = JsonConvert.DeserializeObject <List <P_Sparepart_Records> >(RecordsJson);
                if (ListSparepartRecords == null)
                {
                    //说明第一次装载备件,啥也不干
                }
                else
                {
                    Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineSparepartRecord_0", Sparepart_code + "," + machine_code);
                }
                try
                {
                    P_Sparepart_Records Sparepart = new P_Sparepart_Records()
                    {
                        sparepart_code = Sparepart_code,
                        machine_code   = machine_code,
                        type           = 0,
                        state          = 1,
                        loadtime       = DateTime.Now,
                        operate_person = Ecode,
                    };
                    string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                    Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineSparepartRecord_0", strJson);
                    MessageBox.Show("装载成功", "提示");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("装载失败", "提示");
                    return;
                }
            }
            else
            {
                MessageBox.Show("该备件不属于设备型号:[" + machine_name + "]", "提示");
                return;
            }
            initSparepartRecords();
        }
Пример #4
0
        /// <summary>
        /// 关机
        /// </summary>
        public static void AddMachine_StopRecordsClose(string machine_code, List <V_Station_Shop> List, string Faultreason_code, string E_code)
        {
            //根据关机原因获取关机后状态
            string StopreasonJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetStopreason", Faultreason_code);
            List <B_Machine_Stopreason> ListStopreason = JsonConvert.DeserializeObject <List <B_Machine_Stopreason> >(StopreasonJson);
            int stop_state = 0;

            if (ListStopreason != null)
            {
                stop_state = (int)ListStopreason[0].stop_state;
            }
            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineStopRecords_0", machine_code);
            List <P_Sparepart_Records> ListSparepartRecords = JsonConvert.DeserializeObject <List <P_Sparepart_Records> >(RecordsJson);

            if (ListSparepartRecords == null)
            {
                //啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineStopRecord_1", machine_code);
            }

            try
            {
                P_Machine_StopRecords Sparepart = new P_Machine_StopRecords()
                {
                    process_code   = List[0].process_code,
                    station_code   = List[0].station_code,
                    ws_code        = List[0].ws_code,
                    machine_code   = machine_code,
                    stop_reason    = Faultreason_code,
                    type           = 0,
                    state          = 0,
                    isNew          = 1,
                    starttime      = DateTime.Now,
                    operate_person = E_code,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineStopRecord_0", strJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineStateClose", machine_code + "," + stop_state.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("关机失败", "提示");
                return;
            }
        }
Пример #5
0
        /// <summary>
        /// 卸载配件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            string       Accessory_code = accessoryList[0].accessory_code.ToString().Trim().ToUpper();
            string       machine_code   = accessoryList[0].machine_code.ToString().Trim().ToUpper();
            DialogResult result         = KryptonMessageBox.Show("确定卸载吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryRecords_0", Accessory_code + "," + machine_code);
            List <P_Accessory_Records> ListAccessoryRecords = JsonConvert.DeserializeObject <List <P_Accessory_Records> >(RecordsJson);

            if (ListAccessoryRecords == null)
            {
                //说明第一次装载备件,啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryRecord_1", Accessory_code + "," + machine_code);
            }
            try
            {
                P_Accessory_Records Sparepart = new P_Accessory_Records()
                {
                    Accessory_code   = Accessory_code,
                    machine_code     = machine_code,
                    type             = 1,
                    state            = 0,
                    loadtime         = DateTime.Now,
                    input_time       = DateTime.Now,
                    Accessory_preson = Ecode,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineAccessoryRecord_0", strJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "DeleteAccessoryLoad", Accessory_code);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateAccessorystate_0", Accessory_code);
                //Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryIsLoad_1", Accessory_code);
                //MessageBox.Show("卸载成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("卸载失败", "提示");
                return;
            }
            Acc.initAccessoryRecords(2, "");
            Acc.GetAccessoryType();
        }
Пример #6
0
        //生成抽检按钮
        private void kryptonButton1_Click(object sender, EventArgs e)
        {
            if (kcb_order.Text == "" || ktl_total.Text == "0")
            {
                MessageBox.Show("请将信息填写完整后再试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string      oqcorder  = "Q" + DateTime.Now.ToString("yyyyMMddHHmm") + kcb_order.Text;//动态生成检验单据号
            B_OQC_Order oqc_order = new B_OQC_Order()
            {
                order_no     = kcb_order.Text,
                qty          = Convert.ToDecimal(ktl_total.Text),
                type_id      = Convert.ToInt32(kryptonComboBox2.SelectedValue),
                oqc_id       = Convert.ToInt32(kryptonComboBox1.SelectedValue),
                idx_id       = Convert.ToInt32(kcb_Level.SelectedValue),
                state        = 2,
                input_time   = DateTime.Now,
                oqc_order_no = oqcorder,
                oqc_result   = null,
                end_time     = null
            };

            try
            {
                string strJson = JsonToolsNet.ObjectToJson(oqc_order);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.OQC", "CreateOQC_Order", strJson);
            }
            catch (Exception)
            {
                MessageBox.Show("生成失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                throw;
            }

            MessageBox.Show("生成成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

            string num  = ktl_total.Text;
            string tpid = kryptonComboBox2.SelectedValue.ToString();
            string id   = kcb_Level.SelectedValue.ToString();
            string dt   = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.OQC", "GetIndex", num + "," + tpid + "," + id);
            List <V_OQC_Index_Detail> oqcList = JsonConvert.DeserializeObject <List <V_OQC_Index_Detail> >(dt);
            string NGValue = oqcList.FirstOrDefault().idx_value.ToString();
            string oqcno   = oqcorder;
            string orderNo = kcb_order.Text;

            new OQCWin(NGValue, oqcno, orderNo).Show();
            this.Hide();
        }
Пример #7
0
        /// <summary>
        /// 报障
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            string Accessory_code = accessoryList[0].accessory_code.ToString().Trim().ToUpper();
            string machine_code   = accessoryList[0].machine_code.ToString().Trim().ToUpper();


            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryRecords_0", Accessory_code + "," + machine_code);
            List <P_Accessory_Records> ListAccessoryRecords = JsonConvert.DeserializeObject <List <P_Accessory_Records> >(RecordsJson);

            if (ListAccessoryRecords == null)
            {
                //说明第一次装载备件,啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryRecord_1", Accessory_code + "," + machine_code);
            }
            try
            {
                P_Accessory_Records Sparepart = new P_Accessory_Records()
                {
                    Accessory_code   = Accessory_code,
                    machine_code     = machine_code,
                    type             = 1,
                    state            = 0,
                    loadtime         = DateTime.Now,
                    input_time       = DateTime.Now,
                    Accessory_preson = Ecode,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineAccessoryRecord_0", strJson);
            }
            catch { }

            Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "DeleteAccessoryLoad", Accessory_code);
            Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateAccessorystate", Accessory_code);
            MessageBox.Show("报障成功", "提示");
            Acc.initAccessoryRecords(2, "");
            Acc.GetAccessoryType();
        }
Пример #8
0
        //卸载
        private void button2_Click(object sender, EventArgs e)
        {
            string Sparepart_code = this.dataGridView1.SelectedRows[0].Cells["Column1"].Value.ToString();
            string RecordsJson    = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineSparepartRecords_0", Sparepart_code + "," + machine_code);
            List <P_Sparepart_Records> ListSparepartRecords = JsonConvert.DeserializeObject <List <P_Sparepart_Records> >(RecordsJson);

            if (ListSparepartRecords == null)
            {
                //说明第一次装载备件,啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineSparepartRecord_1", Sparepart_code + "," + machine_code);
            }
            try
            {
                P_Sparepart_Records Sparepart = new P_Sparepart_Records()
                {
                    sparepart_code = Sparepart_code,
                    machine_code   = machine_code,
                    type           = 1,
                    state          = 0,
                    loadtime       = DateTime.Now,
                    operate_person = Ecode,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineSparepartRecord_0", strJson);
                MessageBox.Show("卸载成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("卸载失败", "提示");
                return;
            }
            initSparepartRecords();
            this.textBox1.Text = "";
        }
Пример #9
0
        /// <summary>
        /// 开机
        /// </summary>
        /// <param name="machine_code"></param>
        /// <param name="List"></param>
        /// <param name="E_code"></param>
        public static void AddMachine_StopRecordsOpen(string machine_code, List <V_Station_Shop> List, string E_code)
        {
            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineStopRecords_1", machine_code);
            List <P_Sparepart_Records> ListSparepartRecords = JsonConvert.DeserializeObject <List <P_Sparepart_Records> >(RecordsJson);

            if (ListSparepartRecords == null)
            {
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineStopRecord_0", machine_code);
            }

            try
            {
                P_Machine_StopRecords Sparepart = new P_Machine_StopRecords()
                {
                    process_code   = List[0].process_code,
                    station_code   = List[0].station_code,
                    ws_code        = List[0].ws_code,
                    machine_code   = machine_code,
                    type           = 1,
                    state          = 1,
                    isNew          = 1,
                    starttime      = DateTime.Now,
                    operate_person = E_code,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineStopRecord_0", strJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineStateOpen", machine_code);
            }
            catch (Exception ex)
            {
                MessageBox.Show("开机失败", "提示");
                return;
            }
        }
Пример #10
0
        //保存
        private void kryptonButton6_Click(object sender, EventArgs e)
        {
            if (this.tb_Copies.Text.Trim() == "")
            {
                MessageBox.Show("请输入打印份数");
                return;
            }
            if (this.tb_mid.Text.Trim() == "")
            {
                MessageBox.Show("请输入式样编号");
                return;
            }
            if (this.tb_mName.Text.Trim() == "")
            {
                MessageBox.Show("请输入式样名称");
                return;
            }
            if (this.tb_msn.Text.Trim() == "")
            {
                MessageBox.Show("请输入最大SN");
                return;
            }
            if (this.tb_filePath.Text.Trim() == "")
            {
                MessageBox.Show("请选择打印模板路径");
                return;
            }
            if (this.tb_filePath.Text.IndexOf(".Lab") < 0)
            {
                MessageBox.Show("请选择正确的模板保存");
                return;
            }
            if (this.cb_setZero.SelectedIndex < 0)
            {
                MessageBox.Show("请选择归零方式");
                return;
            }
            string var = string.Empty;

            for (int i = 0; i < ckBox_variable.CheckedItems.Count; i++)
            {
                if (i < ckBox_variable.CheckedItems.Count - 1)
                {
                    var += ((ComboboxItem)ckBox_variable.CheckedItems[i]).Value + ',';
                }
                else
                {
                    var += ((ComboboxItem)ckBox_variable.CheckedItems[i]).Value;
                }
            }

            P_SSW_TemplateList TemplateList = new P_SSW_TemplateList()
            {
                Template_id   = this.tb_mid.Text.ToString(),
                Template_name = this.tb_mName.Text.ToString(),
                product_code  = this.Product_textBox.Text.ToString(),
                RuleStr       = this.ktb_ruleText.Text.ToString(),
                inputTime     = DateTime.Now,
                currentSN     = int.Parse(this.tb_currentSN.Text),
                //maxSN=int.Parse(this.tb_maxsn.Text),
                maxSN        = moduleID != "" ? int.Parse(this.tb_msn.Text) : int.Parse(this.tb_maxsn.Text),
                setZero      = this.cb_setZero.Text.ToString(),
                zeroDate     = DateTime.Now,
                TemplatePath = this.tb_filePath.Text,
                faxType      = rb2.Checked ? 2 : 1,
                checkCode    = kcb_checkCode.Checked ? 1 : 0,
                variable     = var,
                printCopies  = Convert.ToInt32(tb_Copies.Text.ToString())
            };

            if (this.moduleID != "")   //修改
            {
                try
                {
                    string strJson = JsonToolsNet.ObjectToJson(TemplateList);
                    Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateTemplate", moduleID + "|" + strJson);
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("修改成功!");
                    this.Hide();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("修改失败:" + exc.Message);
                    return;
                }
            }
            else                      //新增
            {
                try
                {
                    string strJson = JsonToolsNet.ObjectToJson(TemplateList);
                    Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertTemplate", strJson);
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("新增成功!");
                    this.Hide();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("新增失败:" + exc.Message);
                    return;
                }
            }
        }
Пример #11
0
        private void ktb_start_Click(object sender, EventArgs e)
        {
            if (ktb_pNum.Text == "")
            {
                MessageBox.Show("请输入打印张数", "提示");
                return;
            }
            if (ktb_Pcopies.Text == "")
            {
                MessageBox.Show("请输入打印份数", "提示");
                return;
            }
            //if (decimal.Parse(ktb_sy.Text) == 0)
            //{
            //    MessageBox.Show("该工单已经打印完成,请尽快结案", "提示");
            //    return;
            //}
            //if (decimal.Parse(ktb_sy.Text) < int.Parse(ktb_pNum.Text))
            //{
            //    MessageBox.Show("打印张数不可大于剩余打印数", "提示");
            //    return;
            //}
            //if (Convert.ToDecimal(int.Parse(ktb_pNum.Text)) > Convert.ToDecimal(ktb_sy.Text))
            //{
            //    ktb_pNum.Text = ktb_sy.Text;
            //}
            string        Order_No = this.ktb_orderNO.Text.ToString();
            SerialManager sm       = null;

            if (kryptonComboBox1.SelectedIndex > 0)   //如果打印进制不是10进制
            {
                string entName = kryptonComboBox1.SelectedValue.ToString();
                sm = GetSM(entName);   //获取一个序列号管理对象
            }
            string suffix = "";

            for (int it = 0; it < int.Parse(ktb_pNum.Text); it++)
            {
                if (proc1[0].checkCode == 1)
                {
                    barcode.sn = GetSNByEnter(sm, Int32.Parse(this.ktb_currentSN.Text) + it);
                    suffix     = barcode.suffix + NVBarcode.CheckCode.ModCheckCode(barcode);
                }
                else
                {
                    suffix = barcode.suffix;
                }
                //根据前缀后缀判断是否存在数据,如果有数据,在当前的sn累加打印,没有数据则从1开始打印
                //string PrintSn = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrint_currentSn", barcode.prefix + "," + suffix);
                //PrintSnList = JsonConvert.DeserializeObject<List<P_Print_CurrentSN>>(PrintSn);
                string sn = "";
                if (PrintSnList != null)
                {
                    sn = NVBarcode.CodeRule.GetCompleteSN(GetSNByEnter(sm, int.Parse(PrintSnList[0].current_sn.ToString()) + it), barcode.snStr.Length);  //获取完整的SN
                }
                else
                {
                    sn = NVBarcode.CodeRule.GetCompleteSN(GetSNByEnter(sm, 1 + it), barcode.snStr.Length);  //获取完整的SN
                }

                string             workinfo = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetWorder", Order_No);
                List <P_WorkOrder> workList = JsonConvert.DeserializeObject <List <P_WorkOrder> >(workinfo);

                string            variable = proc1[0].variable.ToString();
                List <V_variable> varList  = new List <V_variable>();
                if (variable != "" && !string.IsNullOrEmpty(variable))
                {
                    string[] variableList = variable.Split(',');

                    for (int index = 0; index < variableList.Count(); index++)
                    {
                        V_variable variabletemp = new V_variable();
                        if (variableList[index].ToString() == "version")
                        {
                            variabletemp.Text  = variableList[index].ToString();
                            variabletemp.value = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrintList1", workList[0].main_order + "," + variableList[index].ToString());
                        }
                        else
                        {
                            variabletemp.Text  = variableList[index].ToString();
                            variabletemp.value = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrintList", orderNO + "," + variableList[index].ToString());
                        }
                        varList.Add(variabletemp);
                    }
                }

                pn.printDocument(sn, 0, prefix, suffix, 1, Convert.ToInt32(ktb_Pcopies.Text), int.Parse(proc1[0].faxType.ToString()), varList);


                string           _product_code   = proc2[0].product_code;
                string           ProductCode     = NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetProduct", _product_code);
                List <B_Product> ProductCodeList = JsonConvert.DeserializeObject <List <B_Product> >(ProductCode);
                if (ProductCodeList[0].print_bind == 1)
                {
                    //打印一个条码,在条码绑定表插入一条数据
                    P_BarCodeBing P_barcode = new P_BarCodeBing()
                    {
                        order        = Order_No,
                        parent_order = workList[0].parent_order,
                        main_order   = workList[0].main_order,
                        state        = 0,
                        barcode      = barcode.prefix + sn + suffix,
                        product_code = _product_code,
                        InputTime    = DateTime.Now
                    };
                    string strJson = JsonToolsNet.ObjectToJson(P_barcode);
                    Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertBarCode", strJson);
                }
            }

            //添加或修改P_Print_CurrentSN数据
            if (PrintSnList != null)
            {
                //修改
                string Sn = (PrintSnList[0].current_sn + Convert.ToInt32(decimal.Parse(ktb_pNum.Text))).ToString();
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateP_Print_currentSn", barcode.prefix + "|" + suffix + "|" + Sn);
            }
            else
            {
                //添加
                P_Print_CurrentSN P_Print_CurrentSN = new P_Print_CurrentSN()
                {
                    prefix     = barcode.prefix,
                    suffix     = suffix,
                    current_sn = Convert.ToInt32(1 + Convert.ToInt32(decimal.Parse(ktb_pNum.Text))),
                    input_time = DateTime.Now
                };
                string strJson = JsonToolsNet.ObjectToJson(P_Print_CurrentSN);
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertPrint_CurrentSn", strJson);
            }


            this.klb_barcode.Text = "条码:";
            //修改P_SSW_TemplateList的currentSN
            string MId = proc2[0].Template_id.ToString();
            int    CSN = int.Parse(proc1[0].currentSN.ToString()) + int.Parse(ktb_pNum.Text);

            Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateTemplateByMid", MId + "|" + CSN);
            //为P_SSW_PrintList新增或修改
            string dt = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrint_orderNo", orderNO);
            List <P_SSW_PrintList> proc = JsonConvert.DeserializeObject <List <P_SSW_PrintList> >(dt);

            if (proc != null)
            {
                //修改
                string  order_no = proc[0].order_no.ToString();
                decimal num      = Convert.ToDecimal(proc2[0].completed.ToString()) + int.Parse(ktb_pNum.Text.ToString());
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdatePrintByOrder_no", order_no + "|" + num);
            }
            else
            {
                //添加
                P_SSW_PrintList P_list = new P_SSW_PrintList()
                {
                    completed    = Convert.ToInt32(this.ktb_pNum.Text.ToString()),
                    order_no     = this.ktb_orderNO.Text.ToString(),
                    product_code = proc2[0].product_code,
                    product_name = null,
                    Template_id  = proc2[0].Template_id,
                    qty          = proc2[0].qty,
                    inputTime    = DateTime.Now,
                    finishTime   = DateTime.Now,
                    state        = null
                };
                string strJson = JsonToolsNet.ObjectToJson(P_list);
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertPrint", strJson);
            }
            //重新绑定工单信息
            BindOrderRu();
            if (Convert.ToDecimal(this.ktb_sy.Text) == 0)
            {
                //修改工单状态
                string order_no = proc2[0].order_no.ToString();
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateWorkOderState", order_no);
            }

            //}
        }
Пример #12
0
        //测试API1
        //public static string InsertDate(string json)
        //{
        //    string StrJson = json.Replace("\\", "\\\\");
        //    DataTable tb = JsonToTable(StrJson);
        //    string order=tb.Rows[0]["order_no"].ToString();
        //    //判断获取数据在本地数据库是否存在
        //    var context1 = LEDAO.APIGateWay.GetEntityContext();
        //    var var = from b in context1.P_SSW_PrintList_test where b.order_no == order select b;
        //    string isAdd = null;
        //    if (var.Count() > 0)
        //    {
        //        isAdd = "2";
        //    }
        //    else
        //    {
        //        isAdd = "1";
        //    }
        //    //根据获取数据生成新的Json
        //    P_SSW_PrintList_test obj = new P_SSW_PrintList_test();
        //    obj.order_no = tb.Rows[0]["order_no"].ToString();
        //    obj.inputTime = Convert.ToDateTime(tb.Rows[0]["inputTime"].ToString());
        //    obj.product_code = tb.Rows[0]["product_code"].ToString();
        //    obj.product_name = tb.Rows[0]["product_name"].ToString();
        //    obj.qty = Convert.ToDecimal(tb.Rows[0]["qty"].ToString());
        //    obj.state = tb.Rows[0]["state"].ToString();
        //    obj.Template_id = tb.Rows[0]["Template_id"].ToString();
        //    if (tb.Rows[0]["finishTime"].ToString() == "")
        //    {
        //        obj.finishTime = null;
        //    }
        //    else
        //    {
        //        obj.finishTime = Convert.ToDateTime(tb.Rows[0]["finishTime"].ToString());
        //    }
        //    obj.completed = Convert.ToInt32(tb.Rows[0]["completed"].ToString());
        //    string strJson1 = JsonToolsNet.ObjectToJson(obj);
        //    //添加或修改
        //    string STR = "";
        //    //添加
        //    if (isAdd == "1")
        //    {
        //        LEDAO.P_SSW_PrintList_test tem = JsonConvert.DeserializeObject<LEDAO.P_SSW_PrintList_test>(strJson1);
        //        var context = LEDAO.APIGateWay.GetEntityContext();
        //        using (context)
        //        {
        //            context.P_SSW_PrintList_test.AddObject(tem);
        //            context.SaveChanges();
        //        }
        //        STR = "1";
        //    }
        //    //修改
        //    if (isAdd == "2")
        //    {
        //        LEDAO.P_SSW_PrintList_test tem = JsonConvert.DeserializeObject<LEDAO.P_SSW_PrintList_test>(strJson1);
        //        using (var context2 = LEDAO.APIGateWay.GetEntityContext())
        //        {
        //            string No = tb.Rows[0]["order_no"].ToString();
        //            var model = context2.P_SSW_PrintList_test.Where(X => X.order_no == No).FirstOrDefault();
        //            model.Template_id = tem.Template_id;
        //            model.inputTime = tem.inputTime;
        //            model.product_code = tem.product_code;
        //            model.order_no = tem.order_no;
        //            model.product_name = tem.product_name;
        //            model.qty = tem.qty;
        //            model.state = tem.state;
        //            model.finishTime = tem.finishTime;
        //            model.completed = tem.completed;
        //            context2.SaveChanges();
        //        }
        //        STR = "2";
        //    }
        //    return STR;
        //}
        //工单同步
        public static string WorkOrderSyncAPI(string json)
        {
            string    StrJson = json.Replace("\\", "\\\\");
            DataTable tb      = JsonToTable(StrJson);
            string    order   = tb.Rows[0]["FBillNo"].ToString();
            //判断获取数据在本地数据库是否存在
            var    context1 = LEDAO.APIGateWay.GetEntityContext();
            var    var      = from b in context1.P_WorkOrder where b.order_no == order select b;
            string isAdd    = null;

            if (var.Count() > 0)
            {
                isAdd = "2";
            }
            else
            {
                isAdd = "1";
            }
            //根据获取数据生成新的Json
            P_WorkOrder obj = new P_WorkOrder();

            obj.order_no     = tb.Rows[0]["FBillNo"].ToString();
            obj.input_time   = Convert.ToDateTime(tb.Rows[0]["FCheckDate"].ToString());
            obj.planned_time = Convert.ToDateTime(tb.Rows[0]["FPlanCommitDate"].ToString());
            obj.product_code = tb.Rows[0]["FItemID"].ToString();
            obj.qty          = Convert.ToDecimal(tb.Rows[0]["FQty"].ToString());
            obj.parent_order = tb.Rows[0]["FParentInterID"].ToString();
            obj.CO           = tb.Rows[0]["FOrderInterID"].ToString();
            obj.state        = Convert.ToInt32(tb.Rows[0]["FStatus"].ToString());
            obj.flow_code    = tb.Rows[0]["FRoutingID"].ToString();
            string strJson1 = JsonToolsNet.ObjectToJson(obj);
            //添加或修改
            string STR = "";

            //添加
            if (isAdd == "1")
            {
                LEDAO.P_WorkOrder tem = JsonConvert.DeserializeObject <LEDAO.P_WorkOrder>(strJson1);
                var context           = LEDAO.APIGateWay.GetEntityContext();
                using (context)
                {
                    context.P_WorkOrder.AddObject(tem);
                    context.SaveChanges();
                }
                STR = "1";
            }
            //修改
            if (isAdd == "2")
            {
                LEDAO.P_WorkOrder tem = JsonConvert.DeserializeObject <LEDAO.P_WorkOrder>(strJson1);
                using (var context2 = LEDAO.APIGateWay.GetEntityContext())
                {
                    string No    = tb.Rows[0]["FBillNo"].ToString();
                    var    model = context2.P_WorkOrder.Where(X => X.order_no == No).FirstOrDefault();
                    model.order_no     = tem.order_no;
                    model.input_time   = tem.input_time;
                    model.product_code = tem.product_code;
                    model.order_no     = tem.order_no;
                    model.qty          = tem.qty;
                    model.state        = tem.state;
                    model.planned_time = tem.planned_time;
                    model.parent_order = tem.parent_order;
                    model.CO           = tem.CO;
                    model.property     = tem.property;
                    model.urgency      = tem.urgency;
                    model.flow_code    = tem.flow_code;
                    context2.SaveChanges();
                }
                STR = "2";
            }
            return(STR);
        }
Пример #13
0
        private void ktb_input1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                Component.Tool.DisplayResult(textBox1, true, "");
                string SFC = ktb_input1.Text.Trim();
                try
                {
                    string str = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetSfcState", SFC);
                    if (str.Length == 0)
                    {
                        //Component.Tool.DisplayResult(textBox3, true, "托盘号不存在,是否创建托盘?");
                        DialogResult result = KryptonMessageBox.Show("确定创建此托盘号吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result == System.Windows.Forms.DialogResult.No)
                        {
                            ktb_input1.Text = "";
                            ktb_input1.Focus();
                            //Component.Tool.DisplayResult(textBox3, true, "请输入托盘号");
                            List <P_SFC_State> dp = new List <P_SFC_State>();
                            kryptonDataGridView1.DataSource = dp;
                            return;
                        }

                        P_SFC_State sfcList = new P_SFC_State()
                        {
                            is_tray = 1,
                            SFC     = ktb_input1.Text,
                        };
                        string strJson = JsonToolsNet.ObjectToJson(sfcList);
                        string opq     = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFCState", strJson);
                        ktb_input1.Text = "";
                        ktb_input2.Focus();
                        ktb_input2.Enabled = true;
                        //Component.Tool.DisplayResult(textBox4, true, "请输入SFC");
                        //Component.Tool.DisplayResult(textBox3, true, "");
                        List <P_SFC_State> kn = new List <P_SFC_State>();
                        kryptonDataGridView1.DataSource = kn;
                        return;
                    }
                    else
                    {
                        List <P_SFC_State> dt = JsonConvert.DeserializeObject <List <P_SFC_State> >(str);

                        if (dt[0].is_tray == 0)
                        {
                            //Component.Tool.DisplayResult(textBox3, false, "不是托盘号,请重新输入!");
                            ktb_input1.Text = "";
                            ktb_input1.Focus();
                            List <P_SFC_State> kn = new List <P_SFC_State>();
                            kryptonDataGridView1.DataSource = kn;
                            return;
                        }
                        else
                        {
                            string tray_sfc = dt[0].SFC;
                            string msn      = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetTrayDetail", tray_sfc);
                            if (msn.Length == 0)
                            {
                                ktb_input2.Enabled = true;
                                //Component.Tool.DisplayResult(textBox3, true, "托盘目前为空");
                                List <P_SFC_State> kn = new List <P_SFC_State>();
                                kryptonDataGridView1.DataSource = kn;
                                ktb_input2.Focus();
                                return;
                            }
                            else
                            {
                                ktb_input2.Enabled = true;
                                //Component.Tool.DisplayResult(textBox3, true, "加载成功");
                                LoadGridView();
                                ktb_input2.Focus();
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    KryptonMessageBox.Show(exc.Message);
                }
            }
        }
Пример #14
0
        private void ktb_input2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                Component.Tool.DisplayResult(textBox1, true, "");
                //Component.Tool.DisplayResult(textBox4, true, "");
                string SFC = ktb_input2.Text.Trim();

                try
                {
                    string str = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetSfcState", SFC);
                    if (str.Length == 0)
                    {
                        //Component.Tool.DisplayResult(textBox4, false, "SFC不存在,请重新输入");
                        ktb_input2.Text = "";
                        ktb_input2.Focus();
                        return;
                    }
                    else
                    {
                        List <LEDAO.P_SFC_State> dt = JsonConvert.DeserializeObject <List <LEDAO.P_SFC_State> >(str);
                        if (kryptonDataGridView1.RowCount > 0)
                        {
                            if (dt[0].is_tray == 0 && dt[0].order_no == order_no && dt[0].state == state && dt[0].now_process == now_process)
                            {
                                P_Tray_Detail sfcList = new P_Tray_Detail()
                                {
                                    tray_sfc   = ktb_input1.Text,
                                    sfc        = dt[0].SFC,
                                    input_time = DateTime.Now,
                                };
                                string strJson = JsonToolsNet.ObjectToJson(sfcList);
                                string opq     = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFC", strJson);
                                if (opq.Length > 0)
                                {
                                    //Component.Tool.DisplayResult(textBox4, false, "此SFC已在托盘中!");
                                }
                                else
                                {
                                    //Component.Tool.DisplayResult(textBox4, true, "添加成功");
                                }
                                //Component.Tool.DisplayResult(textBox3, true, "");
                                LoadGridView();
                            }
                            else if (dt[0].is_tray == 1 && dt[0].order_no == order_no && dt[0].state == state)
                            {
                                string strn = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetTrayDetail", SFC);
                                if (strn.Length == 0)
                                {
                                    //Component.Tool.DisplayResult(textBox4, false, "空托盘,请重新输入");
                                    ktb_input2.Text = "";
                                    ktb_input2.Focus();
                                    return;
                                }
                                else
                                {
                                    List <LEDAO.P_Tray_Detail> kp = JsonConvert.DeserializeObject <List <LEDAO.P_Tray_Detail> >(strn);
                                    foreach (var item in kp)
                                    {
                                        P_Tray_Detail sfcList = new P_Tray_Detail()
                                        {
                                            tray_sfc   = ktb_input1.Text,
                                            sfc        = item.sfc,
                                            input_time = DateTime.Now,
                                        };
                                        string strJson = JsonToolsNet.ObjectToJson(sfcList);
                                        string opq     = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFC", strJson);
                                        if (opq.Length > 0)
                                        {
                                            //Component.Tool.DisplayResult(textBox4, false, "此SFC已在托盘中!");
                                        }
                                        else
                                        {
                                            //Component.Tool.DisplayResult(textBox4, true, "添加成功");
                                        }
                                    }

                                    //Component.Tool.DisplayResult(textBox3, true, "");
                                    LoadGridView();
                                }
                            }

                            else
                            {
                                //Component.Tool.DisplayResult(textBox4, false, "工单或状态不匹配,请重新输入");
                                ktb_input2.Text = "";
                                ktb_input2.Focus();
                            }
                        }
                        else
                        {
                            if (dt[0].is_tray == 0)
                            {
                                P_Tray_Detail sfcList = new P_Tray_Detail()
                                {
                                    tray_sfc   = ktb_input1.Text,
                                    sfc        = dt[0].SFC,
                                    input_time = DateTime.Now,
                                };
                                string strJson = JsonToolsNet.ObjectToJson(sfcList);
                                string opq     = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFC", strJson);
                                if (opq.Length > 0)
                                {
                                    //Component.Tool.DisplayResult(textBox4, false, "此SFC已在托盘中!");
                                }
                                else
                                {
                                    //Component.Tool.DisplayResult(textBox4, true, "添加成功");
                                }
                                //Component.Tool.DisplayResult(textBox3, true, "");
                                LoadGridView();
                            }
                            else
                            {
                                string stro = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetTrayDetail", SFC);
                                if (stro.Length == 0)
                                {
                                    //Component.Tool.DisplayResult(textBox4, false, "空托盘");
                                    ktb_input2.Text = "";
                                    ktb_input2.Focus();
                                    return;
                                }
                                else
                                {
                                    string strn = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "GetTrayDetail", SFC);

                                    List <LEDAO.P_Tray_Detail> kp = JsonConvert.DeserializeObject <List <LEDAO.P_Tray_Detail> >(strn);
                                    foreach (var item in kp)
                                    {
                                        P_Tray_Detail sfcList = new P_Tray_Detail()
                                        {
                                            tray_sfc   = ktb_input1.Text,
                                            sfc        = item.sfc,
                                            input_time = DateTime.Now,
                                        };
                                        string strJson = JsonToolsNet.ObjectToJson(sfcList);
                                        string opq     = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Pack", "AddSFC", strJson);
                                        if (opq.Length > 0)
                                        {
                                            //Component.Tool.DisplayResult(textBox4, false, "此SFC已在托盘中!");
                                        }
                                        else
                                        {
                                            //Component.Tool.DisplayResult(textBox4, true, "添加成功");
                                        }
                                    }

                                    //Component.Tool.DisplayResult(textBox3, true, "");
                                    LoadGridView();
                                }
                            }
                        }

                        ktb_input2.Text = "";
                    }
                }
                catch (Exception exc)
                {
                    KryptonMessageBox.Show(exc.Message);
                }
            }
        }
Пример #15
0
        /// <summary>
        ///  卸载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string Accessory_code = this.textBox1.Text.ToString().Trim().ToUpper();

            //判断已装载的配件是否卸载,如果已卸载,不可重复卸载
            #region
            //string RecordsJson1 = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessory", Accessory_code + "," + machine_code);
            //List<B_Machine_Accessories> ListAccessory = JsonConvert.DeserializeObject<List<B_Machine_Accessories>>(RecordsJson1);
            //if (ListAccessory != null)
            //{
            //    foreach (var item in ListAccessory)
            //    {
            //        if (item.accessory_isload == 0)
            //        {
            //            MessageBox.Show("编码为[" + Accessory_code + "]的配件已卸载!", "提示");
            //            return;
            //        }
            //    }
            //}
            #endregion
            string RecordsJson1 = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryLoad_1", machine_code + "," + Accessory_code);
            List <P_Accessoris_Load> ListAccessory = JsonConvert.DeserializeObject <List <P_Accessoris_Load> >(RecordsJson1);
            if (ListAccessory == null)
            {
                MessageBox.Show("编码为[" + Accessory_code + "]的配件已卸载!", "提示");
                return;
            }
            DialogResult result = KryptonMessageBox.Show("确定卸载吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryRecords_0", Accessory_code + "," + machine_code);
            List <P_Accessory_Records> ListAccessoryRecords = JsonConvert.DeserializeObject <List <P_Accessory_Records> >(RecordsJson);
            if (ListAccessoryRecords == null)
            {
                //说明第一次装载备件,啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryRecord_1", Accessory_code + "," + machine_code);
            }
            try
            {
                P_Accessory_Records Sparepart = new P_Accessory_Records()
                {
                    Accessory_code   = Accessory_code,
                    machine_code     = machine_code,
                    type             = 1,
                    state            = 0,
                    loadtime         = DateTime.Now,
                    input_time       = DateTime.Now,
                    Accessory_preson = Ecode,
                };
                string strJson = JsonToolsNet.ObjectToJson(Sparepart);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineAccessoryRecord_0", strJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "DeleteAccessoryLoad", Accessory_code);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateAccessorystate_0", Accessory_code);
                //Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryIsLoad_1", Accessory_code);
                //MessageBox.Show("卸载成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("卸载失败", "提示");
                return;
            }
            initAccessoryRecords(2, "");
            GetAccessoryType();
            this.textBox1.Text = "";
        }
Пример #16
0
        private void ktb_start_Click(object sender, EventArgs e)
        {
            if (ktb_pNum.Text == "")
            {
                MessageBox.Show("请输入打印张数", "提示");
                return;
            }
            if (ktb_Pcopies.Text == "")
            {
                MessageBox.Show("请输入打印份数", "提示");
                return;
            }
            string        Order_No = this.ktb_orderNO.Text.ToString();
            SerialManager sm       = null;

            if (kryptonComboBox1.SelectedIndex > 0)   //如果打印进制不是10进制
            {
                string entName = kryptonComboBox1.SelectedValue.ToString();
                sm = GetSM(entName);   //获取一个序列号管理对象
            }
            string             suffix   = "";
            List <P_WorkOrder> workList = null;

            for (int it = 0; it < int.Parse(ktb_pNum.Text); it++)
            {
                if (proc1[0].checkCode == 1)
                {
                    barcode.sn = GetSNByEnter(sm, Int32.Parse(this.ktb_currentSN.Text) + it);
                    suffix     = barcode.suffix + NVBarcode.CheckCode.ModCheckCode(barcode);
                }
                else
                {
                    suffix = barcode.suffix;
                }
                //根据前缀后缀判断是否存在数据,如果有数据,在当前的sn累加打印,没有数据则从1开始打印
                //string PrintSn = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrint_currentSn", barcode.prefix + "," + suffix);
                //PrintSnList = JsonConvert.DeserializeObject<List<P_Print_CurrentSN>>(PrintSn);
                string sn = "";
                if (PrintSnList != null)
                {
                    sn = NVBarcode.CodeRule.GetCompleteSN(GetSNByEnter(sm, int.Parse(PrintSnList[0].current_sn.ToString()) + it), barcode.snStr.Length);  //获取完整的SN
                }
                else
                {
                    sn = NVBarcode.CodeRule.GetCompleteSN(GetSNByEnter(sm, 1 + it), barcode.snStr.Length);  //获取完整的SN
                }

                ktb_Pcopies.Text = proc1[0].printCopies.ToString();
                for (int i = 0; i < Convert.ToInt32(ktb_Pcopies.Text); i++)
                {
                    pn.printDocument(sn, 1, prefix, suffix, 1, 1, int.Parse(proc1[0].faxType.ToString()));
                }
                string workinfo = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetWorder", Order_No);
                workList = JsonConvert.DeserializeObject <List <P_WorkOrder> >(workinfo);
                string           _product_code   = proc2[0].product_code;
                string           ProductCode     = NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetProduct", _product_code);
                List <B_Product> ProductCodeList = JsonConvert.DeserializeObject <List <B_Product> >(ProductCode);
                if (ProductCodeList[0].print_bind == 1)
                {
                    //打印一个条码,在条码绑定表插入一条数据
                    P_BarCodeBing P_barcode = new P_BarCodeBing()
                    {
                        order        = Order_No,
                        parent_order = workList[0].parent_order,
                        main_order   = workList[0].main_order,
                        state        = 0,
                        barcode      = barcode.prefix + sn + suffix,
                        product_code = _product_code,
                        InputTime    = DateTime.Now
                    };
                    string strJson = JsonToolsNet.ObjectToJson(P_barcode);
                    Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertBarCode", strJson);
                }
                //timer1.Stop();
            }
            //int planSN = (int.Parse(PrintSnList[0].current_sn.ToString()) - 1) + int.Parse(ktb_pNum.Text);
            //int planSN = (int.Parse(this.ktb_currentSN.Text) - 1) + int.Parse(ktb_pNum.Text);
            //PrintConfirm pconfirm = new PrintConfirm(int.Parse(ktb_pNum.Text), planSN);
            //pconfirm.ShowDialog();
            //if (pconfirm.num > 0)   //如果确认有打印数量
            //{
            //添加或修改P_Print_CurrentSN数据
            if (PrintSnList != null)
            {
                //修改
                string Sn = (PrintSnList[0].current_sn + Convert.ToInt32(decimal.Parse(ktb_pNum.Text))).ToString();
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateP_Print_currentSn", barcode.prefix + "|" + suffix + "|" + Sn);
            }
            else
            {
                //添加
                P_Print_CurrentSN P_Print_CurrentSN = new P_Print_CurrentSN()
                {
                    prefix     = barcode.prefix,
                    suffix     = suffix,
                    current_sn = Convert.ToInt32(1 + Convert.ToInt32(decimal.Parse(ktb_pNum.Text))),
                    input_time = DateTime.Now
                };
                string strJson = JsonToolsNet.ObjectToJson(P_Print_CurrentSN);
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertPrint_CurrentSn", strJson);
            }


            this.klb_barcode.Text = "条码:";
            //修改P_SSW_TemplateList的currentSN
            string MId = proc2[0].Template_id.ToString();
            int    CSN = int.Parse(proc1[0].currentSN.ToString()) + int.Parse(ktb_pNum.Text);

            Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateTemplateByMid", MId + "|" + CSN);
            //为P_SSW_PrintList新增或修改
            string dt = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetPrint_orderNo", orderNO);
            List <P_SSW_PrintList> proc = JsonConvert.DeserializeObject <List <P_SSW_PrintList> >(dt);

            if (proc != null)
            {
                //修改
                string order_no = proc[0].order_no.ToString();
                int    num      = int.Parse(proc2[0].completed.ToString()) + int.Parse(ktb_pNum.Text.ToString());
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdatePrintByOrder_no", order_no + "|" + num);
            }
            else
            {
                //添加
                P_SSW_PrintList P_list = new P_SSW_PrintList()
                {
                    completed    = Convert.ToInt32(this.ktb_pNum.Text.ToString()),
                    order_no     = this.ktb_orderNO.Text.ToString(),
                    Main_order   = workList[0].main_order,
                    product_code = proc2[0].product_code,
                    product_name = null,
                    Template_id  = proc2[0].Template_id,
                    qty          = proc2[0].qty,
                    inputTime    = null,
                    finishTime   = null,
                    state        = null
                };
                string strJson = JsonToolsNet.ObjectToJson(P_list);
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertPrint", strJson);
            }
            //重新绑定工单信息
            BindOrderRu();
            if (Convert.ToDecimal(this.ktb_qty.Text) - Convert.ToDecimal(this.ktb_complete.Text) <= 0)
            {
                //修改工单状态
                string order_no = proc2[0].order_no.ToString();
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateWorkOderState", order_no);
            }
            string Alreadyprint = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetAlreadyPrint", workList[0].main_order);
            List <P_SSW_PrintList> AlreadyprintList = JsonConvert.DeserializeObject <List <P_SSW_PrintList> >(Alreadyprint);
            string Mainworkinfo = Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetByMain_order", workList[0].main_order);
            int    WorkOrderNum = JsonConvert.DeserializeObject <List <P_WorkOrder> >(Mainworkinfo).Count;

            if (AlreadyprintList != null && AlreadyprintList.Count == WorkOrderNum)
            {
                Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateMainWorkOderState", workList[0].main_order);
            }
            //}
        }
Пример #17
0
        //提交操作
        private void btn_reback_Click(object sender, EventArgs e)
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();
            try
            {
                if (string.IsNullOrWhiteSpace(richTextBox_faildesc.Text.Trim()))
                {
                    MessageBox.Show("请给出维修说明,在记录中填写", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (string.IsNullOrWhiteSpace(kComboBox_Process.Text.Trim()))
                {
                    MessageBox.Show("请选择责任工序", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //修改数据库信息,1.P_SFC_State(如果P_SFC_State表中存在记录才修改),
                //更新P_SFC_State 当前工序和过站时间 +P_SFC_Process_IOLog 当前工序
                int    ishebeifail = 0;
                string str         = "";
                List <P_Fail_Detail> lstpFailDetail = new List <P_Fail_Detail>();
                for (int i = 0; i < dataGridView_faildetail.Rows.Count; i++)
                {
                    P_Fail_Detail onepfaildetail = new P_Fail_Detail();
                    onepfaildetail.id = int.Parse(dataGridView_faildetail.Rows[i].Cells["detail_id"].Value.ToString());
                    if ((this.dataGridView_faildetail.Rows[i].Cells["failReasoncode"] as DataGridViewComboBoxCell).Value == null)
                    {
                        MessageBox.Show("原因代码为空,请选择", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    onepfaildetail.reason_code = dicReason[(string)(this.dataGridView_faildetail.Rows[i].Cells["failReasoncode"] as DataGridViewComboBoxCell).Value];
                    if (onepfaildetail.reason_code.Contains("EEE"))  //判断是否为设备不良原因代码
                    {
                        ishebeifail = 1;
                    }
                    if ((this.dataGridView_faildetail.Rows[i].Cells["failtype"] as DataGridViewComboBoxCell).Value == null)
                    {
                        MessageBox.Show("原因类型代码为空,请选择", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    onepfaildetail.reasontype_code = dicTypeReason[(string)(this.dataGridView_faildetail.Rows[i].Cells["failtype"] as DataGridViewComboBoxCell).Value];
                    lstpFailDetail.Add(onepfaildetail);
                }
                //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes
                if (checkBox1.Checked == true)
                {
                    if (checkedListBox1.CheckedItems.Count > 0)
                    {
                        for (int items = 0; items < checkedListBox1.CheckedItems.Count; items++)
                        {
                            string judecode     = ((ComboboxItem)checkedListBox1.CheckedItems[items]).Value;
                            string judename     = ((ComboboxItem)checkedListBox1.CheckedItems[items]).Text;
                            string SFC          = textBox_sfc.Text.ToString();
                            string JudeCodeJson = client.RunServerAPI("BLL.SFC", "GetJudeSFC", judecode + "," + SFC);
                            if (string.IsNullOrEmpty(JudeCodeJson))
                            {
                                P_SFC_Jude sfc_jude = new P_SFC_Jude()
                                {
                                    jude_code = judecode,
                                    jude_name = judename,
                                    sfc       = SFC,
                                    state     = 0
                                };
                                string judejson = JsonToolsNet.ObjectToJson(sfc_jude);
                                client.RunServerAPI("BLL.SFC", "InsertSFCJude", judejson);
                            }
                            else
                            {
                                MessageBox.Show("该批次已存在[ " + judename + " ]的待判,不可重复", "提示");
                                return;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("请勾选待判名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                string      strJson        = "";
                P_SFC_State clpsfcstateTmp = new P_SFC_State();
                clpsfcstateTmp.order_no   = strorderno;
                clpsfcstateTmp.SFC        = strsfc;
                clpsfcstateTmp.fail_times = 0;
                if (iRepairProcc == 1)  //降级
                {
                    if (string.IsNullOrWhiteSpace(kComboBox_ProductGrade.Text.Trim()))
                    {
                        MessageBox.Show("请先设置级别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (string.IsNullOrWhiteSpace(kComboBox_rebackprocess.Text.Trim()))
                    {
                        MessageBox.Show("请先设置返回工序", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    clpsfcstateTmp.from_process = strfromprocess_code;
                    clpsfcstateTmp.now_process  = diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()];
                    if (clpsfcstateTmp.now_process == "END")
                    {
                        clpsfcstateTmp.state = 2;//该批次已完成,可以流向下一工序
                    }
                    else
                    {
                        clpsfcstateTmp.state = 1;  //设置状态为 1 ,未完成,,正常加工
                    }

                    B_Product_Grade clBProductGrade = new B_Product_Grade();
                    clBProductGrade           = dicProductGrade[kComboBox_ProductGrade.Text.Trim()];
                    clpsfcstateTmp.grade_id   = clBProductGrade.grade_id.ToString();
                    clpsfcstateTmp.grade_type = clBProductGrade.grade_type;
                    //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes
                    strJson = strorderno + "," + strsfc + "," + diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()]
                              + "," + "1" + "," + "0" + "," + "0" + "," + clBProductGrade.grade_id + "," + clBProductGrade.grade_type + "," + "0" + "," + strfromprocess_code;
                }
                else if (iRepairProcc == 2) //待判
                {
                    //待完善???
                }
                else if (iRepairProcc == 3)    //报废
                {
                    clpsfcstateTmp.state = -1; //设置状态为 -1 ,已报废

                    clpsfcstateTmp.now_process = "END";
                    //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes
                    strJson = strorderno + "," + strsfc + "," + "END" + "," + "-1" + "," + "0" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "0" + "," + strfromprocess_code;
                }
                else  //不做操作,直接返回指定工序
                {
                    if (string.IsNullOrWhiteSpace(kComboBox_rebackprocess.Text.Trim()))
                    {
                        MessageBox.Show("请先设置返回工序", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    clpsfcstateTmp.state       = 1; //设置状态为 1 ,未完成,,正常加工
                    clpsfcstateTmp.now_process = diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()];
                    //order,sfc,nowprocess,state,failtimes,pass,grade_id,grade_type,iofailtimes
                    strJson = strorderno + "," + strsfc + "," + diczrprocess[this.kComboBox_rebackprocess.Text.ToString().Trim()]
                              + "," + "1" + "," + "0" + "," + "0" + "," + "grade_id" + "," + "grade_type" + "," + "0" + "," + strfromprocess_code;
                }

                str = client.RunServerAPI("BLL.SFC", "UpDataSFCInfoAndSFCIOLogData", strJson);
                if (!str.Contains("OK"))
                {
                    MessageBox.Show("更新P_SFC_State 失败 Or P_SFC_Process_IOLog 失败," + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                //更新维修结果  P_FailLog  P_Fail_Detail
                P_FailLog clpfaillog = new P_FailLog();
                clpfaillog.fid = int.Parse(strfid);
                if (!string.IsNullOrWhiteSpace(kComboBox_Process.Text.Trim()))
                {
                    clpfaillog.process_code     = strfromprocess_code;
                    clpfaillog.Disposal_Process = strfromprocess_code;
                    #region
                    //if (diczrprocess.Keys.Contains(kComboBox_Process.Text.Trim()))
                    //{
                    //    clpfaillog.process_code = diczrprocess[kComboBox_Process.Text.Trim()];
                    //}
                    //else
                    //{
                    //    MessageBox.Show("请选择责任工序!");
                    //    return;
                    //}
                    //clpfaillog.Disposal_Process = diczrprocess[kComboBox_Process.Text.Trim()];
                    #endregion
                    //根据责任工序,找到责任人和工位
                    strJson = "";
                    strJson = strsfc + "," + clpfaillog.process_code;
                    str     = client.RunServerAPI("BLL.SFC", "GetSFCIOLogInfo", strJson);
                    if (string.IsNullOrWhiteSpace(str))
                    {
                        //
                    }
                    else
                    {
                        List <P_SFC_Process_IOLog> lstsfciolog = JsonConvert.DeserializeObject <List <P_SFC_Process_IOLog> >(str);
                        if (lstsfciolog.Count > 0)
                        {
                            clpfaillog.emp_code = lstsfciolog[0].emp_code;
                        }
                        if (ishebeifail == 1) //存在设备不良,需要根据工位代码找到设备代码
                        {
                            //根据工位,找到设备
                            str = client.RunServerAPI("BLL.Station", "GetStationEquipmentByStation", lstsfciolog[0].station_code);
                            if (string.IsNullOrWhiteSpace(str))
                            {
                                //
                            }
                            else
                            {
                                List <B_StationMachine> lststationequipment = JsonConvert.DeserializeObject <List <B_StationMachine> >(str);
                                if (lstsfciolog.Count > 0)
                                {
                                    clpfaillog.equipment_code = lststationequipment[0].machine_code;
                                }
                            }
                        }
                    }
                }
                if (iRepairProcc == 1) //降级
                {
                    clpfaillog.state = 1;
                }
                else if (iRepairProcc == 2) //待判
                {
                    //待完善???
                }
                else if (iRepairProcc == 3) //报废
                {
                    clpfaillog.state = 9;   //报废状态
                }
                else
                {
                    clpfaillog.state = 1;
                }
                if (!string.IsNullOrWhiteSpace(richTextBox_faildesc.Text.Trim()))
                {
                    clpfaillog.repair_remark = richTextBox_faildesc.Text.Trim();
                }
                str = "";
                str = client.RunServerAPI("BLL.Faillog", "UpdateFailLog", JsonConvert.SerializeObject(clpfaillog));
                if (!str.Contains("1"))
                {
                    MessageBox.Show("更新P_FailLog 失败" + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                str = "";
                str = client.RunServerAPI("BLL.Fail_Detail", "UpdateFail_Detail", JsonConvert.SerializeObject(lstpFailDetail));
                if (!str.Contains("1"))
                {
                    MessageBox.Show("更新P_Fail_Detail 失败" + str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("提交失败:" + exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //提交完成
            MessageBox.Show("维修完成", "OK", MessageBoxButtons.OK, MessageBoxIcon.None);
            this.Close();
        }
Пример #18
0
        /// <summary>
        ///  装载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string Accessory_code = this.textBox1.Text.Trim().ToString().ToUpper();

            if (Accessory_code == "")
            {
                MessageBox.Show("配件编码不可为空", "提示");
                return;
            }
            //判断设备是否保养,是否可用
            string AccessoryJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetAccessory", Accessory_code);
            List <B_Accessories> listAccessory = JsonConvert.DeserializeObject <List <B_Accessories> >(AccessoryJson);
            int type_id = 0;

            if (listAccessory != null)
            {
                foreach (var item in listAccessory)
                {
                    if (item.state == 1)
                    {
                        MessageBox.Show("配件 [" + item.accessory_name + " ]已使用", "提示");
                        return;
                    }
                    if (item.state == 2)
                    {
                        MessageBox.Show("配件 [" + item.accessory_name + " ]保养中", "提示");
                        return;
                    }
                    if (item.state == 3)
                    {
                        MessageBox.Show("配件 [" + item.accessory_name + " ]维修中", "提示");
                        return;
                    }
                    if (item.state == 4)
                    {
                        MessageBox.Show("配件 [" + item.accessory_name + " ]已报废", "提示");
                        return;
                    }
                    if (item.maintian_type == 0)
                    {
                        if (((DateTime)(item.maintain_nexttime)).AddMinutes(-5) <= DateTime.Now && DateTime.Now <= ((DateTime)(item.maintain_nexttime)).AddMinutes(5))
                        {
                            MessageBox.Show("配件[" + item.accessory_name + "]已到保养时间,请保养!", "提示");
                            return;
                        }
                    }
                    if (item.maintian_type == 1)
                    {
                        if (item.Userqty >= item.maintain_quality)
                        {
                            MessageBox.Show("配件[" + item.accessory_name + "]已达到保养件数,请保养!", "提示");
                            return;
                        }
                    }
                    type_id = (int)item.type_id;
                }
            }
            else
            {
                MessageBox.Show("配件[" + Accessory_code + "]不存在", "提示");
                return;
            }
            //判断扫描设备是否属于绑定的设备型号
            string AccessorytypeAllJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryAllType", machine_code);
            List <V_Machnie_Accessory_type> ListAccessorytypeAll = JsonConvert.DeserializeObject <List <V_Machnie_Accessory_type> >(AccessorytypeAllJson);

            if (ListAccessorytypeAll != null)
            {
                List <string> list = new List <string>();
                foreach (var item in ListAccessorytypeAll)
                {
                    list.Add(item.type_id.ToString());
                }
                if (!list.Contains(type_id.ToString()))
                {
                    MessageBox.Show("该配件不属于该设备,请核对", "提示");
                    return;
                }
            }
            else
            {
                MessageBox.Show("该设备没有绑定配件,不可装载", "提示");
                return;
            }

            //判断已装载的配件是否卸载,如果未卸载,不可重复安装
            string RecordsJson1 = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryLoad_1", machine_code + "," + Accessory_code);
            List <P_Accessoris_Load> ListAccessory = JsonConvert.DeserializeObject <List <P_Accessoris_Load> >(RecordsJson1);

            if (ListAccessory != null)
            {
                MessageBox.Show("编码为[" + Accessory_code + "]的配件已装载!", "提示");
                return;
            }
            //判断是否转载完成,完成则不可超出装载
            string MachineRecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessory", type_id.ToString() + "," + machine_code);
            List <B_Machine_Accessories> ListMachineAccessory = JsonConvert.DeserializeObject <List <B_Machine_Accessories> >(MachineRecordsJson);
            int accessory_count = 0;

            if (ListMachineAccessory != null)
            {
                foreach (var item in ListMachineAccessory)
                {
                    accessory_count = (int)item.accessory_count;
                }
            }
            string StrJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryLoad_0", machine_code + "," + type_id.ToString());
            List <P_Accessoris_Load> ListAccessoryLoad = JsonConvert.DeserializeObject <List <P_Accessoris_Load> >(StrJson);

            if (ListAccessoryLoad != null)
            {
                if (ListAccessoryLoad.Count >= accessory_count)
                {
                    MessageBox.Show("同类型号的配件已装载完成", "提示");
                    return;
                }
            }
            string RecordsJson = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "GetMachineAccessoryRecords_1", Accessory_code + "," + machine_code);
            List <P_Accessory_Records> ListAccessoryRecords = JsonConvert.DeserializeObject <List <P_Accessory_Records> >(RecordsJson);

            if (ListAccessoryRecords == null)
            {
                //说明第一次装载配件,啥也不干
            }
            else
            {
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryRecord_0", Accessory_code + "," + machine_code);
            }
            try
            {
                //配件使用记录
                P_Accessory_Records Accessory_Records = new P_Accessory_Records()
                {
                    Accessory_code   = Accessory_code,
                    machine_code     = machine_code,
                    type             = 0,
                    state            = 1,
                    loadtime         = DateTime.Now,
                    input_time       = DateTime.Now,
                    Accessory_preson = Ecode,
                };
                string strJson = JsonToolsNet.ObjectToJson(Accessory_Records);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineAccessoryRecord_0", strJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateMachineAccessoryIsLoad", Accessory_code);
                //装载过后配件绑定设备
                P_Accessoris_Load Accessoris_Load = new P_Accessoris_Load()
                {
                    accessory_code = Accessory_code,
                    accessory_type = listAccessory[0].type_id,
                    machine_code   = machine_code,
                };
                string Accessoris_LoadJson = JsonToolsNet.ObjectToJson(Accessoris_Load);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "AddMachineAccessoryLoad", Accessoris_LoadJson);
                Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.Machine", "UpdateAccessorystate_1", Accessory_code);
                //MessageBox.Show("装载成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("装载失败", "提示");
                return;
            }
            initAccessoryRecords(2, "");
            this.textBox1.Text = "";
            GetAccessoryType();
            //装载配件打开定时器
            //main.Timer();
        }
Пример #19
0
        public static void Print(string variable, string Main_order, Form fm, List <P_SSW_TemplateList> list, string clas)
        {
            string var     = variable;
            string Main_Od = Main_order;
            Form   form    = fm;
            List <P_SSW_TemplateList> proc1 = list;

            KryptonComboBox com = new KryptonComboBox();

            com = (KryptonComboBox)form.Controls.Find("kryptonComboBox1", true)[0];
            KryptonTextBox tb = new KryptonTextBox();

            tb = (KryptonTextBox)form.Controls.Find("ktb_orderNO", true)[0];
            TextBox tb_1 = new TextBox();

            tb_1 = (TextBox)form.Controls.Find("tb_1", true)[0];
            TextBox tb_2 = new TextBox();

            tb_2 = (TextBox)form.Controls.Find("tb_2", true)[0];
            KryptonLabel lb = new KryptonLabel();

            lb = (KryptonLabel)form.Controls.Find("klb_barcode", true)[0];

            pn = NVBarcode.PrintEngine6.GetPrintEngine(proc1[0].TemplatePath);
            string Mid = proc1[0].RuleStr.ToString();

            if (Mid.IndexOf("(") > -1)
            {
                PrintVari pv = new PrintVari(Mid, "", "");
                pv.ShowDialog();
                Mid = pv.result;
            }
            NVBarcode.CodeRule coderule = NV_SNP.Objs.SpecialRule.TransformRuleStr(Mid);   //将特殊规则转成一般规则
            barcode = coderule.GetCodeByRule();
            lb.Text = barcode.prefix + barcode.snStr + barcode.suffix;
            if (com.SelectedIndex > 0)   //如果打印进制不是10进制
            {
                string entName = com.SelectedValue.ToString();
                sm = GetSM(entName);   //获取一个序列号管理对象
            }
            for (int it = int.Parse(tb_1.Text); it <= int.Parse(tb_2.Text); it++)
            {
                string sn     = NVBarcode.CodeRule.GetCompleteSN(GetSNByEnter(sm, it), barcode.snStr.Length); //获取完整的SN
                string suffix = "";
                if (proc1[0].checkCode == 1)
                {
                    barcode.sn = GetSNByEnter(sm, it);
                    suffix     = barcode.suffix + NVBarcode.CheckCode.ModCheckCode(barcode);
                }
                else
                {
                    suffix = barcode.suffix;
                }
                pn.printDocument(sn, 1, barcode.prefix, suffix, 1, 1, int.Parse(proc1[0].faxType.ToString()));
                string             order_No = tb.Text.ToString();
                string             workinfo = NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetWorder", order_No);
                List <P_WorkOrder> proc2    = JsonConvert.DeserializeObject <List <P_WorkOrder> >(workinfo);
                //补打是重复的条码不重复插入清单
                string           product_code    = proc2[0].product_code;
                string           ProductCode     = NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetProduct", product_code);
                List <B_Product> ProductCodeList = JsonConvert.DeserializeObject <List <B_Product> >(ProductCode);
                if (ProductCodeList[0].print_bind == 1)
                {
                    string             Bar         = barcode.prefix + sn + suffix;
                    string             BarCode     = NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "GetBarCode", Bar);
                    List <P_WorkOrder> BarCodeList = JsonConvert.DeserializeObject <List <P_WorkOrder> >(BarCode);
                    if (BarCodeList == null)
                    {
                        //打印一个条码,在条码绑定表插入一条数据
                        P_BarCodeBing P_barcode = new P_BarCodeBing()
                        {
                            order        = order_No,
                            parent_order = proc2[0].parent_order,
                            main_order   = proc2[0].main_order,
                            state        = 0,
                            barcode      = Bar,
                            product_code = proc2[0].product_code,
                            InputTime    = DateTime.Now
                        };
                        string strJson = JsonToolsNet.ObjectToJson(P_barcode);
                        NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "InsertBarCode", strJson);
                    }
                }
                //string MID=proc1[0].Template_id;
                //if (Convert.ToInt32(tb_2.Text) > proc1[0].currentSN)
                //{
                //    int CSN = Convert.ToInt32(tb_2.Text);
                //    NV_SNP.Toos.ServiceReferenceManager.GetClient().RunServerAPI("BLL.SSW", "UpdateTemplateByMid", MID + "|" + CSN);
                //}
            }
        }