示例#1
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);
            }

            //}
        }
示例#2
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);
            }
            //}
        }