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

            //检查明细的状态,如果为1则已经打印,不能在这里打印了
            if (lstItems.Tag != null)
            {
                List <CItem> items = lstItems.Tag as List <CItem>;
                if (items != null)
                {
                    foreach (CItem item in items)
                    {
                        if (item.Status == 1)
                        {
                            MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("REPACK_NOT_PRINT"), "ERROR", MessageBoxButtons.OK);
                            return;
                        }
                    }
                }
            }
            //修改日期20180521
            //打印标签FXZZ
            m_Model.PrintLabel3();
            //标签打印结束,清空明细列表
            lstItems.Items.Clear();
            //清空父ID信息
            txtPNo.Text = "";

            txtCNo.ReadOnly = true;
        }
Esempio n. 2
0
        //如果没有选择任何拆包的明细,则不允许确定
        protected bool CheckUnpack()
        {
            List <CItem> items = lstUnpackItems.Tag as List <CItem>;

            if (items != null)
            {
                bool has_cancel = false;
                foreach (CItem item in items)
                {
                    if (item.Status == 2)
                    {
                        has_cancel = true;
                        break;
                    }
                }
                if (!has_cancel)
                {
                    MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("UNPACK_NO_ITEM_ERROR"));
                }
                return(has_cancel);
            }
            else
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NO_ITEM_UNPACK_ERROR"));
                return(false);
            }
        }
Esempio n. 3
0
        private void btOK_Click(object sender, EventArgs e)
        {
            //如果没有选择任何拆包的明细,则不允许确定
            if (!CheckUnpack())
            {
                return;
            }

            if (IsDeepCancel())
            {
                if (MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("DEEP_CANCELED_WARNNING"), "Warnning", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            List <CItem> items = lstUnpackItems.Tag as List <CItem>;

            if (items != null)
            {
                string name = items[0].Name;
                string mode = GetModeFromTableName(name);
                if (IsDeepCancel())
                {
                    TPCResult <bool> result = null;
                    //深度拆包
                    if (is_all_cancel)
                    {
                        result = Database.UnpackItemByDeep(mode, txtUnpackCode.Text, Program.LoginUser);
                    }
                    else
                    {
                        result = Database.UnpackItemByDeep(items, Program.LoginUser);
                    }
                    if (result.State == RESULT_STATE.NG)
                    {
                        MessageBox.Show(result.Message);
                        return;
                    }
                }
                else
                {
                    //单层拆包
                    TPCResult <bool> result = Database.UnpackItemsBySingle(items, Program.LoginUser);
                    if (result.State == RESULT_STATE.NG)
                    {
                        MessageBox.Show(result.Message);
                        return;
                    }
                }
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("COMPLETED_UNPACK_INFO"));
                Close();
            }
            else
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NO_ITEM_UNPACK_ERROR"));
            }
        }
Esempio n. 4
0
 protected bool CanPacking()
 {
     //如果前面还有装箱,则先检测是否打印过标签
     if (lstItems.Items.Count > 0 || txtPNo.Text.Length > 0)
     {
         MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("APPLY_ID_ERROR"), "ERROR", MessageBoxButtons.OK);
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
 protected override void OnClosing(CancelEventArgs e)
 {
     //检查是否有未完成工作,即工作对象条码是否存在
     if (m_PackingForm.PNoEdit.Text.Length > 0)
     {
         if (MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("UNCOMPLETED_CLOSE_WARN"), "WARNNING", MessageBoxButtons.YesNo) != DialogResult.Yes)
         {
             e.Cancel = true;
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 子编号编辑框,收到扫描条码事件
        /// 增加子项到列表中,并保存到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtCNo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                #region 20190522增加针对KK04输入箱号的bin检查
                string code0 = txtCNo.Text;
                if (LabelPrintGlobal.g_Config.Switch.Equals("ON"))//配置文件开关时"ON"时启用
                {
                    //string mode = code0.Substring(13, 1);
                    //if (mode == "P")
                    //{
                    TPCResult <DataTable> checkBin = m_Model.CheckBin(code0);
                    if (checkBin.State == RESULT_STATE.NG)
                    {
                        MessageBox.Show(checkBin.Message);
                        return;
                    }
                    string bin = LabelPrintGlobal.g_Config.Bin;   //配置文件bin的对比
                    //检查bin是否ok
                    if (checkBin.Value.Rows.Count != 1 || checkBin.Value.Rows[0][0].ToString() != bin)
                    {
                        MessageBox.Show("该箱存在马达Bin不匹配", "马达Bin检查:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //MessageBox.Show(checkBin.Value.Rows[0][0].ToString());
                }
                #endregion


                string code = CNoEdit.Text;
                //这里增加限制,如果父项条码没有预约,则不允许扫描
                if (txtPNo.Text.Length == 0)
                {
                    MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NO_PARENT_SCAN_ERROR"), "WARNNING", MessageBoxButtons.OK);
                    return;
                }

                //回车键,这里默认条码扫描后自带回车键
                TPCResult <bool> result = m_Model.ScanCCode(code);
                if (result.State == RESULT_STATE.NG)
                {
                    MessageBox.Show(result.Message);
                    return;
                }
                CNoEdit.Text = "";

                //只有至少一个子项输入才能再次预约
                btApply.Enabled = true;

                //开始扫描子项后,不允许修改总数
                //txtTotal.Enabled = false;
            }
        }
Esempio n. 7
0
        protected override void OnLoad(EventArgs e)
        {
            //初始化标签打印模块
            string config = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\label.xml";

            if (!LabelPrintGlobal.g_LabelCreator.LoadConfig(config))
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("LABEL_PRINT_INIT_ERROR"), "ERROR", MessageBoxButtons.OK);
                Close();
                return;
            }

            //基础配置文件
            LabelPrintGlobal.g_ConfigFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\config.xml";
            TPCResult <bool> rt = LabelPrintGlobal.g_Config.LoadConfig(LabelPrintGlobal.g_ConfigFile);

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

            ///初始化三种模式
            #region 初始化三种模式
            m_Pack   = new PackModel(m_PackingForm);
            m_Carton = new CartonModel(m_PackingForm);
            m_Pallet = new PalletModel(m_PackingForm);

            m_Pack.Database   = m_DatabseHelper;
            m_Carton.Database = m_DatabseHelper;
            m_Pallet.Database = m_DatabseHelper;

            m_Pack.CodeKey   = "BM004HK1-1";
            m_Carton.CodeKey = "BM004HK1-1";
            m_Pallet.CodeKey = "BM004HK1-1";
            #endregion

            m_PackingForm.Model = m_Pack;

            m_PackingForm.Show();
            InitLanguage();
            InitAuth();

            ShowMode(PACK_MODE.Pack);
        }
Esempio n. 8
0
        /// <summary>
        /// 重装
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rdRepacking_Click(object sender, EventArgs e)
        {
            //如果前面还有装箱,则先检测是否打印过标签
            if (lstItems.Items.Count > 0 || txtPNo.Text.Length > 0)
            {
                if (MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("REPACK_ERROR"), "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    rdPacking.Checked = true;
                    return;
                }
            }

            m_Model.RepackingOn();

            //只有在父No有值时,才能扫描子No
            txtCNo.ReadOnly = true;
        }
Esempio n. 9
0
        /// <summary>
        /// 可以编辑装包总数,当编辑结束,焦点移开时
        /// 校验数值是否正确
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtTotal_Leave(object sender, EventArgs e)
        {
            int  total    = 0;
            bool is_error = false;

            if (!int.TryParse(txtTotal.Text, out total))
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("TOTAL_NUMBER_ERROR"), "ERROR", MessageBoxButtons.OK);
                is_error = true;
            }

            if (total < lstItems.Items.Count)
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("TOTAL_NUMBER_LESS_THEN_DETAIL"), "ERROR", MessageBoxButtons.OK);
                is_error = true;
            }

            if (is_error)
            {
                switch (m_Model.Mode)
                {
                case PACK_MODE.Pack:
                    txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.PackTrays);
                    break;

                case PACK_MODE.Carton:
                    txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.CartonPack);
                    break;

                case PACK_MODE.Pallet:
                    txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.PalletCarton);
                    break;
                }
            }

            //设定打印按钮有效状态
            btPrintLabel.Enabled = (total == lstItems.Items.Count);
            //设定打印按钮的有效状态 修正时间20180517
            btPrintLabelNew.Enabled = (total == lstItems.Items.Count);
            //end
        }
Esempio n. 10
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. 11
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;
            }
        }