private void Introduce_Load(object sender, EventArgs e)
        {
            Tcat.Text    = "";
            Tcom.Text    = "";
            TIt.Text     = "";
            TstoQ.Text   = "";
            TSprice.Text = "";
            date.Text    = "";
            CountLoad();
            logo();

            // Infor Update
            label8.Visible          = false;
            label9.Visible          = false;
            label10.Visible         = false;
            label11.Visible         = false;
            label12.Visible         = false;
            label13.Visible         = false;
            label14.Visible         = false;
            label333.Visible        = false;
            label334.Visible        = false;
            instituteBox.Visible    = false;
            emailBox.Visible        = false;
            addressBox.Visible      = false;
            webBox.Visible          = false;
            MobileNumberBox.Visible = false;
            nameBox.Visible         = false;
            welcomeBox.Visible      = false;
            upDateButton.Visible    = false;


            // Information
            IntroduceModel introduction = othersGateway.GetInformation();

            if (introduction != null)
            {
                instituteNameLabel.Text = introduction.InstituteName;
                line3.Text    = introduction.Address;
                line4.Text    = introduction.OwnerName;
                line5.Text    = "Cell :" + introduction.Mobile + ", Email:" + introduction.Email + " Web:" + introduction.WebSite;
                welLabel.Text = introduction.WelcomeNote;
            }
        }
        public void MakePdf()
        {
            string str1 = DateTime.Today.ToString("u");
            string str2 = str1.Replace(':', 's');
            string str3 = str2.Replace(',', 'd');
            //    string filname = DateTime.Today.ToString("");
            string        fileNamePrifix = customerNameBox.Text.Trim();
            string        final_fileName = fileNamePrifix + str3;
            string        dirctory       = Path.GetDirectoryName(@"C:\Users\Public\");
            DirectoryInfo df             = new DirectoryInfo(dirctory + @"\voucher\");

            if (df.Exists == false)
            {
                Directory.CreateDirectory(dirctory + @"\voucher\");
            }
            string filePath = df + final_fileName;


            Document  document = new Document(PageSize.A4, 75, 75, 75, 75);
            PdfWriter create   = PdfWriter.GetInstance(document, new FileStream(filePath + ".pdf", FileMode.Create));

            document.Open();

            // Font Entry
            BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font hedingfont = new iTextSharp.text.Font(bf, 30, iTextSharp.text.Font.BOLD, BaseColor.BLUE);
            iTextSharp.text.Font smfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            iTextSharp.text.Font thfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            iTextSharp.text.Font tdfont     = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            iTextSharp.text.Font signfont   = new iTextSharp.text.Font(bf, 11, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            signfont.SetColor(23, 45, 12);



            byte[] image = introduce.loadLogo();
            if (image != null)
            {
                Image logo = Image.GetInstance(image);
                logo.SetAbsolutePosition(40, 700);
                logo.ScaleAbsoluteWidth(70);
                logo.ScaleAbsoluteHeight(70);
                document.Add(logo);
            }



            // Customer Data
            Paragraph Header = new Paragraph();

            Header.Alignment = Element.ALIGN_CENTER;


            IntroduceModel introduction = introduce.GetInformation();

            if (introduction != null)
            {
                string instituteBox = introduction.InstituteName;
                string emailBox     = introduction.Email;
                string addresss     = introduction.Address;
                string web          = introduction.WebSite;
                string mobiles      = introduction.Mobile;
                string ownerName    = introduction.OwnerName;

                Header.Add(new Chunk(instituteBox, hedingfont));
                Header.Add(new Chunk("\n" + addresss, smfont));
                Header.Add(new Chunk("\nCell :" + mobiles + ", \n " + web + " , " + emailBox, smfont));
                document.Add(Header);
            }
            else
            {
                Header.Add(new Chunk("It is Your Institute Name", hedingfont));
                Header.Add(new Chunk("\nSomething Address text will visible here", smfont));
                Header.Add(new Chunk("\nCell : -9087948059830, \n Web: N/A, Email: N/A ", smfont));
                document.Add(Header);
            }

            DottedLineSeparator separator = new DottedLineSeparator();

            separator.LineWidth = 1f;
            Chunk linebreak = new Chunk(separator);

            document.Add(linebreak);


            string    customerName = customerNameBox.Text.Trim();
            string    address      = addressTextBox.Text.Trim();
            string    mobile       = mnumberBox.Text.Trim();
            Paragraph csdata       = new Paragraph();

            csdata.Alignment = Element.ALIGN_LEFT;
            csdata.Add(new Chunk("Customer Name : " + customerName + "\nAddress : " + address + "\nMabile Number : " + mobile + "\n Date : " + DateTime.Now.ToString("dd/MM/yyyy"), smfont));
            document.Add(csdata);
            DottedLineSeparator separator2 = new DottedLineSeparator();

            separator2.LineWidth = 1f;
            Chunk linebreak2 = new Chunk(separator2);

            document.Add(linebreak2);



            //Write the table
            float[]   columnWidths = { 1.5f, 7f, 2.2f, 4f };
            PdfPTable ItemsRecord  = new PdfPTable(columnWidths);

            ItemsRecord.DefaultCell.Column.Alignment = Element.ALIGN_CENTER;
            ItemsRecord.WidthPercentage           = 100;
            ItemsRecord.DefaultCell.PaddingBottom = 4f;
            ItemsRecord.AddCell(new Phrase("Sl", thfont));
            ItemsRecord.AddCell(new Phrase("Product  Description", thfont));
            ItemsRecord.AddCell(new Phrase("Quantity", thfont));
            ItemsRecord.AddCell(new Phrase("Net Price", thfont));
            //table Data
            var totalQuantity = listofStockOut.Sum(x => x.Quantity);
            var totalamount   = listofStockOut.Sum(x => x.Price).ToString(CultureInfo.CreateSpecificCulture("bn-BD"));
            int ci            = 0;
            int lc            = listofStockOut.Count;

            foreach (var items in listofStockOut)
            {
                if (ci <= lc)
                {
                    ci++;
                }
                ItemsRecord.AddCell(new Phrase(ci.ToString(), tdfont));
                ItemsRecord.AddCell(new Phrase(items.CatagoryName + " : " + items.ItemName + " Sl/Mo:" + items.Model, tdfont));
                ItemsRecord.AddCell(new Phrase(items.Quantity.ToString(), tdfont));
                ItemsRecord.AddCell(new Phrase(items.Price.ToString(), tdfont));
            }
            PdfPCell cell = new PdfPCell(new Phrase("Total :  ", tdfont));

            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            cell.Colspan             = 2;
            ItemsRecord.AddCell(cell);
            ItemsRecord.AddCell(new Phrase(totalQuantity.ToString(), tdfont));
            ItemsRecord.AddCell(new Phrase(totalamount, tdfont));
            document.Add(ItemsRecord);
            document.Add(new Chunk("\n\n\n"));



            //Author
            Paragraph prgAuthor = new Paragraph();

            prgAuthor.Alignment       = Element.ALIGN_CENTER;
            prgAuthor.IndentationLeft = 250f;
            prgAuthor.Add(new Chunk("Received by", signfont));
            prgAuthor.Add(new Chunk("\n" + DateTime.Now.ToString("dd/MM/yyyy"), signfont));
            document.Add(prgAuthor);
            document.Add(new Chunk("\n\n\n"));
            DottedLineSeparator separator4 = new DottedLineSeparator();

            separator4.LineWidth = 1f;
            Chunk linebreak4 = new Chunk(separator4);

            document.Add(linebreak4);

            document.Add(new Chunk("\nN:B: \n"));

            DottedLineSeparator separator5 = new DottedLineSeparator();

            separator5.LineWidth = 1f;
            Chunk linebreak5 = new Chunk(separator5);

            document.Add(linebreak5);

            document.Add(new Chunk("\n"));
            document.Close();
            create.Close();
            System.Diagnostics.Process.Start(filePath + ".pdf");
        }
Example #3
0
        private void getCodeButton_Click(object sender, EventArgs e)
        {
            if (!Email.IsMatch(emailTextBox.Text.Trim()))
            {
                cMessageBox.Information("Your Email is not Correct");
            }
            else
            {
                string ma    = emailTextBox.Text;
                string mas   = ma.Substring(0, 5);
                string scode = "SA-" + DateTime.Now.ToString("MM-dd") + "-";
                for (int i = 0; i <= mas.Length; i++)
                {
                    scode += scode + mas.Substring(0, 3) + i;
                }
                char[] charArray = scode.ToCharArray();
                Array.Reverse(charArray);
                string codes      = new string(charArray);
                string newCode    = codes.Substring(28, 62);
                bool   connection = NetworkInterface.GetIsNetworkAvailable();
                if (connection == true)
                {
                    try
                    {
                        string         doc           = "No Data is Set";
                        OthersGateway  othersGateway = new OthersGateway();
                        IntroduceModel introduction  = othersGateway.GetInformation();
                        if (introduction != null)
                        {
                            string ins   = introduction.InstituteName;
                            string email = introduction.Email;
                            string add   = introduction.Address;

                            string mob   = introduction.Mobile;
                            string owner = introduction.OwnerName;
                            doc = "Document for : " + ins + ", \nEmail:" + email + ",\n Address :" + add + ",\n Mobile :" + mob + ",\nOwner :" + owner;
                        }
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add("*****@*****.**");
                        mail.Subject           = "Activation For : " + emailTextBox.Text;
                        mail.Body              = doc + "\nCode: " + newCode;
                        SmtpServer.Port        = 587;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "@gmail.doeasily.coart");
                        SmtpServer.EnableSsl   = true;
                        int rowAffect = userGateway.InsertCode(newCode);
                        if (rowAffect > 0)
                        {
                            SmtpServer.Send(mail);
                            cMessageBox.Success("Your Code has been Generated, You will get an Email in short Time.");
                        }
                        else
                        {
                            cMessageBox.Failed("Faild, Try Again or Contact with Developer");
                        }
                    }
                    catch (Exception)
                    {
                        cMessageBox.Failed("Failed to Generate Code");
                    }
                }
                else
                {
                    cMessageBox.Warning("No Internet Connection");
                }
            }
        }