Exemple #1
0
        public Boolean PrintEnvelope(Boolean isTest)
        {
            Boolean _Printed = false;

            //CardPrinterPrinterSettings.PrinterName = "IS700C";
            //CardPrinter.PrinterSettings.PrinterName = "RISO RZ 9 Series";
            // CardPrinter.PrinterSettings.PrinterName = "RICOH HQ9000 RPCS";
            //CardPrinter.PrinterSettings.PrinterName = "RISO RN2550(ADVANCE)";
            //CardPrinter.PrinterSettings.PrinterName = "Send To OneNote 2007";
            if (this.Lines.Count > 0)
            {
                String PrinterName = Global.OpenPrintDialog();
                if (PrinterName != "")
                {
                    CardTemplate oCardTemplate = new CardTemplate();
                    Card         oCard         = new Card(this.CompanyID);
                    oCard.Find(this.ProductID);
                    if (!oCardTemplate.Find(oCard.EnvTemplateID))
                    {
                        MessageBox.Show("No template found for the envelope: " + oCard.EnvTemplateID.ToString());
                        return(false);
                    }

                    CardPrinter CardPrinter = new CardPrinter();

                    CardPrinter.PrinterSettings.PrinterName = PrinterName;

                    CardPrinter.Clear();
                    foreach (Line oLine in this.LinesEnvelope)
                    {
                        CardPrinter.Add(oLine.Text);
                    }


                    CardPrinter.Point = oCardTemplate.Point;

                    CardPrinter.PaperSize = oCardTemplate.PaperSize;
                    CardPrinter.Copies    = 24;
                    CardPrinter.UpperCase = false;

                    CardPrinter.Rotation = (short)oCardTemplate.Rotation;
                    CardPrinter.TestMode = false;

                    CardPrinter.Font = new Font(oCardTemplate.FontName, oCardTemplate.FontSize, oCardTemplate.Bold ? FontStyle.Bold : FontStyle.Regular);
                    //  CardPrinter.Settings();
                    CardPrinter.Print();
                    _Printed = true;
                }
            }
            return(_Printed);
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            //MessageBox.Show(e.KeyCode.ToString());


            #region txtProductID
            if (sender == txtProductID)
            {
                if (e.KeyCode == Keys.F2)
                {
                    if (oProduct.View())
                    {
                        this.Display();

                        return;
                    }
                    txtProductID.Clear();
                    txtProductID.Focus();
                    return;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtProductID.Text.Trim() == "")
                    {
                        txtProductID.Clear();
                        txtProductID.Focus();
                        return;
                    }

                    if (oProduct.Find(txtProductID.Text))
                    {
                        this.Display();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            #endregion
            #region txtTemplateID
            if (sender == txtTemplateID)
            {
                if (e.KeyCode == Keys.F2)
                {
                    if (oCardTemplate.View())
                    {
                        txtTemplateID.Text   = oCardTemplate.ID;
                        txtTDescription.Text = oCardTemplate.Description;
                        DisplayCard();

                        return;
                    }
                    //this.txtDescription.Text =
                    return;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtTemplateID.Text.Trim() == "")
                    {
                        txtTemplateID.Clear();
                        txtTemplateID.Focus();
                        return;
                    }

                    if (oCardTemplate.Find(Convert.ToInt32(txtTemplateID.Text)))
                    {
                        txtTemplateID.Text   = oCardTemplate.ID;
                        txtTDescription.Text = oCardTemplate.Description;
                        this.DisplayCard();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            #endregion
            #region txtEnvTemplateID
            if (sender == txtEnvTemplateID)
            {
                if (e.KeyCode == Keys.F2)
                {
                    if (oCardTemplate.View())
                    {
                        txtEnvTemplateID.Text = oCardTemplate.ID;
                        txtEDescription.Text  = oCardTemplate.Description;
                        DisplayCard();

                        return;
                    }
                    //this.txtDescription.Text =
                    return;
                }
                if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab")
                {
                    if (txtProductID.Text.Trim() == "")
                    {
                        txtEnvTemplateID.Clear();
                        txtEnvTemplateID.Focus();
                        return;
                    }

                    if (oCardTemplate.Find(Convert.ToInt32(txtEnvTemplateID.Text)))
                    {
                        txtEnvTemplateID.Text = oCardTemplate.ID;
                        txtEDescription.Text  = oCardTemplate.Description;
                        this.DisplayCard();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            #endregion

            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F3:

                break;

            case Keys.PageDown:
                Save();
                Clear();
                txtProductID.Clear();
                txtProductID.Focus();
                txtProductID.Enabled = true;
                return;

            case Keys.Delete:

                break;


                //case Keys.<some key>:
                // ......;
                // break;
            }
            #endregion
        }