private void cmbUserType_SelectedIndexChanged(object sender, EventArgs e) { btnViewSalesOrder.Enabled = false; btnViewReceiveOrder.Enabled = false; btnView.Enabled = false; btnShopping.Enabled = false; btnRO.Enabled = false; btnPO.Enabled = false; if (cmbUserType.SelectedIndex == 0) { cmbUserName.DataSource = GeneralMethods.GetCustomers(); cmbUserName.DisplayMember = "cname"; cmbUserName.ValueMember = "cid";; cmbUserName.SelectedIndex = -1; cmbUserName.Text = "Select a Customer"; btnNewUser.Enabled = true; } else if (cmbUserType.SelectedIndex == 1) { cmbUserName.DataSource = GeneralMethods.GetUsers(); cmbUserName.DisplayMember = "uname"; cmbUserName.ValueMember = "uid"; cmbUserName.SelectedIndex = -1; cmbUserName.Text = "Select an Administrator"; btnNewUser.Enabled = true; } else if (cmbUserType.SelectedIndex < 0) { cmbUserType.Text = "Select User Type"; cmbUserName.DataSource = null; btnNewUser.Enabled = false; } }
private void btnAdd_Click(object sender, EventArgs e) { int q; if (String.IsNullOrWhiteSpace(txtQuantity.Text)) { MessageBox.Show("Please enter quantity first!", "Error"); } else if (!(Int32.TryParse(txtQuantity.Text, out q))) { MessageBox.Show("Please enter valid quantity!", "Error!"); } else { int CheckID = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[0].Value); foreach (DataRow row in CartTable.Rows) { if (Convert.ToInt32(row[0]) == CheckID) { int Pid = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[0].Value); int Rotquantity = Convert.ToInt32(txtQuantity.Text); int AvailableQuantity = (int)(dgvProducts.SelectedRows[0].Cells[5].Value); if (Rotquantity > AvailableQuantity) { if (MessageBox.Show(GeneralMethods.GetProductNameByID(Pid) + " is not available in the desired quantity. Do you wish to add the complete quantity avaialable i.e " + AvailableQuantity + " to the cart?", "Oops", MessageBoxButtons.YesNo) == DialogResult.Yes) { Rotquantity = AvailableQuantity; //float a = Convert.ToSingle(dgvProducts.SelectedRows[0].Cells[4].Value); ////float b = Convert.ToInt32(txtQuantity.Text); //float rottotalamount = a * Rotquantity; //string pname = ((GeneralMethods.GetProductByID(Pid)).Rows[0][2]).ToString(); //CartTable.Rows.Add(Pid, pname, Rotquantity, rottotalamount); int Amount = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[4].Value); //int Quantity = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[5].Value); int Quantity = AvailableQuantity; float Price = Amount; //int Profit = GeneralMethods.GetProfitRate(CheckID); //float SellingPrice = ((Price / 100) * Profit) + Price; row[2] = Quantity; row[3] = Price * Quantity; //dgvProducts.SelectedRows[0].Cells[5].Value = (Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[5].Value)) - (Convert.ToInt32(txtQuantity.Text)); return; //break; } } else { int Amount = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[4].Value); int Quantity = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[5].Value); //int Quantity = AvailableQuantity; float Price = Amount; //int Profit = GeneralMethods.GetProfitRate(CheckID); //float SellingPrice = ((Price / 100) * Profit) + Price; row[2] = txtQuantity.Text; row[3] = Price * Convert.ToInt32(txtQuantity.Text); //dgvProducts.SelectedRows[0].Cells[5].Value = (Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[5].Value)) - (Convert.ToInt32(txtQuantity.Text)); return; } } } int pid = (int)(dgvProducts.SelectedRows[0].Cells[0].Value), rotquantity = Convert.ToInt32(txtQuantity.Text); int availableQuantity = (int)(dgvProducts.SelectedRows[0].Cells[5].Value); if (rotquantity > availableQuantity) { if (availableQuantity == 0) { MessageBox.Show("Sorry! The selected product is Out of Stock..\nPlease Try again later..", "Sorry!"); } else if (MessageBox.Show(GeneralMethods.GetProductNameByID(pid) + " is not available in the desired quantity. Do you wish to add the complete quantity avaialable i.e " + availableQuantity + " to the cart?", "Oops", MessageBoxButtons.YesNo) == DialogResult.Yes) { rotquantity = availableQuantity; float a = Convert.ToSingle(dgvProducts.SelectedRows[0].Cells[4].Value); //float b = Convert.ToInt32(txtQuantity.Text); float rottotalamount = a * rotquantity; string pname = ((GeneralMethods.GetProductByID(pid)).Rows[0][2]).ToString(); CartTable.Rows.Add(pid, pname, rotquantity, rottotalamount); } } else { float a = Convert.ToSingle(dgvProducts.SelectedRows[0].Cells[4].Value); //float b = Convert.ToInt32(txtQuantity.Text); float rottotalamount = a * rotquantity; string pname = ((GeneralMethods.GetProductByID(pid)).Rows[0][2]).ToString(); CartTable.Rows.Add(pid, pname, rotquantity, rottotalamount); //dgvProducts.SelectedRows[0].Cells[5].Value = (Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[5].Value)) - (Convert.ToInt32(txtQuantity.Text)); } } }
private void btnSubmit_Click(object sender, EventArgs e) { GeneralMethods.AddUser(txtNewUserName.Text); MessageBox.Show("Member was added successfully!"); this.Close(); }
private void btnAddProduct_Click(object sender, EventArgs e) { string ProductName, Description; int CategoryID = 0, VendorID = 0, ProfitRate; bool ValidSubmission = true; if (String.IsNullOrWhiteSpace(cmbCategory.Text)) { ValidSubmission = false; MessageBox.Show("Please select a category for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(cmbVendor.Text)) { ValidSubmission = false; MessageBox.Show("Please select a vendor for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(txtName.Text)) { ValidSubmission = false; MessageBox.Show("Please enter a name for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(txtProfit.Text)) { ValidSubmission = false; MessageBox.Show("Please enter a profit rate for the product!", "Error"); } else if (!(Int32.TryParse(txtProfit.Text, out ProfitRate))) { ValidSubmission = false; MessageBox.Show("Please enter a valid profit rate!", "Error"); } if (!(GeneralMethods.CheckCategory(cmbCategory.Text))) { if (MessageBox.Show("Are you sure you want to add a new category?", "Add New Category", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { GeneralMethods.AddCategory(cmbCategory.Text); MessageBox.Show("Category added successfuly!", "Success"); } CategoryID = GeneralMethods.GetCategory(cmbCategory.Text); } else if (GeneralMethods.CheckCategory(cmbCategory.Text)) { CategoryID = GeneralMethods.GetCategory(cmbCategory.Text); } if (!(GeneralMethods.CheckVendor(cmbVendor.Text))) { if (MessageBox.Show("Are you sure you want to add a new vendor?", "Add New Vendor", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { GeneralMethods.AddVendor(cmbVendor.Text); MessageBox.Show("Vendor added successfuly!", "Success"); } VendorID = GeneralMethods.GetVendor(cmbVendor.Text); } else if (GeneralMethods.CheckVendor(cmbVendor.Text)) { VendorID = GeneralMethods.GetVendor(cmbVendor.Text); } if (ValidSubmission) { ProductName = txtName.Text; ProfitRate = Convert.ToInt32(txtProfit.Text); Description = rtxtDescription.Text; GeneralMethods.AddProduct(CategoryID, VendorID, ProductName, ProfitRate, Description); GeneralMethods.CreatePurchaseOrderMethod(); MessageBox.Show("Product added successfully!", "Success"); //int id = GeneralMethods.GetPurchaseOrderID(); //GeneralMethods.CreatePurchaseOrderTransaction(id, VendorID, GeneralMethods.GetProductID(), 10); } }
public Edit_Categories() { InitializeComponent(); CategoriesData.DataSource = GeneralMethods.GetCategories(); dgvCategories.DataSource = CategoriesData; }
private void btnCreate_Click(object sender, EventArgs e) { if (ProductsReceivedTable.Rows.Count != 0) { //if (GeneralMethods.CreateNewReceieveOrder()) //{ GeneralMethods.CreateReceiveOrder(UserID); ROID = GeneralMethods.GetReceiveOrderID(); //GeneralMethods.CreatePurchaseOrder(); foreach (DataRow row in ProductsReceivedTable.Rows) { int pid = (Convert.ToInt32(row["ID"])); int quantity = (Convert.ToInt32(row[2])); float amount = (Convert.ToSingle(row[3])); GeneralMethods.CreateReceiveOrderTransaction(ROID, UserID, pid, quantity, amount); float Price = amount / quantity; int Profit = GeneralMethods.GetProfitRate(pid); float SellingPrice = ((Price / 100) * Profit) + Price; int OldQuantity = GeneralMethods.GetQuantity(pid); GeneralMethods.UpdateProductQuantityAndPrice(pid, (quantity + OldQuantity), Price, SellingPrice); //if ((GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity) > 0) //{ // GeneralMethods.CreatePurchaseOrderAfterReceive(GeneralMethods.GetProductVendor(pid), pid, (GeneralMethods.GetPreviousPurchaseOrderQuantity(pid) - quantity)); //} } //DataTable LastPurchaseOrder = new DataTable(); //DataTable NewPurchaseOrder = new DataTable(); //LastPurchaseOrder = GeneralMethods.GetPurchaseOrderTransactionTable((GeneralMethods.GetPurchaseOrderID() - 1)); //NewPurchaseOrder = GeneralMethods.GetPurchaseOrderTransactionTable(GeneralMethods.GetPurchaseOrderID()); //foreach (DataRow row in LastPurchaseOrder.Rows) //{ // bool Present = false; // int VendorID = 0; // int Quantity = 0; // int pid = Convert.ToInt32(row["pid"]); // foreach (DataRow NewRow in NewPurchaseOrder.Rows) // { // int npid = Convert.ToInt32(NewRow["pid"]); // if (npid == pid) // { // Present = true; // break; // } // VendorID = Convert.ToInt32(row["vid"]); // Quantity = Convert.ToInt32(row["potquantity"]); // if (!Present) // { // GeneralMethods.CreatePurchaseOrderAfterReceive(VendorID, pid, Quantity); // } // } //} GeneralMethods.CreatePurchaseOrderMethod(); MessageBox.Show("Receive Order Successfully Created!", "Success!"); //} } else { MessageBox.Show("Please select some items first!", "Error!"); } }
private void dgvPurchaseOrdersTransactions_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (Convert.ToInt32(dgvPurchaseOrdersTransactions.SelectedRows[0].Cells[1].FormattedValue) == GeneralMethods.GetPurchaseOrderID()) { int POTID = Convert.ToInt32(dgvPurchaseOrdersTransactions.SelectedRows[0].Cells[0].FormattedValue); int Quantity = Convert.ToInt32(dgvPurchaseOrdersTransactions.SelectedRows[0].Cells[4].FormattedValue); Form UpdateQuantityForm = new Update_Purchase_Order_Transaction_Quantity(POTID, Quantity); UpdateQuantityForm.ShowDialog(); int POID = Convert.ToInt32(dgvPurchaseOrdersTransactions.SelectedRows[0].Cells[1].FormattedValue); TransactionData.DataSource = GeneralMethods.GetPurchaseOrderTransaction(POID); } else { MessageBox.Show("Sorry! Only the latest Purchase Order can be edited", "Error"); } }
//public static void CreatePurchaseOrderAfterReceive(int VendorID, int ProductID, int Quantity) //{ // if (GeneralMethods.CreateNewPurchaseOrder()) // { // DataTable Products = new DataTable(); // Products = GeneralMethods.GetProductsTable(); // GeneralMethods.CreatePurchaseOrder(); // int ID = GeneralMethods.GetPurchaseOrderID(); // GeneralMethods.CreatePurchaseOrderTransaction(ID, VendorID, ProductID, Quantity); // } // else if (!(GeneralMethods.CreateNewPurchaseOrder())) // { // int ID = GeneralMethods.GetPurchaseOrderID(); // DataTable Products = new DataTable(); // DataTable PurchaseOrders = new DataTable(); // DataTable Transactions = new DataTable(); // Products = GeneralMethods.GetProductsTable(); // PurchaseOrders = GeneralMethods.GetPurchaseOrders(); // Transactions = GeneralMethods.GetPurchaseOrderTransactionTable(ID); // GeneralMethods.CreatePurchaseOrderTransaction(ID, VendorID, ProductID, Quantity); // //GeneralMethods.CreatePurchaseOrder(); // } //} public static void CreatePurchaseOrderMethod() { //if (GeneralMethods.CreateNewPurchaseOrder()) //{ DataTable Products = new DataTable(); Products = GeneralMethods.GetProductsTable(); //GeneralMethods.CreatePurchaseOrder(); //int ID = GeneralMethods.GetPurchaseOrderID(); int j = GetMaxVendorID(); if (j < 1) { return; } for (int i = 1; i <= j; i++) { bool CreateOrder = true; foreach (DataRow row in Products.Rows) { if ((Convert.ToInt32(row["quantity"])) <= 5 && (Convert.ToInt32(row["vid"])) == i) { //int ID = 0; if (CreateOrder) { GeneralMethods.CreatePurchaseOrder(i); CreateOrder = false; } int ID = GetPurchaseOrderID(); int PID = (Convert.ToInt32(row["pid"])); int VID = (Convert.ToInt32(row["vid"])); int Quantity = 10; GeneralMethods.CreatePurchaseOrderTransaction(ID, PID, Quantity); } } } //} //else if (!(GeneralMethods.CreateNewPurchaseOrder())) //{ // int ID = GeneralMethods.GetPurchaseOrderID(); // DataTable Products = new DataTable(); // DataTable PurchaseOrders = new DataTable(); // DataTable Transactions = new DataTable(); // Products = GeneralMethods.GetProductsTable(); // PurchaseOrders = GeneralMethods.GetPurchaseOrders(); // Transactions = GeneralMethods.GetPurchaseOrderTransactionTable(ID); // //GeneralMethods.CreatePurchaseOrder(); // foreach (DataRow prow in Products.Rows) // { // if (((int)(prow["quantity"])) <= 5) // { // bool NotExists = true; // int tquantity = 0; // int tid = 0; // foreach (DataRow trow in Transactions.Rows) // { // if ((int)prow["pid"] == (int)trow["pid"]) // { // NotExists = false; // tquantity = ((int)(trow["potquantity"])); // tid = ((int)trow["potid"]); // break; // } // } // if (NotExists) // { // int PID = ((int)(prow["pid"])); // int VID = ((int)(prow["vid"])); // int Quantity = 10; // GeneralMethods.CreatePurchaseOrderTransaction(ID, VID, PID, Quantity); // } // //else if (!(NotExists)) // //{ // // if(tquantity < 10) // // { // // int PID = ((int)(prow["pid"])); // // int VID = ((int)(prow["vid"])); // // UpdatePurchaseOrderTransaction(tid, GetPurchaseOrderID(), VID, PID, 10); // // } // //} // } // } //} }
public static void CreateReceiveOrderMethod() { if (GeneralMethods.CreateNewReceieveOrder()) { } }