Exemplo n.º 1
0
 public CreateACustomer()
 {
     CustDB = new CustomerDB();
 }
Exemplo n.º 2
0
 private void initVariables()
 {
     CustomerDB.fillLedgerTypeComboNew(cmbCustomer, "Customer");
     pnlUI.Controls.Add(pnlList);
     setButtonVisibility("init");
 }
Exemplo n.º 3
0
 public static Customer GetCustomer(string CustomerID)
 {
     return(CustomerDB.Get(CustomerID));
 }
Exemplo n.º 4
0
 public static bool UpdateCustomer(Customer data)
 {
     return(CustomerDB.Update(data));
 }
Exemplo n.º 5
0
 public static Customer GetCustomer(string customerId)
 {
     return(CustomerDB.Get(customerId));
 }
Exemplo n.º 6
0
 // just before form closes, save data
 private void frmProducts_FormClosing(object sender, FormClosingEventArgs e)
 {
     CustomerDB.SaveCustomers(customers);
 }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchValue"></param>
 /// <returns></returns>
 public static int Customer_Count(string searchValue)
 {
     return(CustomerDB.Count(searchValue));
 }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (Session["user"] != null)
     {
         //calling member class to the session of user
         Customer c = (Customer)Session["user"];
         c.Name          = tbxName.Text;
         c.Gender        = tbxGender.Text;
         c.DateOfBirth   = Convert.ToDateTime(tbxDOB.Text);
         c.Address       = tbxAddress.Text;
         c.PostalCode    = tbxPostalCode.Text;
         c.PersonalID    = tbxPID.Text;
         c.Nationality   = tbxNationality.Text;
         c.PhoneNumber   = Convert.ToInt32(tbxPhone.Text);
         c.CustEmail     = tbxEmail.Text;
         c.Password      = tbxPassword.Text;
         Session["user"] = c;
         int row = CustomerDB.updateCustomer(c);
         //display an output
         lblOutput.Text = "Update successfully!";
         databindedCust();
     }
     else if (Session["userAttraction"] != null)
     {
         Attraction a = (Attraction)Session["userAttraction"];
         a.Name         = tbxCName.Text;
         a.RegID        = tbxRID.Text;
         a.Address      = tbxCAddress.Text;
         a.PostalCode   = tbxCPostalCode.Text;
         a.City         = tbxCCity.Text;
         a.Country      = tbxCCountry.Text;
         a.Password     = tbxCpass.Text;
         a.ContactNo    = tbxCPhone.Text;
         a.OrgEmail     = tbxCEmail.Text;
         a.Password     = tbxCPassword.Text;
         a.Description  = tbxDesc.Text;
         a.OpeningHours = tbxOHour.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             a.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + a.Photo;
         }
         Session["userAttraction"] = a;
         lblOutput.Text            = "Update successfully!";
         int row = AttractionDB.updateAttraction(a);
         databindedOrg();
     }
     else if (Session["userRestaurant"] != null)
     {
         Restaurant r = (Restaurant)Session["userRestaurant"];
         r.Name         = tbxCName.Text;
         r.RegID        = tbxRID.Text;
         r.Address      = tbxCAddress.Text;
         r.PostalCode   = tbxCPostalCode.Text;
         r.City         = tbxCCity.Text;
         r.Country      = tbxCCountry.Text;
         r.Password     = tbxCpass.Text;
         r.ContactNo    = tbxCPhone.Text;
         r.OrgEmail     = tbxCEmail.Text;
         r.Password     = tbxCPassword.Text;
         r.Description  = tbxDesc.Text;
         r.OpeningHours = tbxOHour.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             r.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + r.Photo;
         }
         r.License = tbxLicenseNo.Text;
         Session["userRestaurant"] = r;
         lblOutput.Text            = "Update successfully!";
         int row = RestaurantDB.updateRestaurant(r);
         databindedROrg();
     }
     else if (Session["userHotel"] != null)
     {
         Hotel h = (Hotel)Session["userHotel"];
         h.Name        = tbxCName.Text;
         h.RegID       = tbxRID.Text;
         h.Address     = tbxCAddress.Text;
         h.PostalCode  = tbxCPostalCode.Text;
         h.City        = tbxCCity.Text;
         h.Country     = tbxCCountry.Text;
         h.Password    = tbxCpass.Text;
         h.ContactNo   = tbxCPhone.Text;
         h.OrgEmail    = tbxCEmail.Text;
         h.Password    = tbxCPassword.Text;
         h.Description = tbxDesc.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             h.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + h.Photo;
         }
         h.License            = tbxOHour.Text;
         Session["userHotel"] = h;
         lblOutput.Text       = "Update successfully!";
         int row = HotelDB.updateHotel(h);
         databindedHOrg();
     }
 }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="customerID"></param>
 /// <returns></returns>
 public static bool Customer_Delete(string[] customerID)
 {
     return(CustomerDB.Delete(customerID));
 }
Exemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="customerID"></param>
 /// <returns></returns>
 public static Customer Customer_Get(string customerID)
 {
     return(CustomerDB.Get(customerID));
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static int Customer_Add(Customer data)
 {
     return(CustomerDB.Add(data));
 }
Exemplo n.º 12
0
 public OrderStatusDB(SqlConnection conn)
 {
     this.conn = conn;
     custDB = new CustomerDB(conn);
     ItemDB = new ItemDB(conn);
 }
Exemplo n.º 13
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        //checking whether the credit card entered is valid or not
        int cardValid = Utility.validateCreditCard(tbxCardNumber.Text);

        if (cardValid < 0)
        {
            lblOutput.Text = "Invalid card number. Please enter valid card number";
        }
        else
        {
            ShoppingCart sc = (ShoppingCart)Session["cart"]; //retrieve from the shopping cart session

            Booking        b  = null;                        //when booking id is null
            DiscountCoupon dc = null;                        //when discount coupon is null

            if (Session["DC"] != null)                       //to check whether the discount coupon is not null
            {
                dc = (DiscountCoupon)Session["DC"];          //retrieve from the discount coupon session
            }
            //add the booking details
            b = new Booking("", DateTime.Now, DateTime.Now, sc.NetAMount, sc.Tax, 7, sc.TotalPrice, sc.DiscountedAmt, amtPayable, tbxCardholderName.Text, "Visa", Convert.ToInt64(tbxCardNumber.Text), tbxCvv.Text, Convert.ToDateTime("24/" + ddlMonth.SelectedItem.Text + "/" + ddlYear.SelectedItem.Text), "", (Customer)Session["user"], dc);

            //insert the booking info in the database
            result = ShoppingCartDB.confirmBooking(sc, b, Session["user"].ToString());

            if (result >= 0) //checking the result is not null or minus
            {
                try
                {
                    //sending booking information to the customer
                    SmtpClient client = new SmtpClient("smtp.gmail.com");
                    client.EnableSsl   = true;
                    client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");
                    MailMessage msg, msg1;

                    Customer c = CustomerDB.getACustomerByEmail(Session["emailUser"].ToString()); //retrieve the customer session

                    msg = new MailMessage("*****@*****.**", c.CustEmail);

                    List <CartItem> acmList = sc.RoomCI;       //retrieve the cartitem from room details
                    List <CartItem> ticList = sc.TicketCI;     //retrieve the cartitem from ticket details
                    List <CartItem> resList = sc.RestaurantCI; //retrieve the cart item from restaurant details

                    msg.Subject = "Your Booking Request";
                    msg.Body    = "Booking ID: BK" + result + ". You have requested to book the following services: \r\n\r\n";
                    //add the accommodation info included in the shopping cart to the email body
                    for (int i = 0; i < acmList.Count; i++)
                    {
                        msg.Body    += acmList[i].SCRoom.Hotel.Name + "\r\nRoom ID: " + acmList[i].SCRoom.RoomID + "\r\nCheck-in Date: " + acmList[i].RoomCIDate + "\r\nCheck out Date: " + acmList[i].RoomCODate + "\r\n \r\n";
                        msg1         = new MailMessage("*****@*****.**", acmList[i].SCRoom.Hotel.OrgEmail);
                        msg1.Subject = "New Booking Request";
                        msg1.Body    = "A new booking request regarding your room at " + acmList[i].SCRoom.RoomID + " has been received. Please check your SmartTravel account to accept or reject booking request. Thanks";
                        client.Send(msg1);
                    }
                    //add the ticket type info included in the shopping cart to the email body
                    for (int n = 0; n < ticList.Count; n++)
                    {
                        msg.Body    += ticList[n].AttractionName + "\r\n Date: " + ticList[n].TICdate + "\r\nTotal Amount: " + ticList[n].TICtotalAMT + "\r\nTotal People " + ticList[n].TICqty + "\r\n\r\n";
                        msg1         = new MailMessage("*****@*****.**", ticList[n].TICTicket.Attraction.OrgEmail);
                        msg1.Subject = "New Booking Request";
                        msg1.Body    = "A new booking request regarding your Ticket Details " + ticList[n].TICketID + " " + ticList[n].TICketID + " has been received. Please check your SmartTravel account to accept or reject booking request. Thanks";
                        client.Send(msg1);
                    }
                    //add the restaurant info included in the shopping cart to the email body
                    for (int n = 0; n < resList.Count; n++)
                    {
                        msg.Body    += resList[n].RESname + "\r\n Address: " + resList[n].RESaddress + "\r\n Date: " + resList[n].RESdate + "\r\n Time: " + resList[n].REStime + "\r\nNumber of People: " + resList[n].RESguest + "\r\n\r\n";
                        msg1         = new MailMessage("*****@*****.**", resList[n].RESrestaurant.OrgEmail);
                        msg1.Subject = "New Booking Request";
                        msg1.Body    = "A new booking request regarding your Reservation Details " + "\r\n Date: " + resList[n].RESdate + "\r\n Time: " + resList[n].REStime + " " + " has been received. Please check your SmartTravel account to accept or reject booking request. Thanks";
                        client.Send(msg1);
                    }
                    int count = 1;                   //initialize the count

                    Random r = new Random();         //initialize the random number generator
                    companyName  = "SmartTravel";    //set the company name
                    customerName = c.Name;           //set the customer name from the session
                    orderNo      = r.Next(0, 10000); //initialize the order no from random number generator
                    DataTable dt = new DataTable();  //initialize the datatable
                                                     //add data column into receipt -- pdf generator
                    dt.Columns.AddRange(new DataColumn[5] {
                        new DataColumn("ID", typeof(string)),
                        new DataColumn("Name", typeof(string)),
                        new DataColumn("Price", typeof(int)),
                        new DataColumn("Quantity", typeof(int)),
                        new DataColumn("Total", typeof(int))
                    });
                    //add the accomodation info included in the shopping cart to the digital receipt
                    for (int i = 0; i < acmList.Count; i++)
                    {
                        dt.Rows.Add(count++, acmList[i].SCRoom.Hotel.Name + " -- Room ID: " + acmList[i].SCRoom.RoomID, acmList[i].SCRoom.Price, acmList[i].NoofRoom, acmList[i].RoomTotalAmt);
                    }
                    //add the ticket info included in the shopping cart to the digital receipt
                    for (int n = 0; n < ticList.Count; n++)
                    {
                        dt.Rows.Add(count++, ticList[n].TICTicket.Attraction.Name + " -- " + ticList[n].TICtype, ticList[n].TICTicket.Price, ticList[n].TICqty, ticList[n].TICtotalAMT);
                    }
                    //add the restaurant info included in the shopping cart to the digital receipt
                    for (int n = 0; n < resList.Count; n++)
                    {
                        dt.Rows.Add(count++, resList[n].RESname, 0, resList[n].RESguest, 0);
                    }

                    using (StringWriter sw = new StringWriter())
                    {
                        using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                        {
                            StringBuilder sb = new StringBuilder(); //initialize the stringbuilder

                            //Generate Invoice (Bill) Header.
                            sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                            sb.Append("<tr><td align='center' colspan = '2'><b>Order Sheet</b></td></tr>");
                            sb.Append(" </td></tr>");
                            sb.Append("<tr><td colspan = '2'><b>Customer Name: </b>");
                            sb.Append(customerName);
                            sb.Append("<tr><td colspan = '2'></td></tr>");
                            sb.Append("<tr><td><b>Order No: </b>");
                            sb.Append(orderNo);
                            sb.Append("</td><td align = 'right'><b>Date: </b>");
                            sb.Append(DateTime.Now);
                            sb.Append(" </td></tr>");
                            sb.Append("<tr><td colspan = '2'><b>Company Name: </b>");
                            sb.Append(companyName);
                            sb.Append("</td></tr>");
                            sb.Append("<tr><td colspan = '2'><b>Booking ID: </b>");
                            sb.Append("BK" + result);
                            sb.Append("</td></tr>");
                            sb.Append("</table>");
                            sb.Append("<br />");

                            //Generate Invoice (Bill) Items Grid.
                            sb.Append("<table border = '1'>");
                            sb.Append("<tr>");
                            foreach (DataColumn column in dt.Columns)
                            {
                                sb.Append("<th style = 'background-color: #D20B0C;color:#ffffff'>");
                                sb.Append(column.ColumnName);
                                sb.Append("</th>");
                            }
                            sb.Append("</tr>");
                            foreach (DataRow row in dt.Rows)
                            {
                                sb.Append("<tr>");
                                foreach (DataColumn column in dt.Columns)
                                {
                                    sb.Append("<td>");
                                    sb.Append(row[column]);
                                    sb.Append("</td>");
                                }
                                sb.Append("</tr>");
                            }
                            sb.Append("<tr><td align = 'right' colspan = '");
                            sb.Append(dt.Columns.Count - 1);
                            sb.Append("'>Total</td>");
                            sb.Append("<td>");
                            sb.Append(dt.Compute("sum(Total)", ""));
                            sb.Append("</td>");
                            sb.Append("</tr></table>");
                            sb.Append("<br />");
                            sb.Append("<br />");
                            sb.Append("<br />");
                            sb.Append("<br />");
                            sb.Append("<br />");
                            sb.Append("<br />");
                            sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                            sb.Append("<tr><td align='left' color='red' colspan = '2'><b>*Note:</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>Price is SGD</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>This receipt does not include the tax and booking charges</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><br/><br/><br/><br/><br/><br/></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>Please ensure all information listed above is correct and keep this receipt for your records</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>If you have any questions, please see the contact of the webpage</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>Contact +65 6390 9000</b></td></tr>");
                            sb.Append("<tr><td align='left' colspan = '2'><b>Thank You.</b></td></tr>");
                            sb.Append(" </td></tr>");
                            sb.Append("</table>");

                            StringReader sr = new StringReader(sb.ToString());

                            Document   pdfDoc     = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                            using (MemoryStream memoryStream = new MemoryStream()) //use memory stream to generate the pdfDoc
                            {
                                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
                                pdfDoc.Open();
                                htmlparser.Parse(sr);
                                pdfDoc.Close();
                                byte[] bytes = memoryStream.ToArray();
                                memoryStream.Close();
                                msg.Attachments.Add(new Attachment(new MemoryStream(bytes), "Invoice.pdf")); //add the attachment into an email
                                client.Send(msg);                                                            //sending email
                            }
                        }
                    }
                    btnPrint.Visible = true;
                    //print the booking successful message
                    lblOutput.Text = "Booking request successfully. Your booking ID is BK" + result + ". Thanks you for choosing SmartTravel.";
                    Session["bID"] = "BK" + result;
                }
                catch (Exception er)
                {
                    lblOutput.Text = "internet connection required";
                }
            }

            else
            {
                lblOutput.Text = "Unsuccessful"; //when the shopping cart cannot successfully inserted into database
            }
        }
    }
Exemplo n.º 14
0
    private void GeneratePDF(DataTable dt)                                            //to generate PDF
    {
        Customer c = CustomerDB.getACustomerByEmail(Session["emailUser"].ToString()); //retrieve the customer email

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                StringBuilder sb = new StringBuilder();

                //Generate Invoice (Bill) Header.
                sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                sb.Append("<tr><td align='center' colspan = '2'><b>Order Sheet</b></td></tr>");
                sb.Append(" </td></tr>");
                sb.Append("<tr><td colspan = '2'><b>Customer Name: </b>");
                sb.Append(customerName);
                sb.Append("<tr><td colspan = '2'></td></tr>");
                sb.Append("<tr><td><b>Order No: </b>");
                sb.Append(orderNo);
                sb.Append("</td><td align = 'right'><b>Date: </b>");
                sb.Append(DateTime.Now);
                sb.Append(" </td></tr>");
                sb.Append("<tr><td colspan = '2'><b>Company Name: </b>");
                sb.Append(companyName);
                sb.Append(" </td></tr>");
                sb.Append("<tr><td colspan = '2'><b>Booking ID: </b>");
                sb.Append(Session["bID"]);
                sb.Append("</td></tr>");
                sb.Append("</table>");
                sb.Append("<br />");

                //Generate Invoice (Bill) Items Grid.
                sb.Append("<table border = '1'>");
                sb.Append("<tr>");
                foreach (DataColumn column in dt.Columns)
                {
                    sb.Append("<th style = 'background-color: #D20B0C;color:#ffffff'>");
                    sb.Append(column.ColumnName);
                    sb.Append("</th>");
                }
                sb.Append("</tr>");
                foreach (DataRow row in dt.Rows)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn column in dt.Columns)
                    {
                        sb.Append("<td>");
                        sb.Append(row[column]);
                        sb.Append("</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("<tr><td align = 'right' colspan = '");
                sb.Append(dt.Columns.Count - 1);
                sb.Append("'>Total</td>");
                sb.Append("<td>");
                sb.Append(dt.Compute("sum(Total)", ""));
                sb.Append("</td>");
                sb.Append("</tr></table>");
                sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                sb.Append("<tr><td align='left' color='red' colspan = '2'><b>*Note:</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>Price is SGD</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>This receipt does not include the tax and booking charges</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><br/><br/><br/><br/><br/><br/></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>Please ensure all information listed above is correct and keep this receipt for your records</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>If you have any questions, please see the contact of the webpage</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>Contact +65 6390 9000</b></td></tr>");
                sb.Append("<tr><td align='left' colspan = '2'><b>Thank You.</b></td></tr>");
                sb.Append(" </td></tr>");
                sb.Append("</table>");

                //Export HTML String as PDF.
                StringReader sr         = new StringReader(sb.ToString());
                Document     pdfDoc     = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter    writer     = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                htmlparser.Parse(sr);
                pdfDoc.Close();
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=Invoice_" + orderNo + ".pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Write(pdfDoc);
                Response.End();
            }
        }
    }
Exemplo n.º 15
0
        /// <summary>
        /// the function is used to create a session of UserID
        /// </summary>
        protected void GettingCustomerID()
        {
            string userEmail = User.Identity.Name;

            Session["UserID"] = Convert.ToString(CustomerDB.GetCustomerID(userEmail).CustomerId);
        }
Exemplo n.º 16
0
        private void BalanceInquiry_Load(object sender, EventArgs e)
        {
            //will always find, otherwise wouldn't open the form;
            if (File.Exists(filePath1))
            {
                dictCustomer = CustomerDB.ReadFromFile();
                dictCustomer.TryGetValue(Int32.Parse(code), out aCustomer);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("CUSTOMER Database not found", "ERROR");
            }

            if (File.Exists(filePath2))
            {
                dictAccount = AccountDB.ReadFromFile();
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("ACCOUNT Database not found", "ERROR");
            }

            if (File.Exists(filePath3) && File.Exists(filePath4))
            {
                dictTransaction   = TransactionDB.ReadFromFile();
                sortedTransaction = TransactionDB.ReadFromFileSorted();
                lastValueTransac  = sortedTransaction.Keys.Last();
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("TRANSACTION Database not found", "ERROR");
                lastValueTransac = 30000;
            }

            if (aCustomer.customerAccount == null)
            {
                MessageBox.Show("No accounts to show");
            }

            dictAccount = aCustomer.customerAccount;

            AcclistView.Items.Clear();

            if (dictAccount != null)
            {
                foreach (Account current in dictAccount.Values)
                {
                    ListViewItem item = new ListViewItem(current.AccNumber.ToString());
                    item.SubItems.Add(Convert.ToString(current.Acctype));
                    item.SubItems.Add(current.OpenDate.ToShortDateString());
                    item.SubItems.Add("CAD " + current.Balance);
                    AcclistView.Items.Add(item);
                    Dictionary <int, Transaction> tempDictTransaction = new Dictionary <int, Transaction>();
                    tempDictTransaction = current.accTransactionDict;
                    foreach (Transaction transac in tempDictTransaction.Values)
                    {
                        ListViewItem secItem = new ListViewItem(transac.TransNumber.ToString());
                        secItem.SubItems.Add(Convert.ToString(transac.TransType));
                        secItem.SubItems.Add(current.AccNumber.ToString());
                        secItem.SubItems.Add(Convert.ToString(current.Acctype));
                        secItem.SubItems.Add(transac.Date.ToShortDateString());
                        secItem.SubItems.Add("CAD" + transac.Amount.ToString());
                        TransacListView.Items.Add(secItem);
                        //dictTransaction.Add(transac.TransNumber, transac);
                    }
                }
            }
            else
            {
                MessageBox.Show("No Data");
            }
        }
 private void CustomerBill_Load(object sender, EventArgs e)
 {
     customers = CustomerDB.ReadCustomers();
     DisplayCustomers();
     Statistics();
 }
Exemplo n.º 18
0
 public static List <Customer> ListOfCustomers()
 {
     return(CustomerDB.List(1, -1, "", ""));
 }
 //form
 private void CustomerBill_FormClosing(object sender, FormClosingEventArgs e)
 {
     CustomerDB.SaveCustomers(customers);
 }
Exemplo n.º 20
0
 public CustomerController()
 {
     CustomerDB = new CustomerDB();
 }
Exemplo n.º 21
0
 // Save data just before form closes (ie. data in listbox to file)
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     CustomerDB.SaveCustomers(customerList);
 }
Exemplo n.º 22
0
        public void PrintExportIO(invoiceoutheader ioh, List <invoiceoutdetail> IODetails, string taxStr, string podocID)
        {
            try
            {
                Dictionary <string, string> companyInfo = getCompanyInformation();
                string[] pos        = ioh.TrackingNos.Split(';');
                int      b          = 0;
                int[]    a          = (from s in pos where int.TryParse(s, out b) select b).ToArray();
                int      min        = a.Min();
                string[] dates      = ioh.TrackingDates.Split(';');
                string   poStr      = "";
                string   billingAdd = "";
                //StringBuilder sb = new StringBuilder();
                for (int i = 0; i < pos.Length - 1; i++)
                {
                    string   custPOStr = POPIHeaderDB.getCustomerPOAndDateForInvoiceOut(Convert.ToInt32(pos[i]), Convert.ToDateTime(dates[i]), podocID);
                    string[] custPO    = custPOStr.Split(Main.delimiter1);
                    if (Convert.ToInt32(pos[i]) == min)
                    {
                        billingAdd = custPO[2];
                    }
                    poStr = poStr + custPO[0] + " dated " + custPO[1] + "\n";
                }
                companybank   cb      = CompanyBankDB.getCompBankDetailForIOPrint(ioh.BankAcReference);
                CompanyDataDB datadb  = new CompanyDataDB();
                string        ieccode = "";
                cmpnydata     cdata   = datadb.getData("1").FirstOrDefault(c => c.DataID == "ImportExportCode");
                if (cdata != null)
                {
                    ieccode = cdata.DataValue;
                }

                customer custDetail        = CustomerDB.getCustomerDetailForPO(ioh.ConsigneeID);
                string[] companyBillingAdd = CompanyAddressDB.getCompTopBillingAdd(Login.companyID);
                string   ConsgAdd          = "Consignee:\n" + custDetail.name + Main.delimiter2 + "\n" + ioh.DeliveryAddress + "\n";
                string   buyer             = "Buyer:\n" + custDetail.name + Main.delimiter2 + "\n" + billingAdd + "\n";
                if (custDetail.StateName.ToString().Length != 0)
                {
                    ConsgAdd = ConsgAdd + "Sate Name:" + custDetail.StateName;
                    buyer    = buyer + "Sate Name:" + custDetail.StateName;
                    if (custDetail.StateCode.ToString().Length != 0)
                    {
                        ConsgAdd = ConsgAdd + " ,\nState Code:" + custDetail.StateCode;
                        buyer    = buyer + " ,\nState Code:" + custDetail.StateCode;
                    }
                }
                else
                {
                    if (custDetail.StateCode.ToString().Length != 0)
                    {
                        ConsgAdd = ConsgAdd + "\nState Code:" + custDetail.StateCode;
                        buyer    = buyer + "\nState Code:" + custDetail.StateCode;
                    }
                }
                //string buyer =
                if (custDetail.OfficeName.ToString().Length != 0)
                {
                    ConsgAdd = ConsgAdd + "\nGST:" + custDetail.OfficeName; // For GST Code
                    buyer    = buyer + "\nGST:" + custDetail.OfficeName;    // For GST Code
                }
                if (CustomerDB.getCustomerPANForInvoicePrint(ioh.ConsigneeID).Length != 0)
                {
                    ConsgAdd = ConsgAdd + "\nPAN:" + custDetail.OfficeName; // For PAN Code
                    buyer    = buyer + "\nPAN:" + custDetail.OfficeName;    // For PAN Code
                }

                string HeaderString = companyBillingAdd[0] + Main.delimiter2 + "\n" + companyBillingAdd[1] + "\nGST:" + companyInfo["GST"] + "\nCIN:" + companyInfo["CIN"] + "\nPAN:" + companyInfo["PAN"] +

                                      Main.delimiter1 + "Invoice No : " + ioh.InvoiceNo + ", Date : " + ioh.InvoiceDate.ToString("dd-MM-yyyy") +
                                      Main.delimiter1 + "Reference : " + poStr +
                                      Main.delimiter1 + "IEC Code : " + ieccode +
                                      Main.delimiter1 + "AD Code : " + ioh.ADCode + Main.delimiter1 +

                                      ConsgAdd +

                                      Main.delimiter1 + "Country of origin of goods : " + ioh.OriginCountryName +
                                      Main.delimiter1 + "Country of final destination : " + ioh.FinalDestinatoinCountryName +
                                      Main.delimiter1 + "Pre-Carriage by : " + ioh.PreCarriageTransportationName +
                                      Main.delimiter1 + "Place of Receipt by pre-carrier : " + ioh.PreCarrierReceiptPlace +
                                      Main.delimiter1 + "Port of Loading : " + ioh.ExitPort + Main.delimiter1 +

                                      buyer +

                                      Main.delimiter1 + "Port of Discharge : " + ioh.EntryPort +
                                      Main.delimiter1 + "Final Destination : " + ioh.FinalDestinationPlace +
                                      Main.delimiter1 + "Terms of Delivery : " + ioh.TermsOfDelivery +
                                      Main.delimiter1 + ioh.SpecialNote;


                string footer1   = "Amount In Words\n\n";
                string ColHeader = "SI No.;Description of Goods;HSN;Quantity;Unit;Unit Rate;Amount";
                string footer2   = "\n\nBank : " + cb.BankName + "\nBranch : " + cb.BranchName + "\nAC Type : " + cb.AccountType + "\nAC No : " +
                                   cb.AccountCode + "\nSWIFT Code : " + cb.CompanyID + "\nIFSC Code : " + cb.CreateUser;
                string footer3 = "For Cellcomm Solutions Limited;Authorised Signatory";
                //string termsAndCond = getTCString(poh.TermsAndCondition);
                double totQuant        = 0.00;
                double totAmnt         = 0.00;
                int    n               = 1;
                string ColDetailString = "";
                var    count           = IODetails.Count();
                ////string HSNCode = "";

                foreach (invoiceoutdetail iod in IODetails)
                {
                    ////if ((ioh.DocumentID == "SERVICEINVOICEOUT") || (ioh.DocumentID == "SERVICEEXPORTINVOICEOUT"))
                    ////{
                    ////    HSNCode = ServiceHSNMappingDB.getHSNCode(iod.StockItemID);
                    ////}
                    ////else
                    ////{
                    ////    HSNCode = ProductHSNMappingDB.getHSNCode(iod.StockItemID, iod.ModelNo);
                    ////}
                    //+ : main.delimiter1
                    if (n == count)
                    {
                        //ColDetailString = ColDetailString + n + "+" + iod.CustomerItemDescription + "+" + HSNCode + "+" + iod.Quantity + "+"
                        //                  + iod.Unit + "+" + iod.Price + "+" + (iod.Quantity * iod.Price);
                        ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode + Main.delimiter1 + iod.Quantity + Main.delimiter1
                                          + iod.Unit + Main.delimiter1 + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price);
                        if (iod.Tax != 0)
                        {
                            //ColDetailString = ColDetailString + Main.delimiter2 + "" + "+" + iod.TaxCode + "+" + "" + "+"
                            //              + "" + "+" + "" + "+" + "" + "+" + iod.Tax;
                            ColDetailString = ColDetailString + Main.delimiter2 + "" + Main.delimiter1 + iod.TaxCode + Main.delimiter1 + "" + Main.delimiter1
                                              + "" + Main.delimiter1 + "" + Main.delimiter1 + "" + Main.delimiter1 + iod.Tax;
                        }
                    }
                    else
                    {
                        ColDetailString = ColDetailString + n + Main.delimiter1 + iod.CustomerItemDescription + Main.delimiter1 + iod.HSNCode + Main.delimiter1 + iod.Quantity + Main.delimiter1
                                          + iod.Unit + Main.delimiter1 + iod.Price + Main.delimiter1 + (iod.Quantity * iod.Price) + Main.delimiter2;
                        if (iod.Tax != 0)
                        {
                            //ColDetailString = ColDetailString + "" + "+" + iod.TaxCode + "+" + "" + "+"
                            //              + "" + "+" + "" + "+" + "" + "+" + iod.Tax + Main.delimiter2;
                            ColDetailString = ColDetailString + "" + Main.delimiter1 + iod.TaxCode + Main.delimiter1 + "" + Main.delimiter1
                                              + "" + Main.delimiter1 + "" + Main.delimiter1 + "" + Main.delimiter1 + iod.Tax + Main.delimiter2;
                        }
                    }
                    totQuant = totQuant + iod.Quantity;
                    totAmnt  = totAmnt + (iod.Quantity * iod.Price);
                    n++;
                }

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Title            = "Save As PDF";
                sfd.Filter           = "Pdf files (*.Pdf)|*.pdf";
                sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                sfd.FileName         = ioh.DocumentID + "-" + ioh.InvoiceNo;

                if (sfd.ShowDialog() == DialogResult.Cancel || sfd.FileName == "")
                {
                    return;
                }
                FileStream fs  = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write);
                Rectangle  rec = new Rectangle(PageSize.A4);
                iTextSharp.text.Document doc = new iTextSharp.text.Document(rec);
                PdfWriter writer             = PdfWriter.GetInstance(doc, fs);
                MyEvent   evnt = new MyEvent();
                writer.PageEvent = evnt;

                doc.Open();
                Font   font1 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                Font   font2 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                Font   font3 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.ITALIC, BaseColor.BLACK);
                Font   font4 = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                String URL   = "Cellcomm2.JPG";
                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(URL);
                img.Alignment = Element.ALIGN_LEFT;

                PdfPTable tableMain = new PdfPTable(2);

                tableMain.WidthPercentage = 100;
                PdfPCell  cellImg = new PdfPCell();
                Paragraph pp      = new Paragraph();
                pp.Add(new Chunk(img, 0, 0));
                cellImg.AddElement(pp);
                cellImg.Border = 0;
                tableMain.AddCell(cellImg);

                PdfPCell        cellAdd = new PdfPCell();
                Paragraph       ourAddr = new Paragraph();
                CompanyDetailDB compDB  = new CompanyDetailDB();
                cmpnydetails    det     = compDB.getdetails().FirstOrDefault(comp => comp.companyID == 1);
                if (det != null)
                {
                    //string addr = det.companyname + "\n" + det.companyAddress;
                    ourAddr.Add(new Chunk(det.companyname + "\n", font2));
                    ourAddr.Add(new Chunk(det.companyAddress + "\n", font4));
                    ourAddr.SetLeading(0.0f, 1.5f);
                    //ourAddr = new Paragraph(new Phrase(addr, font2));
                    ourAddr.Alignment = Element.ALIGN_RIGHT;
                }
                cellAdd.AddElement(ourAddr);
                cellAdd.Border = 0;
                tableMain.AddCell(cellAdd);

                Paragraph paragraph = new Paragraph(new Phrase("Invoice", font2));
                paragraph.Alignment = Element.ALIGN_CENTER;

                PrintPurchaseOrder prog      = new PrintPurchaseOrder();
                string[]           HeaderStr = HeaderString.Split(Main.delimiter1);

                PdfPTable table = new PdfPTable(7);

                table.SpacingBefore   = 20f;
                table.WidthPercentage = 100;
                float[] HWidths = new float[] { 0.5f, 8f, 1.5f, 2f, 1.5f, 2f, 3f };
                table.SetWidths(HWidths);
                PdfPCell cell;
                int[]    arr = { 3, 7, 9, 10 };
                float    wid = 0;
                for (int i = 0; i < HeaderStr.Length; i++)
                {
                    if (i == 0 || i == 5 || i == 11)
                    {
                        string[] format = HeaderStr[i].Split(Main.delimiter2);
                        Phrase   phr    = new Phrase();
                        phr.Add(new Chunk(format[0], font2));
                        phr.Add(new Chunk(format[1], font1));
                        cell = new PdfPCell(phr);
                        if (i == 5)
                        {
                            cell.Rowspan = 5;
                        }
                        else
                        {
                            cell.Rowspan = 4;
                        }
                        cell.Colspan             = 2;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);
                    }
                    //else if (arr.Contains(i))
                    //{
                    //    cell = new PdfPCell(new Phrase(HeaderStr[i].Trim(), font1));
                    //    cell.Colspan = 5;
                    //    cell.MinimumHeight = wid;
                    //    table.AddCell(cell);
                    //}
                    else
                    {
                        cell         = new PdfPCell(new Phrase(HeaderStr[i].Trim(), font1));
                        cell.Colspan = 5;
                        //if (i % 2 != 0)
                        //    cell.Colspan = 3;
                        //else
                        //    cell.Colspan = 2;
                        table.AddCell(cell);
                    }
                }
                string[] ColHeaderStr = ColHeader.Split(';');

                PdfPTable table1 = new PdfPTable(7);
                table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                table1.WidthPercentage = 100;
                float[] width = new float[] { 0.5f, 8f, 1.5f, 2f, 1.5f, 2f, 3f };
                table1.SetWidths(width);

                for (int i = 0; i < ColHeaderStr.Length; i++)
                {
                    if (i == 5 || i == 6)
                    {
                        PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim() + "\n(" + ioh.CurrencyID + ")", font2));
                        hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        table1.AddCell(hcell);
                    }
                    else
                    {
                        PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim(), font2));
                        hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        table1.AddCell(hcell);
                    }
                }
                //---
                PdfPCell foot = new PdfPCell(new Phrase(""));
                foot.Colspan        = 7;
                foot.BorderWidthTop = 0;
                foot.MinimumHeight  = 0.5f;
                table1.AddCell(foot);

                table1.HeaderRows = 2;
                table1.FooterRows = 1;

                table1.SkipFirstHeader = false;
                table1.SkipLastFooter  = true;
                //---
                int     track = 0;
                decimal dc1   = 0;
                decimal dc2   = 0;

                string[] DetailStr = ColDetailString.Split(Main.delimiter2);
                float    hg        = 0f;
                for (int i = 0; i < DetailStr.Length; i++)
                {
                    track = 0;
                    hg    = table1.GetRowHeight(i + 1);
                    string[] str = DetailStr[i].Split(Main.delimiter1);
                    for (int j = 0; j < str.Length; j++)
                    {
                        PdfPCell pcell;
                        if (j == 3 || j == 5 || j == 6)
                        {
                            decimal p = 1;
                            if (Decimal.TryParse(str[j], out p))
                            {
                                pcell = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(str[j])), font1));
                            }
                            else
                            {
                                pcell = new PdfPCell(new Phrase(""));
                            }
                            pcell.Border = 0;
                            if (j == 6)
                            {
                                if (str[0].Length == 0)
                                {
                                    pcell.BorderWidthBottom = 0.01f;
                                    track = 1;
                                    dc2   = Convert.ToDecimal(str[j]);
                                }
                                else
                                {
                                    dc1 = Convert.ToDecimal(str[j]);
                                }
                            }
                        }
                        else
                        {
                            if (j == 2)
                            {
                                if (str[j].Trim().Length == 0)
                                {
                                    pcell = new PdfPCell(new Phrase("", font1));
                                }
                                else
                                {
                                    pcell = new PdfPCell(new Phrase(str[j], font1));
                                }
                            }
                            else if (j == 4)
                            {
                                int m = 1;
                                if (Int32.TryParse(str[j], out m) == true)
                                {
                                    if (Convert.ToInt32(str[j]) == 0)
                                    {
                                        pcell = new PdfPCell(new Phrase("", font1));
                                    }
                                    else
                                    {
                                        pcell = new PdfPCell(new Phrase(str[j], font1));
                                    }
                                }
                                else
                                {
                                    pcell = new PdfPCell(new Phrase(str[j], font1));
                                }
                            }
                            else
                            {
                                pcell = new PdfPCell(new Phrase(str[j], font1));
                            }
                            pcell.Border = 0;
                        }
                        //pcell.Border = 0;
                        //if (i == DetailStr.Length - 1)
                        //{
                        //    pcell.MinimumHeight = 50;
                        //}
                        //else
                        pcell.MinimumHeight = 10;
                        //pcell.MinimumHeight = 20;
                        if (j == 1)
                        {
                            pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                        }
                        else
                        {
                            pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        }
                        pcell.BorderWidthLeft  = 0.01f;
                        pcell.BorderWidthRight = 0.01f;
                        table1.AddCell(pcell);
                    }
                    if (track == 1)
                    {
                        for (int j = 0; j < 7; j++)
                        {
                            PdfPCell pcell1;

                            if (j == 6)
                            {
                                pcell1                   = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(dc1 + dc2)), font1));
                                pcell1.Border            = 0;
                                pcell1.BorderWidthBottom = 0.01f;
                            }
                            else
                            {
                                pcell1        = new PdfPCell(new Phrase(""));
                                pcell1.Border = 0;
                            }
                            pcell1.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            pcell1.BorderWidthLeft     = 0.01f;
                            pcell1.BorderWidthRight    = 0.01f;
                            table1.AddCell(pcell1);
                        }
                    }
                }

                double roundedAmt = Math.Round(ioh.InvoiceAmount, 0);
                double diffAmount = roundedAmt - ioh.InvoiceAmount;

                if (diffAmount != 0)
                {
                    table1.AddCell("");
                    table1.AddCell("");
                    PdfPCell cellRound = new PdfPCell(new Phrase("Round off Adj.", font1));
                    cellRound.Colspan             = 4;
                    cellRound.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    table1.AddCell(cellRound);
                    table1.AddCell(new Phrase(String.Format("{0:0.00}", diffAmount), font1));
                    //table1.AddCell("");
                }


                table1.AddCell("");
                table1.AddCell("");
                PdfPCell cellRoundTot = new PdfPCell(new Phrase("Total", font1));
                cellRoundTot.Colspan             = 4;
                cellRoundTot.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                table1.AddCell(cellRoundTot);

                PdfPCell roundTot = new PdfPCell(new Phrase(String.Format("{0:0.00}", roundedAmt), font1));
                roundTot.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                table1.AddCell(roundTot);

                string   total  = footer1 + NumberToString.convertFC(roundedAmt.ToString(), ioh.CurrencyID).Replace("INR", ioh.CurrencyID) + "\n\n";
                PdfPCell fcell1 = new PdfPCell(new Phrase((total), font1));
                fcell1.Colspan = 6;
                //fcell1.MinimumHeight = 30;
                fcell1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                fcell1.BorderWidthBottom   = 0;
                fcell1.BorderWidthRight    = 0;
                fcell1.BorderWidthTop      = 0;
                table1.AddCell(fcell1);

                PdfPCell fcell4 = new PdfPCell(new Phrase("E. & O.E", font1));
                //fcell4.MinimumHeight = 50;
                fcell4.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                fcell4.BorderWidthBottom   = 0;
                //fcell4.BorderWidthRight = 0;
                fcell4.BorderWidthLeft = 0;
                fcell4.BorderWidthTop  = 0;
                table1.AddCell(fcell4);

                //if (ioh.SpecialNote.Trim().Length != 0)
                //{
                //    PdfPCell SplNote = new PdfPCell(new Phrase(("Note:\n" + ioh.SpecialNote.Trim() + "\n"), font1));
                //    SplNote.Colspan = 5;
                //    SplNote.MinimumHeight = 50;
                //    SplNote.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                //    SplNote.BorderWidthBottom = 0;
                //    SplNote.BorderWidthRight = 0;
                //    SplNote.BorderWidthTop = 0;
                //    table1.AddCell(SplNote);

                //    PdfPCell temp1 = new PdfPCell(new Phrase(""));
                //    temp1.Colspan = 2;
                //    temp1.MinimumHeight = 50;
                //    temp1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                //    temp1.BorderWidthBottom = 0;
                //    temp1.BorderWidthLeft = 0;
                //    temp1.BorderWidthTop = 0;
                //    table1.AddCell(temp1);
                //    //table1.AddCell("");
                //}


                PdfPCell pcelNo = new PdfPCell(new Phrase("", font1));
                pcelNo.BorderWidthTop   = 0;
                pcelNo.BorderWidthRight = 0;
                table1.AddCell(pcelNo);

                Phrase phrs = new Phrase();
                phrs.Add(new Chunk("Bank Details", font2));

                phrs.Add(new Chunk(footer2, font1));
                //PdfPCell fcell2 = new PdfPCell(new Phrase(footer2, font1));

                PdfPCell fcell2 = new PdfPCell(phrs);
                fcell2.HorizontalAlignment = PdfPCell.ALIGN_MIDDLE;
                //fcell2.BorderWidthTop = 0;
                //fcell2.BorderWidthRight = 0;
                table1.AddCell(fcell2);

                PdfPCell pcelMid = new PdfPCell(new Phrase("", font1));
                pcelMid.Colspan = 3;
                //pcelMid.Border = 0;
                pcelMid.BorderWidthTop   = 0;
                pcelMid.BorderWidthLeft  = 0;
                pcelMid.BorderWidthRight = 0;
                table1.AddCell(pcelMid);

                string[] ft = footer3.Split(';');

                PdfPCell fcell3 = new PdfPCell();
                Chunk    ch1    = new Chunk(ft[0], font1);
                Chunk    ch2    = new Chunk(ft[1], font1);
                Phrase   phrase = new Phrase();
                phrase.Add(ch1);
                for (int i = 0; i < 3; i++)
                {
                    phrase.Add(Chunk.NEWLINE);
                }
                phrase.Add(ch2);

                Paragraph para = new Paragraph();
                para.Add(phrase);
                para.Alignment = Element.ALIGN_RIGHT;
                fcell3.AddElement(para);
                fcell3.Border            = 0;
                fcell3.Colspan           = 3;
                fcell3.BorderWidthTop    = 0f;
                fcell3.BorderWidthLeft   = 0f;
                fcell3.BorderWidthRight  = 0.5f;
                fcell3.BorderWidthBottom = 0.5f;
                fcell3.MinimumHeight     = 50;
                table1.AddCell(fcell3);
                table1.KeepRowsTogether(table1.Rows.Count - 4, table1.Rows.Count);
                //-------------------------
                double    dd     = 0;
                PdfPTable taxTab = new PdfPTable(3);
                taxTab.WidthPercentage = 100;

                float[] twidth = new float[] { 3f, 3f, 10f };
                taxTab.SetWidths(twidth);
                if (ioh.TaxAmount != 0)
                {
                    PdfPCell pcell;
                    pcell = new PdfPCell(new Phrase("Tax Details", font2));
                    taxTab.AddCell(pcell);
                    PdfPCell pcellc = new PdfPCell(new Phrase("Amount(" + ioh.CurrencyID + ")", font2));
                    taxTab.AddCell(pcellc);
                    PdfPCell pcelllst = new PdfPCell(new Phrase("", font1));
                    pcelllst.Border = 0;
                    taxTab.AddCell(pcelllst);

                    string[] tax = taxStr.Split(Main.delimiter2);
                    for (int i = 0; i < tax.Length - 1; i++)
                    {
                        string[] subtax = tax[i].Split(Main.delimiter1);
                        PdfPCell pcell1;
                        pcell1 = new PdfPCell(new Phrase(subtax[0], font1));
                        PdfPCell pcell2;
                        pcell2 = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(subtax[1])), font1));
                        PdfPCell pcell3 = new PdfPCell(new Phrase("", font1));
                        pcell3.Border = 0;
                        taxTab.AddCell(pcell1);
                        taxTab.AddCell(pcell2);
                        taxTab.AddCell(pcell3);
                    }
                    taxTab.AddCell(new Phrase("Total Tax Amount", font2));
                    taxTab.AddCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(ioh.TaxAmount)), font2));
                    PdfPCell pcellt = new PdfPCell(new Phrase("", font1));
                    pcellt.Border = 0;
                    taxTab.AddCell(pcellt);
                    taxTab.KeepTogether  = true;
                    taxTab.SpacingAfter  = 2f;
                    taxTab.SpacingBefore = 3f;
                }
                //PdfPTable TCTab = new PdfPTable(2); ;
                //if (poh.TermsAndCondition.Trim().Length != 0)
                //{
                //    Chunk TCchunk = new Chunk("Terms And Conditions:\n", font2);
                //    TCchunk.SetUnderline(0.2f, -2f);
                //    TCTab = new PdfPTable(2);
                //    TCTab.WidthPercentage = 100;
                //    PdfPCell TCCell = new PdfPCell();
                //    TCCell.Colspan = 2;
                //    TCCell.Border = 0;
                //    TCCell.AddElement(TCchunk);
                //    TCTab.AddCell(TCCell);
                //    try
                //    {
                //        string[] ParaTC = termsAndCond.Split(Main.delimiter2);
                //        for (int i = 0; i < ParaTC.Length - 1; i++)
                //        {
                //            TCCell = new PdfPCell();
                //            TCCell.Colspan = 2;
                //            TCCell.Border = 0;
                //            Paragraph header = new Paragraph();
                //            Paragraph details = new Paragraph();
                //            details.IndentationLeft = 12f;
                //            details.IndentationRight = 12f;
                //            string paraHeaderStr = (i + 1) + ". " + ParaTC[i].Substring(0, ParaTC[i].IndexOf(Main.delimiter1)) + ":";
                //            string paraFooterStr = ParaTC[i].Substring(ParaTC[i].IndexOf(Main.delimiter1) + 1);
                //            header.Add(new Phrase(paraHeaderStr, font2));
                //            details.Add(new Phrase(paraFooterStr, font1));
                //            TCCell.AddElement(header);
                //            TCCell.AddElement(details);
                //            TCTab.AddCell(TCCell);
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error-" + ex.ToString());
                //    }
                //    try
                //    {
                //        if (TCTab.Rows.Count >= 3)
                //        {
                //            TCTab.KeepRowsTogether(0, 3);
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error-" + ex.ToString());
                //    }
                //}
                //doc.Add(jpg);
                doc.Add(tableMain);
                doc.Add(paragraph);
                doc.Add(table);
                doc.Add(table1);
                if (ioh.TaxAmount != 0)
                {
                    doc.Add(taxTab);
                }
                //if(poh.TermsAndCondition.Trim().Length != 0)
                //    doc.Add(TCTab);
                doc.Close();
                MessageBox.Show("Document Saved");
                //-----watermark
                String wmurl = "";
                if (ioh.status == 98)
                {
                    //cancelled
                    wmurl = "003.png";
                }
                else
                {
                    //approved
                    wmurl = "001.png";
                }

                ////String wmurl = "napproved-1.jpg";
                iTextSharp.text.Image wmimg = iTextSharp.text.Image.GetInstance(URL);
                PrintWaterMark.PdfStampWithNewFile(wmurl, sfd.FileName);
                //-----
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error-" + ex.ToString());
                MessageBox.Show("Failed TO Save");
            }
        }
Exemplo n.º 23
0
        public void PrintWO(workorderheader woh, List <workorderdetail> WODetail, string totalTaxDetail)
        {
            Dictionary <string, string> companyInfo = getCompanyInformation();

            customer custDetail = CustomerDB.getCustomerDetailForPO(woh.CustomerID);

            string[] companyBillingAdd = CompanyAddressDB.getCompTopBillingAdd(Login.companyID);
            string   contractorAdd     = "Contractor:\n" + custDetail.name + Main.delimiter1 + "\n" + woh.POAddress + "\n";

            if (custDetail.StateName.ToString().Length != 0)
            {
                contractorAdd = contractorAdd + "Sate Name:" + custDetail.StateName;
            }
            if (custDetail.StateCode.ToString().Length != 0)
            {
                contractorAdd = contractorAdd + "\nState Code:" + custDetail.StateCode;
            }
            if (custDetail.OfficeName.ToString().Length != 0)
            {
                contractorAdd = contractorAdd + "\nGST:" + custDetail.OfficeName; // For GST Code
            }
            string InvoiceTo   = "Invoice To: \n" + companyBillingAdd[0] + Main.delimiter1 + "\n" + companyBillingAdd[1] + "\nGST:" + companyInfo["GST"] + "\nCIN:" + companyInfo["CIN"] + "\nPAN:" + companyInfo["PAN"];
            string declaration = "We, Cellcomm Solutions Limited (also referred to as “CSL”), are pleased to place" +
                                 " this Purchase Order (also referred to as 'PO') with the Contractor addressed below.In accepting this Purchase Order, the Contractor" +
                                 " undertakes to execute the work described herein as per the details and instructions shown below" +
                                 " (such details and instructions being the Specific Terms and Conditions agreed between the Parties) " +
                                 "and also subject to the General Terms & Conditions contained herein.";

            string HeaderString = contractorAdd +
                                  Main.delimiter2 + "PO No : S-" + woh.WONo + " , Date : " + String.Format("{0:dd MMMM, yyyy}", Convert.ToDateTime(woh.WODate)) +
                                  Main.delimiter2 + "Contractor Reference : " + woh.ContractorReference +
                                  Main.delimiter2 + "Target Date : " + String.Format("{0:dd MMMM, yyyy}", Convert.ToDateTime(woh.TargetDate)) + Main.delimiter2 +

                                  InvoiceTo +

                                  Main.delimiter2 + "Payment Terms : " + PTDefinitionDB.getPaymentTermString(woh.PaymentTerms) +
                                  Main.delimiter2 + woh.SpecialNote;


            string footer1         = "Amount in words\n\n";
            string ColHeader       = "SI No.;Description of Work;Location;Quantity;Rate;Amount";
            string footer2         = "This Purchase Order, being computer generated, does not require physical signature.";
            string footer3         = "for Cellcomm Solutions Limited;Authorised Signatory";
            string termsAndCond    = getTCString(woh.TermsAndCond, woh.DocumentID);
            double totQuant        = 0.00;
            double totAmnt         = 0.00;
            int    n               = 1;
            string ColDetailString = "";
            var    count           = WODetail.Count();

            //+ : main.delimeter1
            //; : main.delimiter2

            try
            {
                foreach (workorderdetail wod in WODetail)
                {
                    if (n == count)
                    {
                        ColDetailString = ColDetailString + n + Main.delimiter1 + wod.Description + Main.delimiter1 + wod.WorkLocation + Main.delimiter1 + wod.Quantity + Main.delimiter1
                                          + wod.Price + Main.delimiter1 + (wod.Quantity * wod.Price);
                    }
                    else
                    {
                        ColDetailString = ColDetailString + n + Main.delimiter1 + wod.Description + Main.delimiter1 + wod.WorkLocation + Main.delimiter1 + wod.Quantity + Main.delimiter1
                                          + wod.Price + Main.delimiter1 + (wod.Quantity * wod.Price) + Main.delimiter2;
                    }
                    totQuant = totQuant + wod.Quantity;
                    totAmnt  = totAmnt + (wod.Quantity * wod.Price);
                    n++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to Save 1 : " + ex.ToString());
            }
            try
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Title            = "Save As PDF";
                sfd.Filter           = "Pdf files (*.Pdf)|*.pdf";
                sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (woh.Status == 0 && woh.DocumentStatus < 99)
                {
                    sfd.FileName = woh.DocumentID + "-Temp-" + woh.TemporaryNo;
                }
                else
                {
                    sfd.FileName = woh.DocumentID + "-" + woh.WONo;
                }

                //sfd.ShowDialog();
                if (sfd.ShowDialog() == DialogResult.Cancel || sfd.FileName == "")
                {
                    return;
                }

                FileStream fs  = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write);
                Rectangle  rec = new Rectangle(PageSize.A4);
                //rec.Bottom = 10;
                iTextSharp.text.Document doc = new iTextSharp.text.Document(rec);
                PdfWriter writer             = PdfWriter.GetInstance(doc, fs);
                MyEvent   evnt = new MyEvent();
                writer.PageEvent = evnt;

                doc.Open();
                Font font1 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                Font font2 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                Font font3 = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.ITALIC, BaseColor.BLACK);
                Font font4 = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                //String imageURL = @"D:\Smrutiranjan\PurchaseOrder\index.jpg";
                //iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL);
                String URL = "Cellcomm2.JPG";
                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(URL);
                img.Alignment = Element.ALIGN_LEFT;
                //--

                PdfPTable tableHeader = new PdfPTable(2);

                tableHeader.WidthPercentage = 100;
                PdfPCell  cellImg = new PdfPCell();
                Paragraph pp      = new Paragraph();
                pp.Add(new Chunk(img, 0, 0));
                cellImg.AddElement(pp);
                cellImg.Border = 0;
                tableHeader.AddCell(cellImg);

                PdfPCell        cellAdd = new PdfPCell();
                Paragraph       ourAddr = new Paragraph("");
                CompanyDetailDB compDB  = new CompanyDetailDB();
                cmpnydetails    det     = compDB.getdetails().FirstOrDefault(comp => comp.companyID == 1);
                if (det != null)
                {
                    ourAddr.Add(new Chunk(det.companyname + "\n", font2));
                    ourAddr.Add(new Chunk(det.companyAddress.Replace("\r\n", "\n"), font4));
                    StringBuilder sb = new StringBuilder();
                    sb.Append("\nGST : " + companyInfo["GST"] + "\nState Code for GST : " + companyInfo["StateCode"] + "\nCIN : " + companyInfo["CIN"] + "\nPAN : " + companyInfo["PAN"]);
                    ourAddr.Add(new Chunk(sb.ToString(), font4));
                    ourAddr.Alignment = Element.ALIGN_RIGHT;
                    ourAddr.SetLeading(0.0f, 1.5f);
                }
                cellAdd.AddElement(ourAddr);
                cellAdd.Border = 0;
                tableHeader.AddCell(cellAdd);
                //----
                Paragraph paragraphDocumentName = new Paragraph(new Phrase("PURCHASE ORDER", font2));
                paragraphDocumentName.Alignment = Element.ALIGN_CENTER;
                Paragraph paragraphOpenCluse = new Paragraph(new Phrase(declaration, font1));
                paragraphOpenCluse.Alignment       = Element.ALIGN_JUSTIFIED;
                paragraphDocumentName.SpacingAfter = 15;
                //PrintPurchaseOrder prog = new PrintPurchaseOrder();
                string[] HeaderStr = HeaderString.Split(Main.delimiter2);

                PdfPTable TableAddress = new PdfPTable(6);

                TableAddress.SpacingBefore   = 20f;
                TableAddress.WidthPercentage = 100;
                float[] HWidths = new float[] { 0.5f, 4.5f, 2f, 2f, 2f, 3f };
                TableAddress.SetWidths(HWidths);
                PdfPCell cell;
                float    wid = 0;
                for (int i = 0; i < HeaderStr.Length; i++)
                {
                    if (i == 0 || i == 4)
                    {
                        string[] format = HeaderStr[i].Split(Main.delimiter1);
                        Phrase   phr    = new Phrase();
                        phr.Add(new Chunk(format[0], font2));
                        phr.Add(new Chunk(format[1], font1));
                        cell         = new PdfPCell(phr);
                        cell.Colspan = 3;
                        if (i == 0)
                        {
                            cell.Rowspan = 3;
                        }
                        else
                        {
                            cell.Rowspan = 2;
                        }
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        TableAddress.AddCell(cell);
                    }
                    else
                    {
                        cell               = new PdfPCell(new Phrase(HeaderStr[i].Trim(), font1));
                        cell.Colspan       = 3;
                        cell.MinimumHeight = wid;
                        TableAddress.AddCell(cell);
                    }
                }
                string[] ColHeaderStr = ColHeader.Split(';');

                PdfPTable TableItemDetails = new PdfPTable(6);
                TableItemDetails.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                TableItemDetails.WidthPercentage = 100;
                float[] width = new float[] { 0.5f, 4.5f, 2f, 2f, 2f, 3f };
                TableItemDetails.SetWidths(width);

                for (int i = 0; i < ColHeaderStr.Length; i++)
                {
                    PdfPCell hcell = new PdfPCell(new Phrase(ColHeaderStr[i].Trim(), font2));
                    hcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TableItemDetails.AddCell(hcell);
                }
                //---
                PdfPCell foot = new PdfPCell(new Phrase(""));
                foot.Colspan        = 6;
                foot.BorderWidthTop = 0;
                foot.MinimumHeight  = 0.5f;
                TableItemDetails.AddCell(foot);

                TableItemDetails.HeaderRows = 2;
                TableItemDetails.FooterRows = 1;

                TableItemDetails.SkipFirstHeader = false;
                TableItemDetails.SkipLastFooter  = true;
                //---
                int     track = 0;
                decimal dc1   = 0;
                decimal dc2   = 0;

                string[] DetailStr = ColDetailString.Split(Main.delimiter2);
                float    hg        = 0f;
                for (int i = 0; i < DetailStr.Length; i++)
                {
                    hg = TableItemDetails.GetRowHeight(i + 1);
                    string[] str = DetailStr[i].Split(Main.delimiter1);
                    for (int j = 0; j < str.Length; j++)
                    {
                        PdfPCell pcell;
                        if (j == 3 || j == 4 || j == 5)
                        {
                            decimal p = 1;
                            if (Decimal.TryParse(str[j], out p))
                            {
                                pcell = new PdfPCell(new Phrase(String.Format("{0:0.00}", Convert.ToDecimal(str[j])), font1));
                            }
                            else
                            {
                                pcell = new PdfPCell(new Phrase(""));
                            }
                            pcell.Border = 0;
                            if (j == 5)
                            {
                                if (str[0].Length == 0)
                                {
                                    pcell.BorderWidthBottom = 0.01f;
                                    track = 1;
                                    dc2   = Convert.ToDecimal(str[j]);
                                }
                                else
                                {
                                    dc1 = Convert.ToDecimal(str[j]);
                                }
                            }
                        }
                        else
                        {
                            pcell        = new PdfPCell(new Phrase(str[j], font1));
                            pcell.Border = 0;
                        }
                        pcell.MinimumHeight       = 10;
                        pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        pcell.BorderWidthLeft     = 0.01f;
                        pcell.BorderWidthRight    = 0.01f;
                        TableItemDetails.AddCell(pcell);
                    }
                }
                double roundedAmt = Math.Round(totAmnt, 0);
                double diffAmount = roundedAmt - totAmnt;
                if (diffAmount != 0)
                {
                    TableItemDetails.AddCell("");
                    TableItemDetails.AddCell("");
                    PdfPCell cellTot = new PdfPCell(new Phrase("", font1));
                    cellTot.Colspan             = 3;
                    cellTot.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TableItemDetails.AddCell(cellTot);
                    TableItemDetails.AddCell(new Phrase(String.Format("{0:0.00}", totAmnt), font2));

                    TableItemDetails.AddCell("");
                    TableItemDetails.AddCell("");
                    PdfPCell cellRound = new PdfPCell(new Phrase("Rounding off", font1));
                    cellRound.Colspan             = 3;
                    cellRound.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    TableItemDetails.AddCell(cellRound);
                    TableItemDetails.AddCell(new Phrase(String.Format("{0:0.00}", diffAmount), font1));
                }
                TableItemDetails.AddCell("");
                TableItemDetails.AddCell("");
                PdfPCell cellTotal = new PdfPCell(new Phrase("Total", font1));
                cellTotal.Colspan             = 3;
                cellTotal.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                TableItemDetails.AddCell(cellTotal);
                TableItemDetails.AddCell(new Phrase(String.Format("{0:0.00}", roundedAmt), font2));

                //-----
                string   total  = footer1 + NumberToString.convert(roundedAmt.ToString());
                PdfPCell fcell1 = new PdfPCell(new Phrase((total), font3));
                fcell1.Colspan             = 6;
                fcell1.MinimumHeight       = 50;
                fcell1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                //fcell1.BorderWidthBottom = 0;
                TableItemDetails.AddCell(fcell1);

                PdfPTable tableSub = new PdfPTable(1);
                tableSub.DefaultCell.Border = 0;
                tableSub.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                tableSub.AddCell(new Phrase("Subject To Bangalore Jurisdiction", font2));
                PdfPCell celSub = new PdfPCell(tableSub);
                celSub.Border  = 0;
                celSub.Colspan = 6;
                TableItemDetails.AddCell(celSub);
                TableItemDetails.KeepRowsTogether(TableItemDetails.Rows.Count - 5, TableItemDetails.Rows.Count);
                Paragraph footer = new Paragraph(new Phrase("Note : " + footer2, font3));
                footer.Alignment = Element.ALIGN_LEFT;
                //--------------------
                PdfPTable TCTab = new PdfPTable(2);
                if (woh.TermsAndCond.Trim().Length != 0)
                {
                    Chunk TCchunk = new Chunk("General Terms & Conditions\n", font2);
                    TCchunk.SetUnderline(0.2f, -2f);
                    TCTab = new PdfPTable(2);
                    TCTab.WidthPercentage = 100;
                    PdfPCell TCCell = new PdfPCell();
                    TCCell.Colspan = 2;
                    TCCell.Border  = 0;
                    TCCell.AddElement(TCchunk);
                    TCTab.AddCell(TCCell);
                    try
                    {
                        string[] ParaTC = termsAndCond.Split(Main.delimiter2);
                        for (int i = 0; i < ParaTC.Length + 1; i++)
                        {
                            TCCell         = new PdfPCell();
                            TCCell.Colspan = 2;
                            TCCell.Border  = 0;
                            Paragraph header  = new Paragraph();
                            Paragraph details = new Paragraph();
                            details.IndentationLeft  = 12f;
                            details.IndentationRight = 12f;
                            details.Alignment        = Element.ALIGN_JUSTIFIED;
                            string paraHeaderStr = (i + 1) + ". " + ParaTC[i].Substring(0, ParaTC[i].IndexOf(Main.delimiter1)) + ":";
                            string paraFooterStr = ParaTC[i].Substring(ParaTC[i].IndexOf(Main.delimiter1) + 1);
                            header.Add(new Phrase(paraHeaderStr, font2));
                            details.Add(new Phrase(paraFooterStr, font1));
                            TCCell.AddElement(header);
                            TCCell.AddElement(details);
                            TCTab.AddCell(TCCell);
                        }
                    }
                    catch (Exception ex)
                    {
                        ////MessageBox.Show("Failed to Save 2 : "+ex.ToString());
                    }
                    try
                    {
                        TCTab.KeepRowsTogether(0, 3);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to Save 3 : " + ex.ToString());
                    }
                }
                doc.Add(tableHeader);
                doc.Add(paragraphDocumentName);
                doc.Add(paragraphOpenCluse);
                doc.Add(TableAddress);
                doc.Add(TableItemDetails);
                doc.Add(footer);
                if (woh.TermsAndCond.Length != 0)
                {
                    doc.Add(TCTab);
                }
                doc.Close();

                if (woh.Status == 0 && woh.DocumentStatus < 99)
                {
                    String wmurl = "";
                    wmurl = "004.png";
                    PrintWaterMark.PdfStampWithNewFile(wmurl, sfd.FileName);
                }
                MessageBox.Show("Document Saved");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to Save 4 : " + ex.ToString());
            }
        }
Exemplo n.º 24
0
 public static int AddCustomer(Customer data)
 {
     return(CustomerDB.Add(data));
 }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        //take the answers and check if correct.
        //if so, set the third panel visible to display the password.
        //in real cases, the password should be sent to the user email.
        // Pnl3.Visible = true;
        //Pnl2.Visible = true;

        //get the security answers, verify if correct.
        try
        {
            cs  = WebConfigurationManager.ConnectionStrings["localConnection"].ConnectionString;
            con = new SqlConnection(cs);
            //get a list of security questions from the user
            SqlCommand cmd = new SqlCommand("select sa1 from vw_customerSq1 where email = '" + uname + "'", con);
            con.Open();
            // LblPwd.Text = "where1";
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);

            //LblSq1.Text = reader["question"];
            reader.Read();
            //LblPwd.Text = "where2";
            //LblSq1.Text = reader.GetValue(0).ToString();
            string sa1 = reader.GetValue(0).ToString();
            //string sa1 = "";
            //LblPwd.Text = reader.GetValue(0).ToString();
            //LblPwd.Text = "where3";
            reader.Close();

            cmd    = new SqlCommand("select sa2 from vw_customerSq2 where email = '" + uname + "'", con);
            reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
            reader.Read();

            string sa2 = reader.GetValue(0).ToString();
            reader.Close();
            con.Close();

            if ((TxtAns1.Text == sa1) && (TxtAns2.Text == sa2))
            {   //get the password
                Pnl2.Visible = false;
                //LblPwd.Text = "Your password is: " + CustomerDB.GetPwd(uname);
                string msg = "<a href=\"http://www.cs.iupui.edu\">Your password </a> is " + CustomerDB.GetPwd(uname);
                if (EmailPwd("*****@*****.**", uname, "Password Recovery", msg))
                {
                    LblMsg.Text = "The password has been sent to your email account. ";
                }
                else
                {
                    LblMsg.Text = "There is an error sending the password. Please try again later.";
                }
            }
            else
            {
                //send message
                LblPwd.Text = "in correct answer";
                //Pnl2.Visible = false;
                //Pnl3.Visible = true;
                LblMsg2.Text = "Information you entered is incorrect. Please try again.";
            }
        }
        catch (Exception err)
        {
            // LblMsg.Text = "Cannot submit information now. Please try again later.";
        }
        finally //must make sure the connection is properly closed
        {       //the finally block will always run whether there is an error or not
            con.Close();
        }
    }
Exemplo n.º 26
0
 public static int DeleteCustomers(string[] CustomerIDs)
 {
     return(CustomerDB.Delete(CustomerIDs));
 }
Exemplo n.º 27
0
    //this function will pull a list of transactions from this user
    //three sql clauses must be sent as they are used because order by cannot be used in the count(*) statement
    protected void DisplayTransaction(string headSql, string whereSql, string orderSql)
    {
        //headSql is "select ID, name, itemNumber, type, model, stockAmount, stockDate, cost, price, description from vw_instruInfo ";
        //whereSql defines the where clause

        int count = 0;

        count = CustomerDB.GetOneInt("select count(*) from vw_instruInfo " + whereSql);
        //LblMsg.Text = "select count(*) from vw_instruInfo " + whereSql + orderSql;
        if (count == 0)
        {//no transaction, create an empty row
            LblMsgNoResult.Text = "No Result is Found";
        }
        else
        {
            ArrayList res = new ArrayList();
            res = CustomerDB.GetRows(headSql + whereSql + orderSql);
            //  LblMsg.Text = headSql + whereSql + orderSql;

            for (int j = 0; j < res.Count; j++)
            {
                //loop through each row to get the content and create a panel to add to the web page
                ArrayList oneRow = new ArrayList();
                oneRow = (ArrayList)res[j];
                Panel panel = new Panel();
                //use unique IDs to dynamically create new web object to gurantee that each object has a unique ID
                panel.ID = "pnlResult" + oneRow[0].ToString();

                Label lblName = new Label();
                lblName.ID        = "lblName" + oneRow[0].ToString();
                lblName.Text      = "Name:";
                lblName.Height    = 20;
                lblName.Font.Size = 13;
                lblName.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblName);

                Label lblNameValue = new Label();
                lblNameValue.ID        = "lblNameValue" + oneRow[0].ToString();
                lblNameValue.Height    = 18;
                lblNameValue.Font.Size = 12;
                lblNameValue.ForeColor = System.Drawing.Color.Black;
                lblNameValue.Text      = oneRow[1].ToString();
                panel.Controls.Add(lblNameValue);

                Label lblItemNumber = new Label();
                lblItemNumber.ID        = "lblItemNumber" + oneRow[0].ToString();
                lblItemNumber.Text      = "Item Number:";
                lblItemNumber.Height    = 20;
                lblItemNumber.Font.Size = 13;
                lblItemNumber.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblItemNumber);

                Label lblItemNumberValue = new Label();
                lblItemNumberValue.ID        = "lblItemNumberValue" + oneRow[0].ToString();
                lblItemNumberValue.Height    = 18;
                lblItemNumberValue.Font.Size = 12;
                lblItemNumberValue.ForeColor = System.Drawing.Color.Black;
                lblItemNumberValue.Text      = oneRow[2].ToString();
                panel.Controls.Add(lblItemNumberValue);

                Label lblType = new Label();
                lblType.ID        = "lblType" + oneRow[0].ToString();
                lblType.Text      = "Type:";
                lblType.Height    = 20;
                lblType.Font.Size = 13;
                lblType.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblType);

                Label lblTypeValue = new Label();
                lblTypeValue.ID        = "lblItemNumberValue" + oneRow[0].ToString();
                lblTypeValue.Height    = 18;
                lblTypeValue.Font.Size = 12;
                lblTypeValue.ForeColor = System.Drawing.Color.Black;
                lblTypeValue.Text      = oneRow[3].ToString();
                panel.Controls.Add(lblTypeValue);


                Label lblModel = new Label();
                lblModel.ID        = "lblModel" + oneRow[0].ToString();
                lblModel.Text      = "Model:";
                lblModel.Height    = 20;
                lblModel.Font.Size = 13;
                lblModel.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblModel);

                Label lblModelValue = new Label();
                lblModelValue.ID        = "lblModelValue" + oneRow[0].ToString();
                lblModelValue.Height    = 18;
                lblModelValue.Font.Size = 12;
                lblModelValue.ForeColor = System.Drawing.Color.Black;
                lblModelValue.Text      = oneRow[4].ToString();
                panel.Controls.Add(lblModelValue);


                Label lblPrice = new Label();
                lblPrice.ID        = "lblPrice" + oneRow[0].ToString();
                lblPrice.Text      = "Price:";
                lblPrice.Height    = 20;
                lblPrice.Font.Size = 13;
                lblPrice.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblPrice);

                Label lblPriceValue = new Label();
                lblPriceValue.ID        = "lblPriceValue" + oneRow[0].ToString();
                lblPriceValue.Height    = 18;
                lblPriceValue.Font.Size = 12;
                lblPriceValue.ForeColor = System.Drawing.Color.Black;
                lblPriceValue.Text      = oneRow[8].ToString();
                panel.Controls.Add(lblPriceValue);


                Label lblDescription = new Label();
                lblDescription.ID        = "lblDescription" + oneRow[0].ToString();
                lblDescription.Text      = "Description:";
                lblDescription.Height    = 20;
                lblDescription.Font.Size = 13;
                lblDescription.ForeColor = System.Drawing.Color.Red;
                panel.Controls.Add(lblDescription);

                Label lblDescriptionValue = new Label();
                lblDescriptionValue.ID        = "lblDescriptionValue" + oneRow[0].ToString();
                lblDescriptionValue.Height    = 18;
                lblDescriptionValue.Font.Size = 12;
                lblDescriptionValue.ForeColor = System.Drawing.Color.Black;
                lblDescriptionValue.Text      = oneRow[9].ToString();
                panel.Controls.Add(lblDescriptionValue);

                panel.BorderWidth = Unit.Pixel(5);

                PnlTrans.Controls.Add(panel);
            }
        }
    }
Exemplo n.º 28
0
 public CreateACustomer(string name, string address, string[] paymentDetails)
 {
     CustDB = new CustomerDB();
 }
Exemplo n.º 29
0
        //make a transaction
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            UpdateTempData();
            Checking tempCheckAccount = new Checking();
            Saving   tempSavAccount   = new Saving();
            double   amount;



            Transaction aTransac = new Transaction();

            if (Double.TryParse(AmountTextBox.Text, out amount))
            {
                if (amount > 0)
                {
                    aTransac.Date      = DateTime.Now;
                    aTransac.Amount    = Convert.ToDouble(AmountTextBox.Text);
                    aTransac.AccNumber = Int32.Parse(AccNumTextBox.Text);
                    aTransac.AccType   = dictAccount[Int32.Parse(AccNumTextBox.Text)].Acctype;
                }
                else
                {
                    MessageBox.Show("Amount must be a positive value!");
                    aTransac = null;
                }
            }
            else
            {
                MessageBox.Show("Invalid amount!");
            }

            /*
             * if (aTransac.AccType == Account.EnumType.Checkings)
             * {
             *  foreach (Checking current in aCustomer.customerAccount.Values)
             *  {
             *      tempCheckAccount = (Checking)current;
             *  }
             *  if (tempCheckAccount.Counter < tempCheckAccount.LimitTransac)
             *  {
             *      tempCheckAccount.Counter++;
             *  }
             *  else
             *  {
             *      aTransac = null;
             *      MessageBox.Show("You have reached your transaction limit for this account");
             *  }
             * }
             *
             * if (aTransac.AccType == Account.EnumType.Savings)
             * {
             *  foreach (Saving current in aCustomer.customerAccount.Values)
             *  {
             *      tempSavAccount = (Saving)current;
             *  }
             * }
             */


            if (!(checkBoxWithdraw.Checked || checkBoxDeposit.Checked))
            {
                MessageBox.Show("Please Select a Transaction Type");
                aTransac = null;
            }

            if (aTransac != null && (Double.TryParse(AmountTextBox.Text, out amount)))/////CHECAR REPETICAO AQUI!
            {
                if (checkBoxWithdraw.Checked)
                {
                    aTransac.TransNumber = transacNum.NextValue(lastValueTransac);
                    aTransac.TransType   = Transaction.EnumType.Withdraw;
                    dictAccount[Int32.Parse(AccNumTextBox.Text)].Balance -= aTransac.Amount;
                    dictCustomer[Int32.Parse(code)].customerAccount[Int32.Parse(AccNumTextBox.Text)].Balance -= aTransac.Amount;
                }
                else if (checkBoxDeposit.Checked)
                {
                    aTransac.TransNumber = transacNum.NextValue(lastValueTransac);
                    aTransac.TransType   = Transaction.EnumType.Deposit;
                    dictAccount[Int32.Parse(AccNumTextBox.Text)].Balance += aTransac.Amount;
                    dictCustomer[Int32.Parse(code)].customerAccount[Int32.Parse(AccNumTextBox.Text)].Balance += aTransac.Amount;
                }
                TransactionNumberTextBox.Text = Convert.ToString(aTransac.TransNumber);
                NewBalanceTextBox.Text        = Convert.ToString(dictCustomer[Int32.Parse(code)].customerAccount[Int32.Parse(AccNumTextBox.Text)].Balance);
                sortedTransaction.Add(aTransac.TransNumber, aTransac);
                TransactionDB.SaveToFile(sortedTransaction);
                dictTransaction.Add(aTransac.TransNumber, aTransac);
                TransactionDB.SaveToFile(dictTransaction);
                dictAccount[Int32.Parse(AccNumTextBox.Text)].accTransactionDict.Add(aTransac.TransNumber, aTransac);
                AccountDB.SaveToFile(dictAccount);
                dictCustomer[Int32.Parse(code)].customerAccount[Int32.Parse(AccNumTextBox.Text)].accTransactionDict.Add(aTransac.TransNumber, aTransac);
                CustomerDB.SaveToFile(dictCustomer);
                DisplayTransacList(dictCustomer[Int32.Parse(code)].customerAccount[Int32.Parse(AccNumTextBox.Text)].accTransactionDict);
                Dictionary <int, Account> tempDictAccount = new Dictionary <int, Account>();
                tempDictAccount = dictCustomer[Int32.Parse(code)].customerAccount;
                DisplayAccList(tempDictAccount);//ATUALIZAR
                lastValueTransac++;
                ConfirmButton.Enabled = false;
            }
        }
Exemplo n.º 30
0
        // just before form closes, save data

        private void kWLabelInd_FormClosing(object sender, FormClosingEventArgs e)
        {
            CustomerDB.SaveCustomers(customers);
        }
 public CustomertsRigistrationController(CustomerDB context)
 {
     _context = context;
 }