Ejemplo n.º 1
0
        private void ucButtonPrint_Click(object sender, EventArgs e)
        {
            try
            {
                string printNum = this.txtPrintNum.Value.Trim();

                if (printNum == "" || printNum == string.Empty)
                {
                    printNum = "0";
                }
                if (Convert.ToInt32(printNum) <= 0)
                {
                    this.ShowMessage(new UserControl.Message(MessageType.Error, "$CS_Error_PrintNumber_Must_Over_Zero"));
                    return;
                }

                if (this.ucLabelComboxPrinter.ComboBoxData.Items.Count == 0)
                {
                    this.ShowMessage(new UserControl.Message(MessageType.Error, "$CS_PleaseInstallPrinter"));
                    return;
                }

                SetPrintButtonStatus(false);

                CodeSoftPrintFacade codeSoftPrintFacade = new CodeSoftPrintFacade(this.DataProvider);

                string printer      = string.Empty;
                string templatePath = string.Empty;;  //print path

                printer = this.ucLabelComboxPrinter.SelectedItemText;


                List <string> materialLot = new List <string>();

                for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++)
                {
                    if (ultraGridMetrialDetial.Rows[i].Cells[0].Value.ToString().Trim().ToUpper() == "TRUE")
                    {
                        materialLot.Add(FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ultraGridMetrialDetial.Rows[i].Cells["MaterialLot"].Value.ToString())));
                    }
                }

                if (!CheckPrintCondition(printer, materialLot))
                {
                    return;
                }


                if (MessageBox.Show(UserControl.MutiLanguages.ParserMessage("$CS_YES_OR_NO_Print"), this.Text, MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    for (int j = 0; j < Convert.ToInt16(this.txtPrintNum.Value.Trim()); j++)
                    {
                        msg = codeSoftPrintFacade.PrintMaterialLot(printer, materialLot);
                    }

                    if (msg.IsSuccess())
                    {
                        this.ShowMessage(new UserControl.Message(MessageType.Success, "$Success_Print_Label"));
                    }
                }

                this.ShowMessage(msg);
            }
            catch (Exception ex)
            {
                this.ShowMessage(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                return;
            }
            finally
            {
                SetPrintButtonStatus(true);
            }
        }
Ejemplo n.º 2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                string printNum = this.edtPrint.Value.Trim();

                if (this.ucLabelComboxPrinter.ComboBoxData.Items.Count == 0)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_PleaseInstallPrinter"));
                    return;
                }

                if (printNum == string.Empty)
                {
                    this.edtPrint.TextFocus(false, true);
                    return;
                }

                if (Convert.ToInt32(printNum) <= 0)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Error_PrintNumber_Must_Over_Zero"));
                    return;
                }

                SetPrintButtonStatus(false);

                CodeSoftPrintFacade codeSoftPrintFacade = new CodeSoftPrintFacade(this.DataProvider);

                string printer = this.ucLabelComboxPrinter.SelectedItemValue.ToString();

                List <string> materialLotList = new List <string>();

                for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++)
                {
                    if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true")
                    {
                        materialLotList.Add(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString());
                    }
                }

                if (!CheckPrintCondition(printer, materialLotList))
                {
                    return;
                }

                if (MessageBox.Show(UserControl.MutiLanguages.ParserMessage("$CS_YES_OR_NO_Print"), this.Text, MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Messages msg = new Messages();
                    for (int j = 0; j < Convert.ToInt32(printNum); j++)
                    {
                        msg = codeSoftPrintFacade.PrintMaterialLot(printer, materialLotList);
                    }

                    if (msg.IsSuccess())
                    {
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$Success_Print_Label"));
                    }
                    else
                    {
                        ApplicationRun.GetInfoForm().Add(msg);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                return;
            }
            finally
            {
                SetPrintButtonStatus(true);
            }
        }