private void txtDiscount_TextChanged(object sender, EventArgs e) { try { string value = txtDiscount.Text; if (value == "") { MassageBox mb = new MassageBox("Please Enter Discount", MsgType.retry); mb.Show(); //MessageBox.Show("Please Enter Discount First!!!..."); } else { decimal subtotal = decimal.Parse(txtSubTotal.Text); decimal discount = decimal.Parse(txtDiscount.Text); decimal grandTotal = ((100 - discount) / 100) * subtotal; txtGrandTotal.Text = grandTotal.ToString(); } }catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }
private void btnUpdate_Click(object sender, EventArgs e) { p.Id = int.Parse(txtProductID.Text); p.name = txtName.Text; p.category = cmbCategory.Text; p.description = txtDescription.Text; p.rate = decimal.Parse(txtRate.Text); p.added_date = DateTime.Now; string loggedUsr = frmLogin.loggedIn; userBLL usr = udal.GetIdFromUsername(loggedUsr); p.added_by = usr.Id; bool success = pdal.Update(p); if (success == true) { MassageBox mb = new MassageBox("Updated", MsgType.update); mb.Show(); ///MessageBox.Show("Product Updated Successfully..."); Clear(); DataTable dt = pdal.Select(); dgvProducts.DataSource = dt; } else { MassageBox mb = new MassageBox("Update Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed To Update Product!!!...Try again..."); } }
private void btnUpdate_Click(object sender, EventArgs e) { c.Id = int.Parse(txtCategoryID.Text); c.title = txtTitle.Text; c.discription = txtDescription.Text; c.added_date = DateTime.Now; string loggedUser = frmLogin.loggedIn; userBLL usr = udal.GetIdFromUsername(loggedUser); c.added_by = usr.Id; bool succes = dal.Update(c); if (succes == true) { MassageBox mb = new MassageBox("Updated", MsgType.update); mb.Show(); //MessageBox.Show("Categoty Updated Succesfully"); Clear(); DataTable dt = dal.Select(); dgvCategories.DataSource = dt; } else { MassageBox mb = new MassageBox("Update Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed To Update Catogory!!!...Try Again"); } }
private void btnDelete_Click(object sender, EventArgs e) { try { u.Id = Convert.ToInt32(txtUSERID.Text); bool success = dal.Delete(u); if (success == true) { MassageBox mb = new MassageBox("Deleted", MsgType.delete); mb.Show(); //MessageBox.Show("User Details Deleted Successfully!!!"); clear(); } else { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Fail to Delete!!!"); } DataTable dt = dal.Select(); dgvUser.DataSource = dt; } catch (Exception) { MassageBox mb = new MassageBox("Select User First!!!", MsgType.retry); mb.Show(); } }
private void btnAdd_Click(object sender, EventArgs e) { c.title = txtTitle.Text; c.discription = txtDescription.Text; c.added_date = DateTime.Now; string loggedUser = frmLogin.loggedIn; userBLL usr = udal.GetIdFromUsername(loggedUser); c.added_by = loggedUser; if (txtTitle.Text == "" || txtDescription.Text == "") { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); } else { bool succes = dal.Insert(c); if (succes == true) { MassageBox mb = new MassageBox("Added Success", MsgType.success); mb.Show(); //MessageBox.Show("New Categoty Inserted Succesfully"); Clear(); DataTable dt = dal.Select(); dgvCategories.DataSource = dt; } else { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed To Insert New Catogory!!!...Try Again"); } } }
private void btnDelete_Click(object sender, EventArgs e) { try { p.Id = int.Parse(txtProductID.Text); bool success = pdal.Delete(p); if (success == true) { MassageBox mb = new MassageBox("Deleted", MsgType.delete); mb.Show(); //MessageBox.Show("Product Deleted Successfull..."); Clear(); DataTable dt = pdal.Select(); dgvProducts.DataSource = dt; } else { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed to Delete Product...!!! Try again..."); } } catch (Exception) { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); } }
private void cancel_Click(object sender, EventArgs e) { try { tdbll.Id = int.Parse(txtRate.Text); bool succes = tdDAL.Delete(tdbll); if (succes == true) { MassageBox mb = new MassageBox("Removed", MsgType.delete); mb.Show(); //MessageBox.Show("Categoty Deleted Succesfully"); // Clear(); DataTable dt = tdDAL.Select(); dgvAddedProducts.DataSource = dt; } else { MassageBox mb = new MassageBox("Remove Failed", MsgType.retry); mb.Show(); // MessageBox.Show("Failed to Delete Categorie...!!! Try Again"); } } catch (Exception) { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); } }
private void btnDelete_Click(object sender, EventArgs e) { try { c.Id = int.Parse(txtCategoryID.Text); bool succes = dal.Delete(c); if (succes == true) { MassageBox mb = new MassageBox("Deleted", MsgType.delete); mb.Show(); //MessageBox.Show("Categoty Deleted Succesfully"); Clear(); DataTable dt = dal.Select(); dgvCategories.DataSource = dt; } else { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); // MessageBox.Show("Failed to Delete Categorie...!!! Try Again"); } } catch (Exception) { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); } }
private void btnUpdate_Click(object sender, EventArgs e) { u.Id = Convert.ToInt32(txtUSERID.Text); u.first_name = txtFirstName.Text; u.last_name = txtLastName.Text; u.email = txtEmail.Text; u.username = txtUserName.Text; u.password = txtPassword.Text; u.contact = txtContact.Text; u.address = txtAddress.Text; u.gender = comboGender.Text; u.user_type = comboUserType.Text; u.added_date = DateTime.Now; u.added_by = 1; bool success = dal.Update(u); if (success == true) { MassageBox mb = new MassageBox("Updated", MsgType.update); mb.Show(); //MessageBox.Show("User Details Updated Successfully!!!"); clear(); } else { MassageBox mb = new MassageBox("Update Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Fail to Updated!!!"); } DataTable dt = dal.Select(); dgvUser.DataSource = dt; }
private void btnUpdate_Click(object sender, EventArgs e) { dc.Id = int.Parse(txtDlr_CustID.Text); 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 loggedUser = frmLogin.loggedIn; userBLL usr = uDal.GetIdFromUsername(loggedUser); dc.added_by = usr.Id; bool succes = dcdal.Update(dc); if (succes == true) { MassageBox mb = new MassageBox("Updated", MsgType.update); mb.Show(); // MessageBox.Show("Dealer and Customer Updated Succesfully"); Clear(); DataTable dt = dcdal.Select(); dgvDlr_Customer.DataSource = dt; } else { MassageBox mb = new MassageBox("Update Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed To Update Dealer and Customer!!!...Try Again"); } }
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 txtPaidAmount_TextChanged(object sender, EventArgs e) { try { string paid = txtPaidAmount.Text; if (paid == "") { MassageBox mb = new MassageBox("Enter Paid Amount", MsgType.retry); mb.Show(); //MessageBox.Show("Please Enter Paid Amount First...!!!"); } else { //decimal returnVal = decimal.Parse(txtReturnAmount.Text); decimal pid = decimal.Parse(txtPaidAmount.Text); decimal gt = decimal.Parse(txtGrandTotal.Text); decimal ret = (pid - gt); txtReturnAmount.Text = ret.ToString(); } } catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }
private void txtVat_TextChanged(object sender, EventArgs e) { try { string check = txtGrandTotal.Text; if (check == "") { MassageBox mb = new MassageBox("Please Enter Discount", MsgType.retry); mb.Show(); //MessageBox.Show("Input Discount First to Calculate Grand Total...!!!"); } else { decimal previousGT = decimal.Parse(txtGrandTotal.Text); decimal vat = decimal.Parse(txtVat.Text); decimal grandTotalWithVat = ((100 + vat) / 100) * previousGT; txtGrandTotal.Text = grandTotalWithVat.ToString(); } } catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }
private void btnLogin_Click(object sender, EventArgs e) { l.username = txtUserName.Text.Trim(); l.password = txtPasword.Text.Trim(); l.user_type = cmbUserType.selectedValue.Trim(); bool success = dal.loginCheck(l); if (success == true) { loggedIn = l.username; switch (l.user_type) { case "Admin": { rfmAdminDashboard admin = new rfmAdminDashboard(); admin.adlg = this; admin.Show(); this.Hide(); } break; case "Cashier": { frmUserDashboard user = new frmUserDashboard(); user.uslg = this; user.Show(); this.Hide(); } break; case "StoreKeeper": { frmStKeeperDashboard stk = new frmStKeeperDashboard(); stk.stlg = this; stk.Show(); this.Hide(); } break; default: { MassageBox mb = new MassageBox("Invalid User Type", MsgType.clear); mb.Show(); //MessageBox.Show("Invalid User Type!!!"); } break; } } else { MassageBox mb = new MassageBox("Login Failed\nRetry", MsgType.retry); mb.Show(); //MessageBox.Show("Login Fail !!!....Try Again"); } }
private void btnClear_Click(object sender, EventArgs e) { MassageBox mb = new MassageBox("Cleared", MsgType.clear); mb.Show(); txtCategoryID.Text = ""; txtDescription.Text = ""; txtSearch.Text = ""; txtTitle.Text = ""; }
private void btnClear_Click(object sender, EventArgs e) { MassageBox mb = new MassageBox("Cleared", MsgType.clear); mb.Show(); txtProductID.Text = ""; txtName.Text = ""; txtDescription.Text = ""; txtRate.Text = ""; txtSearch.Text = ""; txtMin.Text = ""; }
private void btnClear_Click(object sender, EventArgs e) { MassageBox mb = new MassageBox("Cleared", MsgType.clear); mb.Show(); txtDlr_CustID.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearch.Text = ""; }
private void btnClear_Click(object sender, EventArgs e) { MassageBox mb = new MassageBox("Cleared", MsgType.clear); mb.Show(); txtUSERID.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtEmail.Text = ""; txtUserName.Text = ""; txtPassword.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; comboGender.Text = ""; comboUserType.Text = ""; }
private void btnAdd_Click(object sender, EventArgs e) { u.first_name = txtFirstName.Text; u.last_name = txtLastName.Text; u.email = txtEmail.Text; u.username = txtUserName.Text; u.password = txtPassword.Text; u.contact = txtContact.Text; u.address = txtAddress.Text; u.gender = comboGender.Text; u.user_type = comboUserType.Text; u.added_date = DateTime.Now; string loggedUser = frmLogin.loggedIn; userBLL usr = dal.GetIdFromUsername(loggedUser); u.added_by = loggedUser; if (u.user_type == "") { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); } else { bool success = dal.Insert(u); if (success == true) { MassageBox mb = new MassageBox("Added Success", MsgType.success); mb.Show(); //MessageBox.Show("User Added Successfully!!!"); clear(); } else { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Fail to Added!!!"); } } DataTable dt = dal.Select(); dgvUser.DataSource = dt; }
private void btnDelete_Click(object sender, EventArgs e) { dc.Id = int.Parse(txtDlr_CustID.Text); bool succes = dcdal.Delete(dc); if (succes == true) { MassageBox mb = new MassageBox("Deleted", MsgType.delete); mb.Show(); //MessageBox.Show("Dealer/Customer Deleted Succesfully"); Clear(); DataTable dt = dcdal.Select(); dgvDlr_Customer.DataSource = dt; } else { MassageBox mb = new MassageBox("Delete Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed to Delete Dealer/Customer...!!! Try Again"); } }
private void ADD_Click(object sender, EventArgs e) { try { string productName = txtNamePro.Text; decimal rate = decimal.Parse(txtRate.Text); decimal qty = decimal.Parse(txtQty.Text); decimal Total = rate * qty; decimal subTotal = decimal.Parse(txtSubTotal.Text); subTotal = subTotal + Total; if (productName == "") { MassageBox mb = new MassageBox("Select The Product", MsgType.retry); mb.Show(); //MessageBox.Show("Select The Product First and Try Again..."); } else { transactionDT.Rows.Add(productName, rate, qty, Total); dgvAddedProducts.DataSource = transactionDT; txtSubTotal.Text = subTotal.ToString(); txtSearchProduct.Text = ""; txtNamePro.Text = ""; txtInventory.Text = "0.00"; txtRate.Text = "0.00"; txtQty.Text = "0.00"; } } catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }
private void btnAdd_Click(object sender, EventArgs e) { try { p.name = txtName.Text; p.category = cmbCategory.Text; p.description = txtDescription.Text; p.rate = decimal.Parse(txtRate.Text); p.qty = 0; p.min = int.Parse(txtMin.Text); p.added_date = DateTime.Now; string loggedUsr = frmLogin.loggedIn; userBLL usr = udal.GetIdFromUsername(loggedUsr); p.added_by = loggedUsr; bool success = pdal.Insert(p); if (success == true) { MassageBox mb = new MassageBox("Added Success", MsgType.success); mb.Show(); //MessageBox.Show("Product Added Successfully..."); Clear(); DataTable dt = pdal.Select(); dgvProducts.DataSource = dt; } else { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Failed To Added Product!!!...Try again..."); } } catch (Exception) { MassageBox mb = new MassageBox("Added Failed", MsgType.retry); mb.Show(); } }
private void ADD_Click(object sender, EventArgs e) { try { /*if(transactionDT.Rows.Count != 0) * { * SqlConnection conn = new SqlConnection(myconnstring); * conn.Open(); * string sqlTrunc = "TRUNCATE TABLE " + transactionDT; * SqlCommand cmd = new SqlCommand(sqlTrunc, conn); * cmd.ExecuteNonQuery(); * conn.Close(); * }*/ int a = int.Parse(txtInventory.Text); int q = int.Parse(txtQty.Text); int i = int.Parse(txtInventory.Text); int min = int.Parse(txtmin.Text); int check; check = a - q; if (check <= min && lblTop.Text == "SALES") { Alert at = new Alert("Minimum Quntity Reached", AlertType.warning); at.Show(); } if (q > i && lblTop.Text == "SALES") { decimal qt = Math.Round(decimal.Parse(txtQty.Text), 2); MassageBox mb = new MassageBox("Exceed Stock!!!", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } else { string productName = txtNamePro.Text; decimal rate = decimal.Parse(txtRate.Text); decimal qty = decimal.Parse(txtQty.Text); decimal Total = rate * qty; decimal subTotal = decimal.Parse(txtSubTotal.Text); subTotal = subTotal + Total; if (productName == "") { MassageBox mb = new MassageBox("Select The Product", MsgType.retry); mb.Show(); //MessageBox.Show("Select The Product First and Try Again..."); } else { transactionDT.Rows.Add(productName, rate, qty, Total); dgvAddedProducts.DataSource = transactionDT; txtSubTotal.Text = subTotal.ToString(); txtSearchProduct.Text = ""; txtNamePro.Text = ""; txtInventory.Text = "0"; txtRate.Text = "0.00"; txtQty.Text = "0"; } } } catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }
private void btnSave_Click(object sender, EventArgs e) { try { 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(); MassageBox mb = new MassageBox("Transaction Success", MsgType.success); mb.Show(); //MessageBox.Show("Transaction Completed Successfully..."); dgvAddedProducts.DataSource = null; dgvAddedProducts.Rows.Clear(); txtSearch.Text = ""; txtName.Text = ""; txtEmail.Text = ""; txtContact.Text = ""; txtAddress.Text = ""; txtSearchProduct.Text = ""; txtNamePro.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 { MassageBox mb = new MassageBox("Transaction Failed", MsgType.retry); mb.Show(); //MessageBox.Show("Transaction Failed...!!! Try again"); } } }catch (Exception) { MassageBox mb = new MassageBox("ERROR", MsgType.clear); mb.BackColor = Color.Crimson; mb.Show(); } }