Esempio n. 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (txtCustomerName.Text != "")
     {
         if (comboBoxPayment.SelectedIndex != -1)
         {
             if (IsDigitsOnly(txtTotalAmount.Text))
             {
                 MobileFixVS2015.AppCode.claDBSale sale = new MobileFixVS2015.AppCode.claDBSale();
                 SaleID = sale.AddSale(dateTime.Value.Date, comboBoxPayment.Text, Convert.ToDouble(txtTotalAmount.Text));
                 if (SaleID > 0)
                 {
                     clsDBSaleLine SaleLine = new clsDBSaleLine();
                     int           Result   = 0;
                     int           count    = lstSale.Items.Count;
                     for (int j = 0; j < count; j++)
                     {
                         int    ProductID = Convert.ToInt32(lstSale.Items[j].Tag);               //ID
                         double Price     = Convert.ToDouble(lstSale.Items[j].SubItems[2].Text); //Price
                         string Notes     = lstSale.Items[j].SubItems[3].Text;                   //Notes
                         //to check if all sale lines were added Successfullys
                         Result = Result + SaleLine.AddSaleLine(SaleID, ProductID, Price, Notes);
                     }
                     if (Result == 0)//All Added Successfullys
                     {
                         // Display a message box asking users if they
                         // want to Print a reciept for the added sale.
                         if (MessageBox.Show("Do you want a reciept for this sale?", " Print Reciept",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                             == DialogResult.Yes)
                         {
                             //this code will show print preview
                             MFPrintPreviewDialog.Document = MFPrintDocument;
                             MFPrintPreviewDialog.ShowDialog();
                             //this will close the sale form
                             this.Close();
                         }
                         else
                         {
                             //close the form
                             this.Close();
                         }
                     }
                 }
             }
             else
             {
                 labelError.Text = "Total Amount is not a valid Number";
             }
         }
         else
         {
             labelError.Text = "Please choose a payment Method";
         }
     }
     else
     {
         labelError.Text = "Please Enter a Customer Name";
     }
 }
Esempio n. 2
0
 private void btnPrintPreview_Click(object sender, EventArgs e)
 {
     //this code will show print preview
     MFPrintPreviewDialog.Document = MFPrintDocument;
     MFPrintPreviewDialog.ShowDialog();
 }