Exemplo n.º 1
0
 public void BarcodeSettingsAdd(BarcodeSettingsInfo barcodesettingsinfo)
 {
     try
     {
         if (base.sqlcon.State == ConnectionState.Closed)
         {
             base.sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BarcodeSettingsAddorEdit", base.sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam19 = new SqlParameter();
         sprmparam19       = sccmd.Parameters.Add("@showProductCode", SqlDbType.Bit);
         sprmparam19.Value = barcodesettingsinfo.ShowProductCode;
         sprmparam19       = sccmd.Parameters.Add("@showCompanyName", SqlDbType.Bit);
         sprmparam19.Value = barcodesettingsinfo.ShowCompanyName;
         sprmparam19       = sccmd.Parameters.Add("@companyName", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.CompanyName;
         sprmparam19       = sccmd.Parameters.Add("@showPurchaseRate", SqlDbType.Bit);
         sprmparam19.Value = barcodesettingsinfo.ShowPurchaseRate;
         sprmparam19       = sccmd.Parameters.Add("@showMRP", SqlDbType.Bit);
         sprmparam19.Value = barcodesettingsinfo.ShowMRP;
         sprmparam19       = sccmd.Parameters.Add("@point", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Point;
         sprmparam19       = sccmd.Parameters.Add("@zero", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Zero;
         sprmparam19       = sccmd.Parameters.Add("@one", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.One;
         sprmparam19       = sccmd.Parameters.Add("@two", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Two;
         sprmparam19       = sccmd.Parameters.Add("@three", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Three;
         sprmparam19       = sccmd.Parameters.Add("@four", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Four;
         sprmparam19       = sccmd.Parameters.Add("@five", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Five;
         sprmparam19       = sccmd.Parameters.Add("@six", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Six;
         sprmparam19       = sccmd.Parameters.Add("@seven", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Seven;
         sprmparam19       = sccmd.Parameters.Add("@eight", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Eight;
         sprmparam19       = sccmd.Parameters.Add("@nine", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Nine;
         sprmparam19       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Extra1;
         sprmparam19       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam19.Value = barcodesettingsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         base.sqlcon.Close();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Save Or Edit Function
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         bool isOk = true;
         if (cbxShowCompanyNAmeAs.Checked && txtShowCompanyName.Text.Trim() == string.Empty)
         {
             MessageBox.Show("Enter company code", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtShowCompanyName.Focus();
             isOk = false;
         }
         else if ((cbxShowPurchaseRate.Checked && CheckGroupBox()) || (!cbxShowPurchaseRate.Checked))
         {
             if (PublicVariables.isMessageAdd)
             {
                 if (Messages.SaveMessage())
                 {
                     isOk = true;
                 }
                 else
                 {
                     isOk = false;
                 }
             }
             if (isOk)
             {
                 BarcodeSettingsInfo InfoSettings = new BarcodeSettingsInfo();
                 InfoSettings.ShowMRP          = cbxShowMrp.Checked;
                 InfoSettings.ShowProductCode  = rbtnShowProductCode.Checked;
                 InfoSettings.ShowCompanyName  = cbxShowCompanyNAmeAs.Checked;
                 InfoSettings.ShowPurchaseRate = cbxShowPurchaseRate.Checked;
                 InfoSettings.CompanyName      = txtShowCompanyName.Text.Trim();
                 InfoSettings.Zero             = txtZero.Text.Trim();
                 InfoSettings.One    = txtOne.Text.Trim();
                 InfoSettings.Two    = txtTwo.Text.Trim();
                 InfoSettings.Three  = txtThree.Text.Trim();
                 InfoSettings.Four   = txtFour.Text.Trim();
                 InfoSettings.Five   = txtFive.Text.Trim();
                 InfoSettings.Six    = txtSix.Text.Trim();
                 InfoSettings.Seven  = txtSeven.Text.Trim();
                 InfoSettings.Eight  = txtEight.Text.Trim();
                 InfoSettings.Nine   = txtNine.Text.Trim();
                 InfoSettings.Point  = txtPoint.Text.Trim();
                 InfoSettings.Extra1 = string.Empty;
                 InfoSettings.Extra2 = string.Empty;
                 BarcodeSettingsSP spbarcodesetting = new BarcodeSettingsSP();
                 spbarcodesetting.BarcodeSettingsAdd(InfoSettings);
                 Messages.SavedMessage();
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BS5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 public void BarcodeSettingsAdd(BarcodeSettingsInfo barcodesettingsinfo)
 {
     try
     {
         SpBarcodeSettings.BarcodeSettingsAdd(barcodesettingsinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("BCP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 4
0
        public BarcodeSettingsInfo BarcodeSettingsView(decimal barcodeSettingsId)
        {
            BarcodeSettingsInfo barcodesettingsinfo = new BarcodeSettingsInfo();
            SqlDataReader       sdrreader           = null;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("BarcodeSettingsView", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam2 = new SqlParameter();
                sprmparam2       = sccmd.Parameters.Add("@barcodeSettingsId", SqlDbType.Decimal);
                sprmparam2.Value = barcodeSettingsId;
                sdrreader        = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    barcodesettingsinfo.BarcodeSettingsId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString());
                    barcodesettingsinfo.ShowProductCode   = bool.Parse(((DbDataReader)sdrreader)[1].ToString());
                    barcodesettingsinfo.ShowCompanyName   = bool.Parse(((DbDataReader)sdrreader)[2].ToString());
                    barcodesettingsinfo.CompanyName       = ((DbDataReader)sdrreader)[3].ToString();
                    barcodesettingsinfo.ShowPurchaseRate  = bool.Parse(((DbDataReader)sdrreader)[4].ToString());
                    barcodesettingsinfo.ShowMRP           = bool.Parse(((DbDataReader)sdrreader)[5].ToString());
                    barcodesettingsinfo.Point             = ((DbDataReader)sdrreader)[6].ToString();
                    barcodesettingsinfo.Zero      = ((DbDataReader)sdrreader)[7].ToString();
                    barcodesettingsinfo.One       = ((DbDataReader)sdrreader)[8].ToString();
                    barcodesettingsinfo.Two       = ((DbDataReader)sdrreader)[9].ToString();
                    barcodesettingsinfo.Three     = ((DbDataReader)sdrreader)[10].ToString();
                    barcodesettingsinfo.Four      = ((DbDataReader)sdrreader)[11].ToString();
                    barcodesettingsinfo.Five      = ((DbDataReader)sdrreader)[12].ToString();
                    barcodesettingsinfo.Six       = ((DbDataReader)sdrreader)[13].ToString();
                    barcodesettingsinfo.Seven     = ((DbDataReader)sdrreader)[14].ToString();
                    barcodesettingsinfo.Eight     = ((DbDataReader)sdrreader)[15].ToString();
                    barcodesettingsinfo.Nine      = ((DbDataReader)sdrreader)[16].ToString();
                    barcodesettingsinfo.Extra1    = ((DbDataReader)sdrreader)[17].ToString();
                    barcodesettingsinfo.Extra2    = ((DbDataReader)sdrreader)[18].ToString();
                    barcodesettingsinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)[19].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                base.sqlcon.Close();
            }
            return(barcodesettingsinfo);
        }
        public BarcodeSettingsInfo BarcodeSettingsView(decimal barcodeSettingsId)
        {
            BarcodeSettingsInfo barcodesettingsinfo = new BarcodeSettingsInfo();

            try
            {
                barcodesettingsinfo = SpBarcodeSettings.BarcodeSettingsView(barcodeSettingsId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("BCP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(barcodesettingsinfo);
        }
        /// <summary>
        /// Function to view all values for Barcode Printing
        /// </summary>
        /// <returns></returns>
        public BarcodeSettingsInfo BarcodeSettingsViewForBarCodePrinting()
        {
            BarcodeSettingsInfo barcodesettingsinfo = new BarcodeSettingsInfo();
            SqlDataReader       sdrreader           = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("BarcodeSettingsViewForBarcodePrinting", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                sdrreader         = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    barcodesettingsinfo.BarcodeSettingsId = decimal.Parse(sdrreader[0].ToString());
                    barcodesettingsinfo.ShowProductCode   = bool.Parse(sdrreader[2].ToString());
                    barcodesettingsinfo.ShowCompanyName   = bool.Parse(sdrreader[1].ToString());
                    barcodesettingsinfo.CompanyName       = sdrreader[3].ToString();
                    barcodesettingsinfo.ShowPurchaseRate  = bool.Parse(sdrreader[4].ToString());
                    barcodesettingsinfo.ShowMRP           = bool.Parse(sdrreader[5].ToString());
                    barcodesettingsinfo.Point             = sdrreader[6].ToString();
                    barcodesettingsinfo.Zero   = sdrreader[7].ToString();
                    barcodesettingsinfo.One    = sdrreader[8].ToString();
                    barcodesettingsinfo.Two    = sdrreader[9].ToString();
                    barcodesettingsinfo.Three  = sdrreader[10].ToString();
                    barcodesettingsinfo.Four   = sdrreader[11].ToString();
                    barcodesettingsinfo.Five   = sdrreader[12].ToString();
                    barcodesettingsinfo.Six    = sdrreader[13].ToString();
                    barcodesettingsinfo.Seven  = sdrreader[14].ToString();
                    barcodesettingsinfo.Eight  = sdrreader[15].ToString();
                    barcodesettingsinfo.Nine   = sdrreader[16].ToString();
                    barcodesettingsinfo.Extra1 = sdrreader[17].ToString();
                    barcodesettingsinfo.Extra2 = sdrreader[18].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(barcodesettingsinfo);
        }
        /// <summary>
        /// ExportToThermalPrinter
        /// </summary>
        public void ExportToPDFforThermalPrinter()
        {
            iTextSharp.text.Document pdfdoc = new iTextSharp.text.Document();
            try
            {
                DirectoryInfo dir1 = new DirectoryInfo(Application.StartupPath + "\\Barcode");
                if (!Directory.Exists(Application.StartupPath + "\\Barcode"))
                {
                    dir1.Create();
                }
                if (File.Exists(Application.StartupPath + "\\Barcode\\Barcode.pdf"))
                {
                    File.Delete(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
                iTextSharp.text.Rectangle pgSize = new iTextSharp.text.Rectangle(227, 65);
                pdfdoc = new Document(pgSize, 6, 6, 0, 0);
                PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream(Application.StartupPath + "\\Barcode\\Barcode.pdf", FileMode.Create));
                PdfPTable tbl = new PdfPTable(2);
                float[] fltParentWidth = new float[] { 108f, 108f };
                tbl.TotalWidth = 216;
                tbl.LockedWidth = true;
                tbl.SetWidths(fltParentWidth);
                tbl.DefaultCell.FixedHeight = 57;
                tbl.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                tbl.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                tbl.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
                pdfdoc.Open();
                int intotalCount = 0;
                BarcodeSettingsInfo Info = new BarcodeSettingsInfo();
                SettingsBll BllSettings = new SettingsBll();
                Info = BllBarcodeSettings.BarcodeSettingsViewForBarCodePrinting();
                for (int i = 0; i < dgvBarcodePrinting.Rows.Count; i++)
                {
                    if (dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value != null && dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString() != string.Empty)
                    {
                        int inCopies = 0;
                        if (dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value != null)
                        {
                            int.TryParse(dgvBarcodePrinting.Rows[i].Cells["dgvCopies"].Value.ToString(), out inCopies);
                        }
                        for (int j = 0; j < inCopies; j++)
                        {
                            string strCode = dgvBarcodePrinting.Rows[i].Cells["dgvProductCode"].Value.ToString();
                            string strCompanyName = string.Empty;
                            if (Info.ShowCompanyName)
                                strCompanyName = Info.CompanyName;
                            string strProductCode = string.Empty;
                            if (Info.ShowProductCode)
                                strProductCode = strCode;
                            else
                                strProductCode = dgvBarcodePrinting.Rows[i].Cells["dgvproductName"].Value.ToString();

                            string strMRP = string.Empty;
                            if (Info.ShowMRP)
                            {
                                strMRP = new CurrencyBll().CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol + ": " + dgvBarcodePrinting.Rows[i].Cells["dgvMRP"].Value.ToString();
                            }

                            string strSecretPurchaseRateCode = string.Empty;
                            if (Info.ShowPurchaseRate)
                            {
                                string strPurchaseRate = dgvBarcodePrinting.Rows[i].Cells["dgvPurchaseRate"].Value.ToString();

                                if (strPurchaseRate.Contains("."))
                                {
                                    strPurchaseRate = strPurchaseRate.TrimEnd('0');
                                    if (strPurchaseRate[strPurchaseRate.Length - 1] == '.')
                                        strPurchaseRate = strPurchaseRate.Replace(".", "");
                                }
                                for (int k = 0; k < strPurchaseRate.Length; k++)
                                {
                                    switch (strPurchaseRate[k])
                                    {
                                        case '0':
                                            strSecretPurchaseRateCode += Info.Zero;
                                            break;
                                        case '1':
                                            strSecretPurchaseRateCode += Info.One;
                                            break;
                                        case '2':
                                            strSecretPurchaseRateCode += Info.Two;
                                            break;
                                        case '3':
                                            strSecretPurchaseRateCode += Info.Three;
                                            break;
                                        case '4':
                                            strSecretPurchaseRateCode += Info.Four;
                                            break;
                                        case '5':
                                            strSecretPurchaseRateCode += Info.Five;
                                            break;
                                        case '6':
                                            strSecretPurchaseRateCode += Info.Six;
                                            break;
                                        case '7':
                                            strSecretPurchaseRateCode += Info.Seven;
                                            break;
                                        case '8':
                                            strSecretPurchaseRateCode += Info.Eight;
                                            break;
                                        case '9':
                                            strSecretPurchaseRateCode += Info.Nine;
                                            break;
                                        case '.':
                                            strSecretPurchaseRateCode += Info.Point;
                                            break;
                                    }
                                }
                            }

                            PdfContentByte pdfcb = writer.DirectContent;
                            Barcode128 code128 = new Barcode128();
                            code128.Code = strCode;
                            code128.Extended = false;
                            code128.CodeType = iTextSharp.text.pdf.Barcode.CODE128;
                            code128.AltText = strProductCode;
                            code128.BarHeight = 16;
                            code128.Size = 9;
                            code128.Baseline = 9;
                            code128.TextAlignment = Element.ALIGN_CENTER;
                            iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(pdfcb, null, null);
                            Phrase phrase = new Phrase();

                            phrase.Add(new Chunk(strCompanyName, new iTextSharp.text.Font(-1, 9, iTextSharp.text.Font.BOLD)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(-1, 4)));
                            PdfPCell cell = new PdfPCell(phrase);
                            cell.HorizontalAlignment = Element.ALIGN_CENTER;
                            cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            phrase.Add(new Chunk(image128, 0, 0));
                            phrase.Add(new Chunk(Environment.NewLine, new iTextSharp.text.Font(-1, 4)));
                            phrase.Add(new Chunk(strMRP, new iTextSharp.text.Font(-1, 8)));
                            phrase.Add(new Chunk(Environment.NewLine + strSecretPurchaseRateCode, new iTextSharp.text.Font(-1, 7)));
                            phrase.Add(new Chunk(Environment.NewLine + Environment.NewLine, new iTextSharp.text.Font(-1, 1.2f)));
                            tbl.AddCell(cell);
                            intotalCount++;
                        }
                    }
                }
                int reminder = intotalCount % 2;
                if (reminder != 0)
                {
                    for (int i = reminder; i < 2; ++i)
                    {
                        tbl.AddCell("");
                    }
                }
                if (tbl.Rows.Count != 0)
                {
                    pdfdoc.Add(tbl);
                    pdfdoc.Close();
                    System.Diagnostics.Process.Start(Application.StartupPath + "\\Barcode\\Barcode.pdf");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("The process cannot access the file") && ex.Message.Contains("Barcode.pdf' because it is being used by another process."))
                {
                    MessageBox.Show("Close the PDF file and try again", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("BCP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                try
                {
                    pdfdoc.Close();
                }
                catch
                {
                }
            }
        }
 /// <summary>
 /// Save Or Edit Function
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         bool isOk = true;
         if (cbxShowCompanyNAmeAs.Checked && txtShowCompanyName.Text.Trim() == string.Empty)
         {
             MessageBox.Show("Enter company code", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtShowCompanyName.Focus();
             isOk = false;
         }
         else if ((cbxShowPurchaseRate.Checked && CheckGroupBox()) || (!cbxShowPurchaseRate.Checked))
         {
             if (PublicVariables.isMessageAdd)
             {
                 if (Messages.SaveMessage())
                 {
                     isOk = true;
                 }
                 else
                 {
                     isOk = false;
                 }
             }
             if (isOk)
             {
                 BarcodeSettingsInfo InfoSettings = new BarcodeSettingsInfo();
                 InfoSettings.ShowMRP = cbxShowMrp.Checked;
                 InfoSettings.ShowProductCode = rbtnShowProductCode.Checked;
                 InfoSettings.ShowCompanyName = cbxShowCompanyNAmeAs.Checked;
                 InfoSettings.ShowPurchaseRate = cbxShowPurchaseRate.Checked;
                 InfoSettings.CompanyName = txtShowCompanyName.Text.Trim();
                 InfoSettings.Zero = txtZero.Text.Trim();
                 InfoSettings.One = txtOne.Text.Trim();
                 InfoSettings.Two = txtTwo.Text.Trim();
                 InfoSettings.Three = txtThree.Text.Trim();
                 InfoSettings.Four = txtFour.Text.Trim();
                 InfoSettings.Five = txtFive.Text.Trim();
                 InfoSettings.Six = txtSix.Text.Trim();
                 InfoSettings.Seven = txtSeven.Text.Trim();
                 InfoSettings.Eight = txtEight.Text.Trim();
                 InfoSettings.Nine = txtNine.Text.Trim();
                 InfoSettings.Point = txtPoint.Text.Trim();
                 InfoSettings.Extra1 = string.Empty;
                 InfoSettings.Extra2 = string.Empty;
                 BarcodeSettingsBll Bllbarcodesetting = new BarcodeSettingsBll();
                 Bllbarcodesetting.BarcodeSettingsAdd(InfoSettings);
                 Messages.SavedMessage();
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BS5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }