private void txtSearch_TextChanged(object sender, EventArgs e) { string keyword = txtSearch.Text; if (keyword == "") { txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; return; } DeaCustBLL dc = dcDAL.SearchDealerCustomerForTransaction(keyword); txtName.Text = dc.name; txtEmail.Text = dc.email; txtContact.Text = dc.contact; txtAddress.Text = dc.address; }
private void cmbCustomer_SelectedValueChanged(object sender, EventArgs e) { string deaCustName = cmbCustomer.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); if (dc.type != null) { Discount = decimal.Parse(dc.type); } { if (dgvAddedProducts.Rows.Count > 0) { for (int i = 0; i < dgvAddedProducts.Rows.Count - 1; i++) { dgvAddedProducts.Rows[i].Cells["Discount"].Value = dc.type; } CalcTot(); } } }
private void txtSearch_TextChanged(object sender, EventArgs e) { // Get the keyword from text box string keyword = txtSearch.Text; if (keyword == "") { //clear all the text boxes txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; return; } // get the details and set to trext boxes DeaCustBLL dc = dcDAL.SearchDealerCustomerForTransaction(keyword); // transfer or set the value from DeaCustBLL to text boxes txtName.Text = dc.name; txtEmail.Text = dc.email; txtContact.Text = dc.contact; txtAddress.Text = dc.address; }
private void BtnUpdate_Click(object sender, EventArgs e) { d.id = Convert.ToInt32(txtDeaCustID.Text); d.type = cmbType.Text; d.name = txtName.Text; d.email = txtEmail.Text; d.contact = txtContact.Text; d.address = txtAddress.Text; d.added_date = DateTime.Now; //Geting Username of logged in user string loggedUser = frmLogin.loggedIn; DeaCustBLL usr = dal.GetIDFromUsername(loggedUser); d.added_by = usr.id; //Creatae booleaan to chec if the product is added successflly or not bool success = dal.Update(d); if (success == true) { //Product Inserted successfully MessageBox.Show("Data Update Successfully"); Clear(); DataTable dt = dal.Select(); dgvDeaCust.DataSource = dt; } else { //Failed to ADD New Product MessageBox.Show("Data to Update Product"); Clear(); DataTable dt = dal.Select(); dgvDeaCust.DataSource = dt; } }
private void btnSave_Click(object sender, EventArgs e) { //Get the Values from PurchaseSales Form First transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; //Get the ID of Dealer or Customer Here //Lets get name of the dealer or customer first string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); //Get the Username of Logged in user string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //Lets Create a Boolean Variable and set its value to false bool success = false; //Actual Code to Insert Transaction And Transaction Details using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; //Create aboolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction, out transactionID); //Use for loop to insert Transaction Details for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transactionDetailBLL transactionDetail = new transactionDetailBLL(); //Get the Product name and convert it to id string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; //Here Increase or Decrease Product Quantity based on Purchase or sales string transactionType = lblTop.Text; //Lets check whether we are on Purchase or Sales bool x = false; if (transactionType == "Purchase") { //Increase the Product x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { //Decrease the Product Quntiyt x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //Insert Transaction Details inside the database bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } if (success == true) { //Transaction Complete scope.Complete(); //Code to Print Bill DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n\r\n MEGA STORE PVT. LTD. \r\n\r\n"; printer.SubTitle = "Kurunegala, Puttalam Rd \r\n Phone: 077-8513462 \r\n\r\n"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: " + txtGrandTotal.Text + "\r\n\r\n" + "Thank you for doing business with us."; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvAddedProducts); MessageBox.Show("Transaction Completed Sucessfully"); //Celar the Data Grid View and Clear all the TExtboxes dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; TxtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { //Transaction Failed MessageBox.Show("Transaction Failed"); } } }
private void btnSave_Click(object sender, EventArgs e) { //Get the Values or details from the PurchaseForm first transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; //Get the ID of Dealer or Customer Here //Lets get name of the dealer or customer first string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); //*********************** transaction.dea_cust_id = dc.id; //*********************************** transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); //Get the Username of the Logged in User string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //Lets Create a Boolean Variable and Set it's value to False bool success = false; //Actual code to Insert Transaction and Transaction Details using (TransactionScope scope = new TransactionScope()) { int tranasctionID = -1; //Create a boolean Value and Insert Transaction bool w = tDAL.Insert_Transction(transaction, out tranasctionID); //use for loop to Insert Transaction Details for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transcationDetailsBLL transcationDetails = new transcationDetailsBLL(); //Get the product Name and convert it to id string ProductName = transactionDT.Rows[i][0].ToString(); // Here was Errror before<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< productsBLL p = pDAL.GetDeaProductIDFromName(ProductName); transcationDetails.product_id = p.id; transcationDetails.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transcationDetails.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transcationDetails.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transcationDetails.dea_cust_id = dc.id; transcationDetails.added_date = DateTime.Now; transcationDetails.added_by = u.id; /*------------------------------------------------------------------------------------------------------------------ * ------------ PRODUCT INCREASE OR DECREASE OR UPDATE --------------------------------------------------------------- * -------------------------------------------------------------------------------------------------------------------*/ //Here Increase or Decrease Product Quantity based on Purchase or Sales string transactionType = lblTop.Text; //Lets check whether we are on Purchase or Sales bool x = false; if (transactionType == "Purchase") { //Increase the product x = pDAL.IncreaseProduct(transcationDetails.product_id, transcationDetails.qty); } else if (transactionType == "Sales") { //Decrease the Product Quantity x = pDAL.DecreaseProduct(transcationDetails.product_id, transcationDetails.qty); } /*--------------------------------------------------------------------------------------------------------------------------- * ------------------------PRODUCT INCREASE OR DECREASE OR UPDATE-------------------------------------------------------------- * ----------------------------------------------------------------------------------------------------------------------------*/ //Insert Transaction Details inside the database bool y = tdDAL.InsertTransactionDetail(transcationDetails); success = w && x && y; } if (success == true) { //Transaction Complete scope.Complete(); MessageBox.Show("Transaction Completed Sucessfully"); //Clear Data Grid View and all of the Textboxes dgvAddedProoducts.DataSource = null; dgvAddedProoducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { //Transaction Failed MessageBox.Show("Transaction Failed"); } } }
private void btnSave_Click(object sender, EventArgs e) { //get the value from purchase form first transactionBLL transaction = new transactionBLL(); transaction.type = lblTop.Text; //get the ID of dealer or customer here. //let get the name of dealer first string DeaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(DeaCustName); transaction.dea_cus_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); //Get the username of logged in user string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //lets create boolean variable and set it value to false/ bool success = false; //Actual Code to insert transaction and transaction detail using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; //create a boolean Value and insert transaction bool w = tDAL.InsertTransaction(transaction, out transactionID); //use for loop to insert transaction Detail for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the detail of products transactionDetailBLL transactionDetail = new transactionDetailBLL(); //Get the products name and convert ID string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; //Here Increase or Decrease product Quantity based on Pyurchase or Sales string transactionType = lblTop.Text; //let check weather we are in purchase or sales bool x = false; if (transactionType == "PURCHASE") { x = pDAL.Increaseproduct(transactionDetail.product_id, transactionDetail.qty); //Increase the product } else if (transactionType == "SALES") { //decrease the product x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //Insert transaction Detail in to DataBase bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } if (success == true) { //Transaction Completed scope.Complete(); //Code to Print the Bill of products DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n\r\n ANYSTORE PVT.LTD. \r\n\r\n"; printer.SubTitle = "Highfrezh, Ajoke \r\n phone: 01-41XXXXX \r\n\r\n"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: " + txtGrandTotal.Text + "\r\n\r\n" + "Thanks for doing business with us"; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvAddedProducts); MessageBox.Show("Transaction Complete successfully"); //Clear datagrid veiw and all the TextBoxs dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtProductSearch.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { //Transaction Failed MessageBox.Show("Transaction Failed"); } } }
private void btnSave_Click(object sender, EventArgs e) { // Get the values from Purchase and Sales form first transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; // Get the ID of Dealer or Customer here // Get the name of Dealer or customer first string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); // get the username of the loggedin user string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; // boolean variable and set it to false bool success = false; // insert transaction and transaction Details using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; //create a boolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction, out transactionID); // loop to insert transaction details for (int i = 0; i < transactionDT.Rows.Count; i++) { // get all the details of the product transactionDetailBLL transactionDetail = new transactionDetailBLL(); // get product name and convert it to id string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; // increase/decrease product Quantity based on purchase or sells string transactionType = lblTop.Text; // check if we are on purchase or sales page bool x = false; if (transactionType == "Purchase") { // increase the product qty x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { // decrease product quantity x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //insert transaction details in the database bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } if (success == true) { //Transaction complete scope.Complete(); // print the bill DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n\r\n SOPHIE'S STORE PVT. LTD. \r\n\r\n"; printer.SubTitle = "Bellevue, Washington \r\n Phone: 425-xxx-xxxx \r\n\r\n"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; //limit grand total to 2 decimal values decimal GTTwoDecimal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "%\r\n" + "Grand Total: " + GTTwoDecimal.ToString() + "\r\n" + "Thank you for doing buisness with us!"; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvAddedProducts); MessageBox.Show("Transaction completed Successfully."); //clear the data grid view and text boxes dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = ""; txtRate.Text = ""; txtQty.Text = ""; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { //Transaction Failed MessageBox.Show("Transaction Failed."); } } }
private void btnSave_Click(object sender, EventArgs e) { transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); string username = frmLogin.loggedIn; userBLL u = uDAL.GetIdFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; bool success = false; using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; bool w = tDAL.Insert_Transaction(transaction, out transactionID); for (int i = 0; i < transactionDT.Rows.Count; i++) { transactionDetailBLL transactionDetail = new transactionDetailBLL(); string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; string transactionType = lblTop.Text; bool x = false; if (transactionType == "Purchase") { x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } if (success == true) { scope.Complete(); //Code to Print Bill DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n\r\n TEAM ANTIVIRUS PVT. LTD. \r\n\r\n"; printer.SubTitle = "Dhaka, Bangladesh \r\n Phone: 017xxxxxxxx \r\n\r\n"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT:" + txtVat.Text + "% \r\n" + "Grand Total:" + txtGrandTotal.Text + "\r\n\r\n" + "Thank You"; printer.FooterSpacing = 15; printer.PrintDataGridView(pnldataGridView); MessageBox.Show("Transaction Completed Successfully"); pnldataGridView.DataSource = null; pnldataGridView.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtProductSearch.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; txtVat.Text = "0"; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtGrandTotal.Text = "0"; txtDiscount.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { MessageBox.Show("Transaction Failed"); } } }
private void btnSave_Click(object sender, EventArgs e) { //get the details from the Purchasesale form transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; //get the id of dealer or customer //get the name of dealer or customer string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); //Get the username of logged in user string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //create a Boolean variable and set its value to false bool success = false; //Actual code to insert Transaction and transaction details using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; //boolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction, out transactionID); //use for loop to insert Transaction Details for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transactionDetailBLL transactionDetail = new transactionDetailBLL(); //get the product name and convert it to id string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; //insert transaction details inside the database bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && y; } if (success == true) { //transaction complete scope.Complete(); MessageBox.Show("Transaction Complete Sucessfull."); //clear data gridview and textbox dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { //Transaction failed MessageBox.Show("Transaction failed."); } } }
private void btnCancel_Click(object sender, EventArgs e) { //validation if (decimal.Parse("0" + txtCheque.Text) > 0 && txtChequeNo.Text.Length < 2) { MessageBox.Show("Please enter a cheque no."); } //to do cancell bills //Get the Values from PurchaseSales Form First transactionsBLL transaction = new transactionsBLL(); if (lblTop.Text == "Sales") { transaction.type = "CRN"; } else if (lblTop.Text == "Purchase") { transaction.type = "RTS"; } //Get the ID of Dealer or Customer Here //Lets get name of the dealer or customer first string deaCustName = cmbCustomer.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); //transaction.invoice_no = decimal.Parse(txtInvoiceNo.Text); transaction.invoice_no = decimal.Parse(tDAL.GetNextInvoiceNo(transaction.type).ToString()); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse("0" + txtGrandTotal.Text), 2); transaction.transaction_date = dtpBillDate.Value; transaction.tax = decimal.Parse("0" + txtVat.Text); transaction.discount = decimal.Parse("0" + txtDiscount.Text); transaction.cash = decimal.Parse("0" + txtCash.Text); transaction.card = decimal.Parse("0" + txtCard.Text); transaction.cheque = decimal.Parse("0" + txtCheque.Text); transaction.cheque_no = decimal.Parse("0" + txtChequeNo.Text); //Get the Username of Logged in user string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //Lets Create a Boolean Variable and set its value to false bool success = false; //Actual Code to Insert Transaction And Transaction Details using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; //Create aboolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction, out transactionID); //Use for loop to insert Transaction Details for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transactionDetailBLL transactionDetail = new transactionDetailBLL(); //Get the Product name and convert it to id string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.transastion_id = transactionID; transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][3].ToString()); transactionDetail.discount = decimal.Parse(transactionDT.Rows[i][4].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][5].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; //Here Increase or Decrease Product Quantity based on Purchase or sales string transactionType = lblTop.Text; //Lets check whether we are on Purchase or Sales bool x = false; if (transactionType == "Purchase") { //Decrease the Product coz RTS x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { //Increase the Product Quntiyt coz CRN x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //Insert Transaction Details inside the database bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } tDAL.UpdateInvNo(decimal.Parse(tDAL.GetNextInvoiceNo(transaction.type).ToString()), transaction.type); //tDAL.UpdateInvNo(decimal.Parse(txtInvoiceNo.Text), transaction.type); //update grand total if (success == true) { ////////////frmReport r = new frmReport(); ////////////r.DocId = 1; ////////////r.TrID = transactionID; ////////////r.ShowDialog(); //Transaction Complete scope.Complete(); //Code to Print Bill //to do print bills //DGVPrinter printer = new DGVPrinter(); //printer.Title = "\r\n\r\n\r\n ANYSTORE PVT. LTD. \r\n\r\n"; //printer.SubTitle = "Kathmandu, Nepal \r\n Phone: 01-045XXXX \r\n\r\n"; //printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; //printer.PageNumbers = true; //printer.PageNumberInHeader = false; //printer.PorportionalColumns = true; //printer.HeaderCellAlignment = StringAlignment.Near; //printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: " + txtGrandTotal.Text + "\r\n\r\n" + "Thank you for doing business with us."; //printer.FooterSpacing = 15; //printer.PrintDataGridView(dgvAddedProducts); //MessageBox.Show("Transaction Completed Sucessfully"); //Celar the Data Grid View and Clear all the TExtboxes dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); transactionDT.Rows.Clear(); txtSearchProduct.Text = ""; cmbItemName.Text = ""; TxtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtCash.Text = "0"; txtCard.Text = "0"; txtCheque.Text = "0"; txtChequeNo.Text = "0"; txtReturnAmount.Text = "0"; txtInvoiceNo.Text = (decimal.Parse(txtInvoiceNo.Text) + 1).ToString(); } else { //Transaction Failed MessageBox.Show("Transaction Failed"); } } }
private void btnSave_Click(object sender, EventArgs e) { transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; bool success = false; using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; bool w = tDAL.Insert_Transaction(transaction, out transactionID); for (int i = 0; i < transactionDT.Rows.Count; i++) { transactionDetailBLL transactionDetail = new transactionDetailBLL(); string ProductName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; string transactionType = lblTop.Text; bool x = false; if (transactionType == "Purchase") { x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && x && y; } if (success == true) { scope.Complete(); DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n\r\n ANYSTORE PVT. LTD. \r\n\r\n"; printer.SubTitle = "Kathmandu, Nepal \r\n Phone: 01-045XXXX \r\n\r\n"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount: " + txtDiscount.Text + "% \r\n" + "VAT: " + txtVat.Text + "% \r\n" + "Grand Total: " + txtGrandTotal.Text + "\r\n\r\n" + "Thank you for doing business with us."; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvAddedProducts); MessageBox.Show("ทำการบันทึกข้อมูลการซือ ขาย เรียบร้อยแล้ว"); dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; TxtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { MessageBox.Show("ไม่สามารถทำการบันทึกการซื้อ ขายได้! กรุณาลองใหม่อีกครั้ง"); } } }
private void btnSave_Click(object sender, EventArgs e) { //Get the values from form purchase Sales form First // we will create an objetct of Transactions Class transactionsBLL transaction = new transactionsBLL(); transaction.type = lblTop.Text; // Get the ID of Dealer or Customer Here // Lets get name of the dealer or customer first string deaCustName = txtName.Text; // here we have first written method in DeaCustDAL and now forwarding as DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); //Now we will refer the transaction transaction.dea_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVat.Text); transaction.discount = decimal.Parse(txtDiscount.Text); // Get the user name,for added by, get the user name string username = frmLogin.loggedIn; userBLL u = uDAL.GetIDFromUsername(username); // we need to passthistransaction transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //Lets create a Boolean variable and set its value to False bool success = false; //Actual Code to Insert Transaction and Transaction Details using (TransactionScope scope = new TransactionScope()) { int transactionID = 1; //Create a Boolean value and Insert Transaction bool w = tDAL.Insert_Transcation(transaction, out transactionID); //Use for loop to insert transaction details for (int i = 0; i < transactionDT.Rows.Count; i++) { // create all details of products transactionDetailBLL transactionDetail = new transactionDetailBLL(); // Get the product name and convert it to ID string productName = transactionDT.Rows[i][0].ToString(); productsBLL p = pDAL.GetproductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; // Here we will increase or decrease the quantity based on purchase or sales // we have created Methods to Increase and decrease Qty. // Here Increase or Decrease Product Qty based on Purchase or Sales // we wil lspecify it is Sales or Purchase. we wil lcreate a string variable string transactionType = lblTop.Text; //Lets Check we are on Purchase or Sales bool x = false; if (transactionType == "Purchase") { //Increase the product x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { //Decrease the Product Qty x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //Insert Transaction Details Inside the Database bool y = tdDAL.InsertTranscationDetail(transactionDetail); success = w && y && x; } if (success == true) { // transaction complete scope.Complete(); MessageBox.Show("Transaction completed Successfully"); dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0"; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVat.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { MessageBox.Show("This Transaction Has Not Been Completed and Failed"); } } }
private void BtnSave_Click(object sender, EventArgs e) { //Get the values from Purchase from frst transactionBLL transaction = new transactionBLL(); transaction.type = lblTop.Text; //Get the ID of dealer or customer her //lets get name of the dealer or customer first string deaCustName = txtName.Text; DeaCustBLL dc = dcDAL.GetDeaCustIDFromName(deaCustName); transaction.dea_cust_id = dc.id; transaction.grandTotal = decimal.Parse(txtGrandTotal.Text); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtVAT.Text); transaction.discount = decimal.Parse(txtDiscount.Text); //Get the username logged in user string username = frmLogin.loggedIn; userBLL u = uDal.GetIDFromUsername(username); transaction.added_by = u.id; transaction.transactionDetails = transactionDT; bool success = false; //Actual code to insert transaction and transaction details using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; ///create boolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction, out transactionID); //User for lopping transaction detaio for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transaction_detailBLL transactionDetail = new transaction_detailBLL(); //Get the Product name and convert it to id string Productname = txtProductName.Text; productsBLL p = pDAL.GetProductIDFromName(ProductName); transactionDetail.product_id = p.id; transactionDetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 3); transactionDetail.dea_cust_id = dc.id; transactionDetail.added_date = DateTime.Now; transactionDetail.added_by = u.id; //Here increase or Decrease Product Quantitiy based on Purchase or sales string transactionType = lblTop.Text; //Lets check wheather we are on purchase or sales bool x = false; if (transactionType == "Purchase") { x = pDAL.IncreaseProduct(transactionDetail.product_id, transactionDetail.qty); } else if (transactionType == "Sales") { //Decrease the Product Quantitiy x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty); } //Insert Transaction Detail inside the Databsae bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && y; } if (success == true) { //Transaction Completed scope.Complete(); //Code to print bill DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\n ANYSTORE PVT. LTD."; printer.SubTitle = "Jepara, Suwawal \r\n Phone: 0895386989706"; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount :" + txtDiscount.Text + "% \r\n " + "VAT:" + txtVAT.Text + "% \r\n" + "Grand Total:" + "r\n" + "Thank you for doing buisness with us "; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvAddedProducts); MessageBox.Show("Transaction Completed Successfully"); dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtProductName.Text = ""; txtInventory.Text = ""; txtRate.Text = ""; txtQty.Text = "0"; txtSubTotal.Text = "0"; txtDiscount.Text = "0"; txtVAT.Text = "0"; txtGrandTotal.Text = "0"; txtPaidAmount.Text = "0"; txtReturnAmount.Text = "0"; } else { MessageBox.Show("Transaction Failed "); } } }