Esempio n. 1
0
        private void reprint2()
        {
            if (lstItems.Items.Count < Convert.ToInt32(txtTotal.Text))
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NOT_FULL_QUANTITY_ERROR"), "ERROR", MessageBoxButtons.OK);
                return;
            }

            PrintDialog dlg = new PrintDialog();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            PrinterSettings setting = dlg.PrinterSettings;

            PrintLabelData data = new PrintLabelData();

            data.PCode    = txtCode.Text;
            data.DataCode = GetCodeDate();
            data.Date     = GetDate();
            data.Total    = Convert.ToInt32(txtTotal.Text);
            TPCResult <int> result = Database.GetModuleCount(m_Mode, txtCode.Text);

            if (result.State == RESULT_STATE.NG)
            {
                MessageBox.Show(result.Message);
                return;
            }

            data.Quantity = result.Value;

            string label_nameFrist  = "";
            string label_nameSecond = "fxzz_additional";

            switch (m_Mode)
            {
            case PACK_MODE.Pack:
                label_nameFrist = "pack_fxzz";
                break;

            case PACK_MODE.Carton:
                label_nameFrist = "carton_fxzz";
                break;

            case PACK_MODE.Pallet:
                label_nameFrist = "pallet_fxzz";
                break;
            }
            //打印第一页信息
            TPCPrintLabel labelFrist      = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameFrist);
            List <string> parametersFrist = MakePrintParameters(m_Mode, data);

            //打印第二页信息
            TPCPrintLabel labelSecond      = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameSecond);
            List <string> parametersSecond = MakePrintParameters(m_Mode, data);

            #region 修改打印参数
            #region lotNo
            string lotNo = parametersSecond[14];
            parametersSecond[14] = lotNo.Substring(0, lotNo.Length - 1);
            #endregion


            parametersSecond[5] = changeDateFormat(parametersSecond[14].Substring(3));

            ///将时间格式9013改成2019-01-03
            string changeDateFormat(string dateCode)
            {
                string outputTime = "";

                string[] code = { dateCode.Substring(0, 1), dateCode.Substring(1, 2), dateCode.Substring(3, 1) };
                #region 确定年月日
                //确定年
                string today = DateTime.Today.ToString("yyyy");
                for (int i = 0; i < 10; i++)
                {
                    if (today.Substring(3, 1).Equals(code[0]))
                    {
                        outputTime = today;
                    }
                    else
                    {
                        today = (Convert.ToInt16(today) - 1).ToString();
                    }
                }
                //确定月份和日
                DateTime          dtTemp = Convert.ToDateTime(outputTime + "-01-01");
                GregorianCalendar gc     = new GregorianCalendar();
                for (int i = 0; i < 365; i++)
                {
                    int weekOfYear = gc.GetWeekOfYear(dtTemp, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
                    int dayOfWeek  = (int)dtTemp.DayOfWeek + 1;
                    if (weekOfYear == Convert.ToInt16(code[1]) && dayOfWeek == Convert.ToInt16(code[2]))
                    {
                        outputTime = dtTemp.ToString("yyyy-MM-dd");
                        break;
                    }
                    else
                    {
                        dtTemp = dtTemp.AddDays(1);
                    }
                }
                #endregion
                return(outputTime);
            }

            #endregion

            switch (m_Mode)
            {
            case PACK_MODE.Pack:
                labelFrist.Print(setting, parametersFrist);

                dlg = new PrintDialog();
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                setting = dlg.PrinterSettings;
                labelSecond.Print(setting, parametersSecond);
                break;

            case PACK_MODE.Carton:
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);

                dlg = new PrintDialog();
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                setting = dlg.PrinterSettings;
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                break;

            case PACK_MODE.Pallet:
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);

                dlg = new PrintDialog();
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                setting = dlg.PrinterSettings;
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);

                #region 富士康卡板A4纸张
                //设置新纸张大小
                dlg = new PrintDialog();
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                setting = dlg.PrinterSettings;

                Print2 print2 = new Print2(txtCode.Text, parametersSecond[7], parametersSecond[5], parametersSecond[14]);

                DataTable dt = new DataTable();
                dt.Columns.Add("No.");
                dt.Columns.Add("箱号");
                dt.Columns.Add("料号");
                dt.Columns.Add("数量");
                int i = 0;
                //每行写上被包括的子标签数量等
                TPCResult <List <List <string> > > items = null;
                bool queryInfo(string ID)
                {
                    items = null;
                    //m_Mode = PACK_MODE.Pack;
                    items = Database.GetFXZZ_Data(ID);
                    if (items.State == RESULT_STATE.NG)
                    {
                        MessageBox.Show(items.Message);
                        return(false);
                    }
                    return(true);
                }

                foreach (ListViewItem var in lstItems.Items)
                {
                    string id = var.SubItems[1].Text;
                    if (!queryInfo(id))
                    {
                        return;
                    }
                    if (items.Value.Count == 0)
                    {
                        continue;
                    }
                    DataRow dr = dt.NewRow();
                    dr["No."] = (++i).ToString();
                    dr["箱号"]  = id;
                    dr["料号"]  = LabelPrintGlobal.g_Config.APN;
                    dr["数量"]  = items.Value[0][0].ToString();
                    dt.Rows.Add(dr);
                }



                print2.ImportDataTable(dt);

                if (print2.BtnPrint_Click(setting))
                {
                    print2.Dispose();
                    return;
                }
                print2.Dispose();
                #endregion
                break;
            }

            //这里需要写入pnt_mng表
            TPCResult <bool> ret = Database.SetManagerData(m_Mode, data.PCode, Program.LoginUser,
                                                           Convert.ToInt32(data.Total), PACK_ACTION.Register,
                                                           PACK_STATUS.Completed);
            if (ret.State == RESULT_STATE.NG)
            {
                MessageBox.Show(ret.Message);
                return;
            }
        }
Esempio n. 2
0
        private void reprint3()
        {
            if (lstItems.Items.Count < Convert.ToInt32(txtTotal.Text))
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NOT_FULL_QUANTITY_ERROR"), "ERROR", MessageBoxButtons.OK);
                return;
            }

            PrintDialog dlg = new PrintDialog();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            PrinterSettings setting = dlg.PrinterSettings;

            PrintLabelData data = new PrintLabelData();

            data.PCode    = txtCode.Text;
            data.DataCode = GetCodeDate();
            data.Total    = Convert.ToInt32(txtTotal.Text);
            data.Date     = GetDate();
            TPCResult <int> result = Database.GetModuleCount(m_Mode, txtCode.Text);

            if (result.State == RESULT_STATE.NG)
            {
                MessageBox.Show(result.Message);
                return;
            }

            data.Quantity = result.Value;

            string label_nameFrist  = "";
            string label_nameSecond = "";

            switch (m_Mode)
            {
            case PACK_MODE.Pack:
                label_nameFrist  = "pack_fxzz";
                label_nameSecond = "pack_wks";
                break;

            case PACK_MODE.Carton:
                label_nameFrist  = "carton_fxzz";
                label_nameSecond = "carton_wks";
                break;

            case PACK_MODE.Pallet:
                label_nameFrist  = "pallet_fxzz";
                label_nameSecond = "pallet_wks";
                break;
            }
            //打印第一页信息
            TPCPrintLabel labelFrist      = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameFrist);
            List <string> parametersFrist = MakePrintParameters(m_Mode, data);

            //打印第二页信息
            TPCPrintLabel labelSecond      = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameSecond);
            List <string> parametersSecond = MakePrintParameters(m_Mode, data);

            switch (m_Mode)
            {
            case PACK_MODE.Pack:
                labelFrist.Print(setting, parametersFrist);
                labelSecond.Print(setting, parametersSecond);
                break;

            case PACK_MODE.Carton:
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                break;

            case PACK_MODE.Pallet:
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelFrist.Print(setting, parametersFrist);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                labelSecond.Print(setting, parametersSecond);
                break;
            }


            //这里需要写入pnt_mng表
            TPCResult <bool> ret = Database.SetManagerData(m_Mode, data.PCode, Program.LoginUser,
                                                           Convert.ToInt32(data.Total), PACK_ACTION.Register,
                                                           PACK_STATUS.Completed);

            if (ret.State == RESULT_STATE.NG)
            {
                MessageBox.Show(ret.Message);
                return;
            }
        }
Esempio n. 3
0
        protected List <string> MakePrintParameters(PACK_MODE mode, PrintLabelData data)
        {
            List <string> parameters = new List <string>();

            //pegatron P/N
            parameters.Add(LabelPrintGlobal.g_Config.Pegatoron_PN);
            //APN
            parameters.Add(LabelPrintGlobal.g_Config.APN);
            //REV
            parameters.Add(LabelPrintGlobal.g_Config.REV);
            //Config
            parameters.Add(LabelPrintGlobal.g_Config.Config);
            //DESC
            parameters.Add(LabelPrintGlobal.g_Config.DESC);
            //date
            parameters.Add(data.DataCode);
            //L/C
            parameters.Add(LabelPrintGlobal.g_Config.lc);
            //Quantity
            parameters.Add(data.Quantity.ToString());
            //Batch
            parameters.Add(LabelPrintGlobal.g_Config.batch);
            //Pack No
            parameters.Add(data.PCode);
            //stage
            parameters.Add(LabelPrintGlobal.g_Config.Stage);
            //2D barcode
            string barcode = string.Format("{0},{1},{2},{3},{4},{5},{6}",
                                           data.PCode,                                      //pack No
                                           LabelPrintGlobal.g_Config.Pegatoron_PN,          //PEGA P/N
                                           LabelPrintGlobal.g_Config.APN,                   //APN
                                           LabelPrintGlobal.g_Config.batch,                 //Batch
                                           data.Quantity.ToString(),                        //Quantity
                                           data.DataCode,                                   //Date
                                           LabelPrintGlobal.g_Config.lc);                   //L/C
            //Packの場合、特別処理(Erase Pack id at QR code)、2017/11/14(呉)
            int idx_first   = barcode.IndexOf(",");
            int len_barcode = barcode.Length;

            switch (mode)
            {
            case PACK_MODE.Pack:
                barcode = barcode.Substring(idx_first + 1, len_barcode - idx_first - 1);
                break;
            }
            parameters.Add(barcode);
            //修改日期20180518
            //13
            parameters.Add(LabelPrintGlobal.g_Config.Vendor_PN);
            //14
            parameters.Add(data.Date);
            KeyValuePair <string, string>[] lotCountArray = new KeyValuePair <string, string> [16];
            TPCResult <List <KeyValuePair <string, string> > > lotCountList = Database.GetLotCount(mode, data.PCode);
            int lotSum = 0;

            if (lotCountList.State == RESULT_STATE.NG)
            {
                for (int i = 0; i < 8; i++)
                {
                    parameters.Add("ERROR");
                }
            }
            else
            {
                Array.Copy(lotCountList.Value.ToArray(), lotCountArray, lotCountList.Value.ToArray().Length);
                for (int i = 0; i < lotCountArray.Length; i++)
                {
                    parameters.Add(lotCountArray[i].Key);
                    parameters.Add(lotCountArray[i].Value);
                    lotSum += Convert.ToInt32(lotCountArray[i].Value);
                }
            }
            //other  47, total 48
            if (lotSum == 0)
            {
                parameters.Add("ERROR");
                parameters.Add("ERROR");
            }
            else
            {
                TPCResult <int> lotTotal = Database.GetLotTotal(mode, data.PCode);
                if (lotTotal.State == RESULT_STATE.NG)
                {
                    parameters.Add("ERROR");
                    parameters.Add("ERROR");
                }
                else
                {
                    int other = lotTotal.Value - lotSum;
                    parameters.Add(other.ToString());
                    parameters.Add(lotTotal.Value.ToString());
                }
            }
            lotSum = 0;
            //49
            parameters.Add(LabelPrintGlobal.g_Config.Mfr);
            //end
            return(parameters);
        }