コード例 #1
0
        private void AddingDataIntoTextboxesAfterProductSelection(string selectedProductId)
        {
            StockDetail selectedProduct = availableProducts.FirstOrDefault(obj => obj.ProductId.ToString().Equals(Product_Search_Textbox.Text) || obj.ProductName.Equals(selectedProductId));

            if (selectedProduct == null)
            {
                return;
            }
            Product_Search_Textbox.Text = selectedProduct.ProductId.ToString();
            Product_Name_Textbox.Text   = selectedProduct.ProductName;
            Retail_Price_Textbox.Text   = string.Format("{0:0.00}", selectedProduct.RetailPrice);
            Available_Qty_Textbox.Text  = string.Format("{0:0.00}", selectedProduct.Quantity);
            Gst_Percent_Textbox.Text    = selectedProduct.GSTPercentage.ToString();
            HideResults();
            if (selectedProduct.Quantity != 0)
            {
                Quantity_textBox.Focus();
                Quantity_textBox.ReadOnly = false;
            }
            else
            {
                if (MessageBox.Show("Selected Product Is Not Available, It's Available Quantity is Zero", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop) == DialogResult.OK)
                {
                    Product_Search_Textbox.Focus();
                    Product_Search_Textbox.Text = Product_Name_Textbox.Text = Retail_Price_Textbox.Text = string.Empty;
                    Available_Qty_Textbox.Text  = Gst_Percent_Textbox.Text = string.Empty;
                }
            }
        }
コード例 #2
0
 private void BillPage_Load(object sender, EventArgs e)
 {
     try
     {
         CreateProgressInstance();
         progressBar.worker.DoWork             += FormLoadDoWork;
         progressBar.worker.RunWorkerCompleted += FormLoadRunWorkerCompleted;
         progressBar.worker.RunWorkerAsync();
         BillDate_textBox.Text = DateTime.Today.ToString("dd-MM-yyyy");
         Product_Search_Textbox.Focus();
         BilledProducts_GridView.Columns[0].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[1].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[2].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[3].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[4].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[5].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[6].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[7].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
         BilledProducts_GridView.Columns[8].HeaderCell.Style.Font = new Font("Tahoma", 9.75F, FontStyle.Bold);
     }
     catch (Exception ex)
     {
         this.Invoke((System.Action)(() => { progressBar.Close(); }), null);
         MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Bill Page", MessageBoxButtons.OK);
     }
 }
コード例 #3
0
 private void BillPage_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F2)
     {
         Print_Bill_Btn_Click(null, null);
         Product_Search_Textbox.Focus();
     }
     else if (e.KeyCode == Keys.Enter)
     {
         if (!Product_Search_ListBox.Visible && !isBillPrinted)
         {
             Add_button_Click(null, null);
         }
         else if (isBillPrinted)
         {
             BillDetailsUpdation();
         }
         else if (Product_Search_ListBox.Visible && Product_Search_ListBox.Items.Count == 1)
         {
             ProductIdEntered();
         }
         else if (Product_Search_ListBox.Visible && Product_Search_ListBox.SelectedIndex != -1)
         {
             Product_Search_ListBox_MouseClick(null, null);
         }
     }
     else if (e.KeyCode == Keys.Up)
     {
         if (Product_Search_ListBox.Visible && Product_Search_ListBox.Items.Count > 0 &&
             Product_Search_ListBox.SelectedIndex != 0)
         {
             Product_Search_ListBox.Focus();
             Product_Search_ListBox.Select();
         }
         if (Product_Search_ListBox.Visible && Product_Search_ListBox.Items.Count > 0 &&
             Product_Search_ListBox.SelectedIndex == 0)
         {
             Product_Search_Textbox.Focus();
         }
     }
     else if (e.KeyCode == Keys.Down && Product_Search_ListBox.Items.Count > 0)
     {
         if (Product_Search_ListBox.Visible)
         {
             Product_Search_ListBox.Focus();
             Product_Search_ListBox.Select();
         }
     }
     else if (e.KeyCode == Keys.F3)
     {
         Cancel_Button_Click(null, null);
     }
     else if (e.KeyCode == Keys.Tab)
     {
         if (Product_Search_ListBox.Visible && Product_Search_ListBox.Items.Count == 1)
         {
             ProductIdEntered();
         }
     }
 }
コード例 #4
0
 private void Print_Bill_Btn_Click(object sender, EventArgs e)
 {
     try
     {
         Product_Search_Textbox.Focus();
         if (BilledProducts_GridView.Rows.Count > 0)
         {
             isBillPrinted                   = true;
             Print_Bill_Btn.Enabled          = Add_Product_Btn.Enabled = Remove_Btn.Enabled = false;
             Product_Search_Textbox.ReadOnly = true;
             Error_Message_Label.Text        = "UPDATING CURRENT BILL";
             billNumber = cashier.GetRetailBillCurrentBillNumber();
             Print();
         }
         else
         {
             Error_Message_Label.Text = "Add Products For Bill";
             HideWarningMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Bill Page", MessageBoxButtons.OK);
     }
 }
コード例 #5
0
 private void Cancel_Button_Click(object sender, EventArgs e)
 {
     Product_Search_Textbox.Focus();
     Print_Bill_Btn.Enabled          = Add_Product_Btn.Enabled = Remove_Btn.Enabled = true;
     Product_Search_Textbox.ReadOnly = isBillPrinted = false;
     GSTAmount_TextBox.Text          = BillAmount_Textbox.Text = Total_Bill_Qty_Textbox.Text = Total_Amount_Textbox.Text = string.Empty;
     BilledProducts_GridView.Rows.Clear();
     AssignEmptyToAvailableTextboxes();
     BillDate_textBox.Text = DateTime.Today.ToString("dd-MM-yyyy");
     BillPage_Load(null, null);
     HideWarningMessage();
 }
コード例 #6
0
 private void Print_Bill_Btn_Click(object sender, EventArgs e)
 {
     try
     {
         Product_Search_Textbox.Focus();
         if (BilledProducts_GridView.Rows.Count > 0)
         {
             PaymentConformation paymentConformation = new PaymentConformation()
             {
                 StartPosition = FormStartPosition.CenterScreen,
             };
             paymentConformation.Total_Textbox.Text         = Total_Amount_Textbox.Text;
             paymentConformation.CustomerName_Textbox.Text  = customerName;
             paymentConformation.Mobile_Number_Textbox.Text = mobileNumber;
             paymentConformation.Paid_Amount_Textbox.Text   = paidAmount;
             paymentConformation.FormClosed += (s, args) =>
             {
                 if (paymentConformation.isOkButtonClicked)
                 {
                     customerName                    = paymentConformation.CustomerName_Textbox.Text;
                     mobileNumber                    = paymentConformation.Mobile_Number_Textbox.Text;
                     paidAmount                      = paymentConformation.Paid_Amount_Textbox.Text;
                     isBillPrinted                   = true;
                     Print_Bill_Btn.Enabled          = Add_Product_Btn.Enabled = Remove_Btn.Enabled = false;
                     Product_Search_Textbox.ReadOnly = true;
                     Error_Message_Label.Text        = "UPDATING CURRENT BILL";
                     billNumber                      = cashier.GetCreditBillCurrentBillNumber();
                     Print();
                 }
             };
             paymentConformation.ShowInTaskbar = false;
             paymentConformation.Show(this);
         }
         else
         {
             Error_Message_Label.Text = "Add Products For Bill";
             HideWarningMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Bill Page", MessageBoxButtons.OK);
     }
 }
コード例 #7
0
 private void BillDetailsUpdation()
 {
     try
     {
         if (isBillPrinted)
         {
             Product_Search_Textbox.Focus();
             CreateProgressInstance();
             progressBar.worker.DoWork             += BillDetailsUpdationDoWork;
             progressBar.worker.RunWorkerCompleted += BillDetailsUpdationRunWorkerCompleted;
             progressBar.worker.RunWorkerAsync();
         }
         else
         {
             MessageBox.Show("Please Print the Bill First");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Bill Page", MessageBoxButtons.OK);
     }
 }
コード例 #8
0
        private void Add_button_Click(object sender, EventArgs e)
        {
            decimal purchasedQuantity = 0;
            decimal purchasedPrice    = 0;
            decimal gstDividend       = 0;
            decimal selectedProductBillAmount;
            decimal selectedProductGSTAmount;

            try
            {
                Product_Search_Textbox.Focus();

                if (!string.IsNullOrWhiteSpace(Quantity_textBox.Text) && decimal.TryParse(Quantity_textBox.Text, out decimal quantityValidaton))
                {
                    purchasedQuantity = Convert.ToDecimal(Quantity_textBox.Text);
                    purchasedPrice    = Convert.ToDecimal(Retail_Price_Textbox.Text);
                }

                if (Product_Search_Textbox.Text == string.Empty)
                {
                    Error_Message_Label.Text = Constants.SELECT_ANY_PRODUCT_ERROR_MESSAGE;
                    HideWarningMessage();
                    Product_Search_Textbox.Focus();
                }
                else if (purchasedQuantity == 0)
                {
                    Error_Message_Label.Text = Constants.ENTER_VALID_QUANTITY_ERROR_MESSAGE;
                    HideWarningMessage();
                    Quantity_textBox.Focus();
                }
                else if (purchasedQuantity > Convert.ToDecimal(Available_Qty_Textbox.Text))
                {
                    MessageBox.Show("Entered Quantity Is Greater Than Available Quantity", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Quantity_textBox.Focus();
                }
                else
                {
                    selectedProductBillAmount = purchasedQuantity * purchasedPrice;
                    if (Gst_Percent_Textbox.Text != "0")
                    {
                        gstDividend = Convert.ToDecimal(Gst_Percent_Textbox.Text) / 100;
                    }
                    selectedProductGSTAmount = selectedProductBillAmount * gstDividend;

                    BilledProducts_GridView.Rows.Add((BilledProducts_GridView.Rows.Count + 1).ToString(), Product_Search_Textbox.Text, Product_Name_Textbox.Text, string.Format("{0:0.00}", purchasedQuantity), string.Format("{0:0.00}", purchasedPrice), string.Format("{0:0.00}", selectedProductBillAmount), Gst_Percent_Textbox.Text, string.Format("{0:0.00}", selectedProductGSTAmount), string.Format("{0:0.00}", selectedProductGSTAmount + selectedProductBillAmount));

                    if (BillAmount_Textbox.Text == string.Empty)
                    {
                        BillAmount_Textbox.Text     = string.Format("{0:0.00}", selectedProductBillAmount);
                        GSTAmount_TextBox.Text      = string.Format("{0:0.00}", selectedProductGSTAmount);
                        Total_Bill_Qty_Textbox.Text = string.Format("{0:0}", purchasedQuantity);
                        Total_Amount_Textbox.Text   = string.Format("{0:0.00}", Math.Round(selectedProductBillAmount + selectedProductGSTAmount, MidpointRounding.ToEven));
                    }
                    else
                    {
                        BillAmount_Textbox.Text     = string.Format("{0:0.00}", Convert.ToDecimal(BillAmount_Textbox.Text) + selectedProductBillAmount);
                        GSTAmount_TextBox.Text      = string.Format("{0:0.00}", Convert.ToDecimal(GSTAmount_TextBox.Text) + selectedProductGSTAmount);
                        Total_Bill_Qty_Textbox.Text = string.Format("{0:0}", Convert.ToDecimal(Total_Bill_Qty_Textbox.Text) + purchasedQuantity);
                        Total_Amount_Textbox.Text   = string.Format("{0:0.00}", Math.Round(Convert.ToDecimal(Total_Amount_Textbox.Text) + selectedProductBillAmount + selectedProductGSTAmount, MidpointRounding.ToEven));
                    }

                    Quantity_textBox.ReadOnly = true;
                    AssignEmptyToAvailableTextboxes();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace.ToString(), "Error Occured at Bill Page", MessageBoxButtons.OK);
            }
        }