private void btnAdd_Click(object sender, EventArgs e) { dc.type = cmbType.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; //getting id in added by field string loggedUser = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUser); //passing the id of logged in user in added by field dc.added_by = usr.id; //creating boolean method to insert data into database bool success = dcdal.Insert(dc); if (success == true) { MessageBox.Show("Dealer or Customer Added Successfully."); Clear(); //refresh data grid view DataTable dt = dcdal.Select(); dgvDeaCust.DataSource = dt; } else { MessageBox.Show("Failed to Add New Dealer or customer."); } }
private void btnAdd_Click(object sender, EventArgs e) { //get the values from form dc.type = cmbType.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; //Getting ID in Added by field string loggedUser = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUser); //passing the id of logged in user in added by field dc.added_by = usr.id; //Creating Boolean Method To insert data into database bool success = dcDal.Insert(dc); if (success == true) { //new category inserted successfull MessageBox.Show("Dealer or Customer Added Sucessfully."); Clear(); //Refresh Data grid view DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { //failed to insert MessageBox.Show("Dealer or Customer Failed ."); } }
private void btn_add_Click(object sender, EventArgs e) { string loggeddUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggeddUsr); dc.type = cmbType.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; dc.added_by = usr.id; bool success = dcDal.Insert(dc); if (success) { Clear(); DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { MessageBox.Show("Failed to insert new dealer/customer"); } }
private void btnAdd_Click(object sender, EventArgs e) { //Get the Values from Form dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; //Getting the ID to Logged in user and passign its value in dealer or cutomer module string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUsr); dc.added_by = usr.id; //Creating boolean variable to check whether the dealer or cutomer is added or not bool success = dcDal.Insert(dc); if (success == true) { //Dealer or Cutomer inserted successfully MessageBox.Show("Dealer or Customer Added Successfully"); Clear(); //Refresh Data Grid View DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { //failed to insert dealer or customer } }
private void btnAdd_Click(object sender, EventArgs e) { dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; string loggedUsr = frmLogin.loggedIn; userBLL usr = uDAL.GetIDFromUsername(loggedUsr); dc.added_by = usr.id; bool success = dcDal.Insert(dc); if (success == true) { MessageBox.Show("Dealer or Customer Added Successfully"); Clear(); DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { } }
private void btnAdd_Click(object sender, EventArgs e) { // get the values from form dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; // getting the loggedin user id and passing its value to deal or customer module string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUsr); dc.added_by = usr.id; // boolean variable to check if the dealer/customer is added or not bool success = dcDal.Insert(dc); if (success == true) { //dealer/customer is inserted successfully MessageBox.Show("Dealer or customer added Successfully"); Clear(); // refresh data grid view DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { //Failed to insert dealer /customer MessageBox.Show(""); } }
private void BtnADD_Click(object sender, EventArgs e) { 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 boolean to chec if the product is added successflly or not bool success = dal.Insert(d); if (success == true) { //Product Inserted successfully MessageBox.Show("Data Added Successfully"); Clear(); DataTable dt = dal.Select(); dgvDeaCust.DataSource = dt; } else { //Failed to ADD New Product MessageBox.Show("Failed to Add new Data"); Clear(); DataTable dt = dal.Select(); dgvDeaCust.DataSource = dt; } }
private void btnAdd_Click(object sender, EventArgs e) { dc.type = cmbDlrCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIdFromUsername(loggedUsr); dc.added_by = usr.Id; bool success = dcdal.Insert(dc); if (success == true) { MassageBox mb = new MassageBox("Added Success", MsgType.success); mb.Show(); //MessageBox.Show("Dealer/Customer Added Successfully..."); Clear(); DataTable dt = dcdal.Select(); dgvDlr_Customer.DataSource = dt; } else { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed to ADD Dealer/Customer...!!! Try Again.."); } }
private void button1_Click(object sender, EventArgs e) { //Getting all value form form dc.type = cmbType.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; //Getting the Id of the logged in User string loggedUser = frmLogin.loggedIn; userBLL usr = udal.GetIDFromUsername(loggedUser); dc.added_by = usr.id; //creating a boolean variable to check if desler and customer is added or not bool success = dcdal.Insert(dc); if (success == true) { //dealer or customer Added successfull MessageBox.Show("Dealer or Customer added successfully"); Clear(); //Refreshing the Data Grid view DataTable dt = dcdal.select(); dgvDeaCust.DataSource = dt; } else { //Failed to add Dealer or customer MessageBox.Show("Failed to add Dealer or Customer"); } }
private void btnAddCust_Click(object sender, EventArgs e) { dc.type = cmbtype.Text; dc.name = txtName.Text; dc.email = txtEMail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; string loggedIn = Login.loggedInUser; UserBLL usr = udal.getIdFromUserName(loggedIn); dc.added_by = usr.id; bool success = dcDal.Insert(dc); if (success == true) { Mymessage mymessage = new Mymessage("Data Successfully Inserted! "); mymessage.Show(); Clear(); DataTable dt = dcDal.Select(); GDVCustomer.DataSource = dt; } else { Mymessage mymessage = new Mymessage("Erroe While Inserting Data... "); mymessage.Show(); } }
private void btnAdd_Click(object sender, EventArgs e) { dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUsr); dc.added_by = usr.id; bool success = dcDal.Insert(dc); if (success == true) { MessageBox.Show("ทำการเพิ่ม Dealer หรือ Customer เรียบร้อยแล้ว"); Clear(); DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { MessageBox.Show("ไม่สามารถทำการเพิ่ม Dealer หรือ Customer ได้! กรุณาลองใหม่อีกครั้ง"); } }
private void btnAdd_Click(object sender, EventArgs e) { try { //get the values from form dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; //getting the ID to logged in user and passing its value in dealer customer module string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUsr); dc.added_by = usr.id; //creating boolean variable to check whether the dealer or customer is added or not bool success = dcDal.Insert(dc); if (success == true) { //dealer or customer added successfully MessageBox.Show("Dealer/Customer added successfully!"); Clear(); //refresh datagrid view DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { //failed to insert dealer or customer MessageBox.Show("Dealer/Customer adding failed!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } bool IsValidEmail(string email) { try { var addr = new System.Net.Mail.MailAddress(email); return(addr.Address == email); } catch { return(false); } } }
private void btnAdd_Click(object sender, EventArgs e) { // Get the values from all Text boxes and store in BLL dc.type = cmbDeaCust.Text; dc.name = txtName.Text; dc.email = txtEmail.Text; dc.contact = txtContact.Text; dc.address = txtAddress.Text; dc.added_date = DateTime.Now; // Getting ID of Logged In User and Passing its value in Dealer or Customer Module // we will get user name who is logged in string loggedUsr = frmLogin.loggedIn; userBLL usr = uDal.GetIDFromUsername(loggedUsr); // we will pass this value dc.added_by = usr.id; // create Boolean variable to check if the Dealer is added successfully or Not bool success = dcDal.Insert(dc); // if the product is added successfully then the value of success will be true or will be false. if (success == true) { // product inserted successfully MessageBox.Show("Dealer or Customer Inserted Successfully"); // we need to clear Text Boxes. we will write a method for this. // Calling the Clear Method Clear(); // Refresh the Data Grid View as well.For that we wil lcreate a data Table. DataTable dt = dcDal.Select(); dgvDeaCust.DataSource = dt; } else { // Falied to Insert MessageBox.Show("Product NOT Inserted Successfully"); } }
private void btnSave_Click(object sender, EventArgs e) { //Get the Values from PurchaseSales Form First transactionsBLL transaction = new transactionsBLL(); DeaCustBLL dc = new DeaCustBLL(); transaction.type = lblTop.Text; //Get the ID of or Dealer Customer Here //Lets get name of the dealer or customer first string deaCustName = txtName.Text; if (!string.IsNullOrEmpty(deaCustName)) { dc = dcDAL.GetDeaCustIDFromName(deaCustName); } else { DeaCustDAL dcd = new DeaCustDAL(); dc.type = "Walkin"; dc.name = "Walkin Customer"; dc.email = " "; dc.added_by = 4; dc.added_date = DateTime.Now; dcd.Insert(dc); // if customer / dealer name not exists its means Walkin Customer } 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; int branchId = int.Parse(frmLogin.branchId); userBLL u = uDAL.GetIDFromUsername(username, branchId); 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, frmLogin.branchId); 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, frmLogin.branchId); } else if (transactionType == "Sales") { //Decrease the Product Quntiyt x = pDAL.DecreaseProduct(transactionDetail.product_id, transactionDetail.qty, frmLogin.branchId); } //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 Falcon Soft PVT. LTD. \r\n\r\n"; printer.SubTitle = "Islamabad, Pakistan \r\n Phone: 03043487853 \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"); } } }