public void ShowSalesLines(DataGridView gv, DataGridViewColumn SalesLineIdGv, DataGridViewColumn ProductIdGv, DataGridViewColumn ProductNameGv, DataGridViewColumn LineNumberGv, DataGridViewColumn ProductPriceGv, DataGridViewColumn QuantityGv, DataGridViewColumn TotalCost, DataGridViewColumn Unit, int SalesNumber) { try { SqlCommand cmd; cmd = new SqlCommand("Usp_GetSalesLine", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SalesNumber", SalesNumber); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); SalesLineIdGv.DataPropertyName = dt.Columns["SalesLineID"].ToString(); ProductIdGv.DataPropertyName = dt.Columns["ID"].ToString(); LineNumberGv.DataPropertyName = dt.Columns["LineNumber"].ToString(); ProductNameGv.DataPropertyName = dt.Columns["ProductName"].ToString(); ProductPriceGv.DataPropertyName = dt.Columns["ProductCost"].ToString(); QuantityGv.DataPropertyName = dt.Columns["Quantity"].ToString(); TotalCost.DataPropertyName = dt.Columns["TotalCost"].ToString(); Unit.DataPropertyName = dt.Columns["Unit"].ToString(); gv.AutoGenerateColumns = false; gv.DataSource = dt; } catch (Exception) { MainClass.ShowMessage("Unable to Load Sales data", "Error", "Error"); } }
public void ShowCategories(DataGridView gv, DataGridViewColumn CategoryIdGv, DataGridViewColumn CategoryGv, DataGridViewColumn CategoryIsActiveGv, string Data = null) { try { SqlCommand cmd;//= new SqlCommand(); if (Data == null) { cmd = new SqlCommand("Usp_GetCategoryDetails", MainClass.con); } else { cmd = new SqlCommand("Usp_SearchCategoryDetails", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Data", Data); } cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); CategoryIdGv.DataPropertyName = dt.Columns["ID"].ToString(); CategoryGv.DataPropertyName = dt.Columns["Category Name"].ToString(); CategoryIsActiveGv.DataPropertyName = dt.Columns["Is Active"].ToString(); gv.DataSource = dt; } catch (Exception) { MainClass.ShowMessage("Unable to Load categories data", "Error", "Error"); } }
public int SaveReceiving(int PONumber, decimal ReceivingGrossCost) { try { using (TransactionScope tc = new TransactionScope()) { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("usp_Insert_Receiving", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PONumber", SqlDbType.Int).Value = PONumber; cmd.Parameters.AddWithValue("@POGrossCost", SqlDbType.Decimal).Value = ReceivingGrossCost; int row = cmd.ExecuteNonQuery(); SqlCommand cmdRecvId = new SqlCommand("Usp_GetLastReceivingId", MainClass.con); cmdRecvId.CommandType = CommandType.StoredProcedure; RecvId = Convert.ToInt32(cmdRecvId.ExecuteScalar()); tc.Complete(); return(RecvId); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(RecvId); }
public void UpdatePOStatus(int PONumber, int POStatus) { try { //status=1 for sent //status==2 for received MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_UpdatePOStatus", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PoNumber", SqlDbType.Int).Value = PONumber; cmd.Parameters.AddWithValue("@Status", SqlDbType.Int).Value = POStatus; int row = cmd.ExecuteNonQuery(); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
private void ImportFileData(DataTable dt) { try { Updation update = new Updation(); foreach (DataRow row in dt.Rows) { DataTable dtProductId = retrieve.GetId("usp_GetProductID", row[0].ToString()); //stocks in update.UpdateIncreaseAvailableStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[2]), Convert.ToDateTime(row[1])); //stocks out update.UpdateDecreaseAvailableStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[3]), Convert.ToDateTime(row[1])); //stock onhold update.UpdateIncreaseInOnHoldStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[4]), Convert.ToDateTime(row[1])); //resolve onhold update.UpdateResolveInOnHoldStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[5]), Convert.ToDateTime(row[1])); //stock rejected update.UpdateIncreaseRejectedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[6]), Convert.ToDateTime(row[1])); //resolve rejected update.UpdateIResolveRejectedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[7]), Convert.ToDateTime(row[1])); //stock reworked update.UpdateIncreaseInReworkedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[8]), Convert.ToDateTime(row[1])); //resolve reworked update.UpdateResolveInReworkedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[9]), Convert.ToDateTime(row[1])); } MainClass.ShowMessage("Stocks Updated Successfully. ", "Success", "Success"); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } }
private void buttonLogin_Click(object sender, EventArgs e) { if (textBoxUserName.Text == "") { labelUserNameError.Visible = true; } else { labelUserNameError.Visible = false; } if (textBoxPassword.Text == "") { labelPasswordError.Visible = true; } else { labelPasswordError.Visible = false; } if (labelUserNameError.Visible || labelPasswordError.Visible) { MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message. } else { if (Retrievel.GetUserDetails(textBoxUserName.Text, textBoxPassword.Text)) { HomeScreen obj = new HomeScreen(); MainClass.ShowWindow(obj, this, MDI.ActiveForm); } } }
public int SaveSales(int CustomerId, decimal SalesGrossCost, int UserId, string SalesStatus = null) { try { using (TransactionScope tc = new TransactionScope()) { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("usp_Insert_Sales", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CustomerId", SqlDbType.Int).Value = CustomerId; cmd.Parameters.AddWithValue("@SalesGrossCost", SqlDbType.Decimal).Value = SalesGrossCost; cmd.Parameters.AddWithValue("@SalesStatus", SqlDbType.Int).Value = 1; cmd.Parameters.AddWithValue("@UserId", SqlDbType.Int).Value = UserId; int row = cmd.ExecuteNonQuery(); SqlCommand cmdSalesId = new SqlCommand("Usp_GetLastSalesId", MainClass.con); cmdSalesId.CommandType = CommandType.StoredProcedure; SalesId = Convert.ToInt32(cmdSalesId.ExecuteScalar()); tc.Complete(); return(SalesId); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(SalesId); }
public void UpdateUserDetails(string name, string password, string contactNumber, string email, int usersId, int role) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_EditUserDetails", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", SqlDbType.VarChar).Value = name; cmd.Parameters.AddWithValue("@password", SqlDbType.VarChar).Value = password; cmd.Parameters.AddWithValue("@ContactNumber", SqlDbType.VarChar).Value = contactNumber; cmd.Parameters.AddWithValue("@Email", SqlDbType.VarChar).Value = email; cmd.Parameters.AddWithValue("@UserId", SqlDbType.Int).Value = usersId; cmd.Parameters.AddWithValue("@Role", SqlDbType.Int).Value = role; int row = cmd.ExecuteNonQuery(); if (row > 0) { MainClass.ShowMessage("Username '" + name + "' updated Successfully. ", "Success", "Success"); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public int UpdateDecreaseAvailableStocks(int ProductId, decimal quantity, DateTime Date) { int row = 0; try { //status=1 for sent //status==2 for received MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_DecreaseStocksbyDateStockOut", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = ProductId; cmd.Parameters.AddWithValue("@Quantity", SqlDbType.Decimal).Value = quantity; cmd.Parameters.AddWithValue("@Date", SqlDbType.DateTime).Value = Date; row = cmd.ExecuteNonQuery(); return(row); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(row); }
public void DeleteDetails(object id, string proc, string param) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand(proc, MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(param, id);//.Value = id; int row = cmd.ExecuteNonQuery(); if (row > 0) { MainClass.ShowMessage("Data deleted Successfully. ", "Success", "Success"); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public void UpdateCategoryDetails(string Name, Int16 IsSales, int id) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_EditCategoryDetails", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", SqlDbType.VarChar).Value = Name; cmd.Parameters.AddWithValue("@IsSales", SqlDbType.TinyInt).Value = IsSales; cmd.Parameters.AddWithValue("@Id", SqlDbType.Int).Value = id; int row = cmd.ExecuteNonQuery(); if (row > 0) { MainClass.ShowMessage("Category: '" + Name + "' updated Successfully. ", "Success", "Success"); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public void UpdateProductDetails(string Name, string Code, decimal purchasePrice, string unit, decimal MinValue, int categoryId, int productId, decimal salesPrice) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_EditProductDetail", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Code", SqlDbType.VarChar).Value = Code; cmd.Parameters.AddWithValue("@Name", SqlDbType.VarChar).Value = Name; cmd.Parameters.AddWithValue("@PurchasePrice", SqlDbType.Decimal).Value = purchasePrice; cmd.Parameters.AddWithValue("@Unit", SqlDbType.VarChar).Value = unit; cmd.Parameters.AddWithValue("@MinimumValue", SqlDbType.Decimal).Value = MinValue; cmd.Parameters.AddWithValue("@CategoryID", SqlDbType.Int).Value = categoryId; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = productId; cmd.Parameters.AddWithValue("@SalesPrice", SqlDbType.Decimal).Value = salesPrice; int row = cmd.ExecuteNonQuery(); if (row > 0) { MainClass.ShowMessage("Product: '" + Name + "' updated Successfully. ", "Success", "Success"); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public override void buttonSave_Click(object sender, EventArgs e) { if (dataGridViewPOLines.Rows.Count > 0) { Updation Update = new Updation(); using (TransactionScope tc = new TransactionScope()) { int PoLines = 0; foreach (DataGridViewRow row in dataGridViewPOLines.Rows) { Update.UpdatePODetails(POId, Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ProductTotalPrice"].Value), Convert.ToDecimal(row.Cells["ProductQuantityGv"].Value), Convert.ToInt32(row.Cells["LineNo"].Value)); PoLines += 1; } if (PoLines > 0) { Update.UpdatePOPrice(POId, Convert.ToDecimal(labelGrandTotalValue.Text)); MainClass.ShowMessage("Purchase Order Updated Successfully.", "Success", "Success"); } else { MainClass.ShowMessage("Unable to Update Purchase Order.", "Error", "Error"); } tc.Complete(); } } }
public void Deletewith4Params(string proc, string param1, string param2, string param3, string param4, object param1Value, object param2Value, object param3Value, object param4Value) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand(proc, MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(param1, param1Value); cmd.Parameters.AddWithValue(param2, param2Value); cmd.Parameters.AddWithValue(param3, param3Value); cmd.Parameters.AddWithValue(param4, param4Value); int row = cmd.ExecuteNonQuery(); if (row > 0) { MainClass.ShowMessage("Data deleted Successfully. ", "Success", "Success"); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public int SaveReceiveLine(int Rec_Id, int prodId, decimal price, decimal quantity, int POLineNumber) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_InsertReceiveLine", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ReceiveId", SqlDbType.Int).Value = Rec_Id; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = prodId; cmd.Parameters.AddWithValue("@LineNumber", SqlDbType.Int).Value = POLineNumber; cmd.Parameters.AddWithValue("@LineQuantity", SqlDbType.Decimal).Value = quantity; cmd.Parameters.AddWithValue("@LineTotalCost", SqlDbType.Decimal).Value = price; RecvIdCount = cmd.ExecuteNonQuery(); return(RecvIdCount); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(RecvIdCount); }
public void UpdateIncreaseRejectedStocks(int ProductId, decimal quantity, DateTime date) { try { //status=1 for sent //status==2 for received MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_IncreaseInRejectedStocks", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = ProductId; cmd.Parameters.AddWithValue("@Quantity", SqlDbType.Decimal).Value = quantity; cmd.Parameters.AddWithValue("@Date", SqlDbType.DateTime).Value = date; int row = cmd.ExecuteNonQuery(); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public int SaveSalesLine(int Sales_Id, int prodId, decimal price, decimal quantity, string Unit, int SalesLineNumber) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_InsertSalesLine", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SalesNumber", SqlDbType.Int).Value = Sales_Id; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = prodId; cmd.Parameters.AddWithValue("@LineNumber", SqlDbType.Int).Value = SalesLineNumber; cmd.Parameters.AddWithValue("@SalesLineQuantity", SqlDbType.Decimal).Value = quantity; cmd.Parameters.AddWithValue("@SalesLineTotalCost", SqlDbType.Decimal).Value = price; cmd.Parameters.AddWithValue("@Unit", SqlDbType.VarChar).Value = Unit; SalesidCount = cmd.ExecuteNonQuery(); return(SalesidCount); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(SalesidCount); }
public int SavePO(int SupplierID, DateTime ExpectedDeliveryDate, decimal POGrossCost, int UserId, string POStatus = null) { try { using (TransactionScope tc = new TransactionScope()) { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("usp_Insert_PO", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SupplierId", SqlDbType.Int).Value = SupplierID; cmd.Parameters.AddWithValue("@ExpectedDeliveyDate", SqlDbType.Date).Value = ExpectedDeliveryDate; cmd.Parameters.AddWithValue("@POGrossCost", SqlDbType.Decimal).Value = POGrossCost; cmd.Parameters.AddWithValue("@POStatus", SqlDbType.Int).Value = 1; cmd.Parameters.AddWithValue("@UserId", SqlDbType.Int).Value = UserId; int row = cmd.ExecuteNonQuery(); SqlCommand cmdPOId = new SqlCommand("Usp_GetLastPOId", MainClass.con); cmdPOId.CommandType = CommandType.StoredProcedure; POId = Convert.ToInt32(cmdPOId.ExecuteScalar()); tc.Complete(); return(POId); } } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } return(POId); }
public void UpdatePODetails(int PO_Id, int prodId, decimal price, decimal quantity, int POLineNumber) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_UpatePOLinesDetails", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PONumber", SqlDbType.Int).Value = PO_Id; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = prodId; cmd.Parameters.AddWithValue("@LineNumber", SqlDbType.Int).Value = POLineNumber; cmd.Parameters.AddWithValue("@POLineQuantity", SqlDbType.Decimal).Value = quantity; cmd.Parameters.AddWithValue("@POLineTotalCost", SqlDbType.Decimal).Value = price; int row = cmd.ExecuteNonQuery(); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
public void UpdatePOPrice(int PO_Id, decimal price) { try { MainClass.con.Open(); SqlCommand cmd = new SqlCommand("Usp_UpatePOPrice", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PoNumber", SqlDbType.Int).Value = PO_Id; cmd.Parameters.AddWithValue("@Price", SqlDbType.Decimal).Value = price; // pidCount = cmd.ExecuteNonQuery(); // return pidCount; int row = cmd.ExecuteNonQuery(); } catch (Exception exp) { MainClass.ShowMessage(exp.Message, "Error", "Error"); } finally { MainClass.con.Close(); } }
private void buttonExport_Click(object sender, EventArgs e) { try { if (comboBoxPO.SelectedIndex > 0) { // string Path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Path += "\\PO_PDF"; // if (!System.IO.Directory.Exists(Path)) // { // System.IO.Directory.CreateDirectory(Path); // } // string dates = DateTime.Now.ToString(); // string rd = dates.Replace("/", ":"); // string rdd = rd.Replace(":", "_"); // Path += "\\PO_Number_" + POId.ToString() + "_" + rdd + ".pdf"; // string supplier = "Supplier : "; // string Address=""; // string City=""; // string Country=""; // string ContactNumber=""; // string POCreationDate=""; // string ExpectedDelDate=""; // DataTable dtblSupplier = retrieve.GetPOSupplier(POId); // if (dtblSupplier.Rows.Count > 0) // { // supplier += dtblSupplier.Rows[0][0].ToString(); // Address = dtblSupplier.Rows[0][1].ToString(); // City = dtblSupplier.Rows[0][2].ToString(); // Country = dtblSupplier.Rows[0][3].ToString(); // ContactNumber = dtblSupplier.Rows[0][4].ToString(); // POCreationDate = dtblSupplier.Rows[0][5].ToString(); // ExpectedDelDate = dtblSupplier.Rows[0][6].ToString(); // } // DataTable dtbl = retrieve.GetPOLinesforPDFExport(POId); // string Header = "Purchase Order #" + POId.ToString(); // PDFReports pdf = new PDFReports(); // pdf.ExportDataTableToPdfPORec(dtbl, Path, Header, supplier, labelGrandTotalValue.Text, Address, City, Country, ContactNumber, POCreationDate, ExpectedDelDate); // System.Diagnostics.Process.Start(Path); POReport rpt = new POReport(POId); rpt.Show(); } else { MainClass.ShowMessage("Please select a Purchase Order first.", "Error", "Error"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Message"); } }
public override void buttonSave_Click(object sender, EventArgs e) { if (textBoxCategoryName.Text == "") { labelCategoryNameError.Visible = true; } else { labelCategoryNameError.Visible = false; } if (comboBoxIsSales.SelectedIndex == -1) { labelIsSalesError.Visible = true; } else { labelIsSalesError.Visible = false; } if (labelCategoryNameError.Visible || labelIsSalesError.Visible) { MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message. } else { if (comboBoxIsSales.SelectedIndex == 1) { stat = 0; } else if (comboBoxIsSales.SelectedIndex == 0) { stat = 1; } if (edit == 0) //Code for save operation { Insertion insert = new Insertion(); insert.SaveCategoryDetails(textBoxCategoryName.Text, stat); retrieve.ShowCategories(dataGridViewCat, catIdGV, CatGVName, CatGVStatus); MainClass.Disable_Reset(panelRightSlider); } else if (edit == 1) //code for update operaiton { DialogResult dr = MessageBox.Show("Are you sure, you want to update record.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Updation update = new Updation(); update.UpdateCategoryDetails(textBoxCategoryName.Text, stat, CategoryId); retrieve.ShowCategories(dataGridViewCat, catIdGV, CatGVName, CatGVStatus); MainClass.Disable_Reset(panelRightSlider); } } } }
private void buttonAddToCart_Click(object sender, EventArgs e) { if (comboBoxCustomer.SelectedIndex == -1) { labelSupplierError.Visible = true; } else { labelSupplierError.Visible = false; } //if (dateTimePickerExpectedDelDate.Text == "") //{ // labelExpectedDelDateError.Visible = true; //} //else //{ // labelExpectedDelDateError.Visible = false; //} if (comboBoxSelectProduct.SelectedIndex == -1) { labelProductDateError.Visible = true; } else { labelProductDateError.Visible = false; } if (textBoxQuantity.Text == "") { labelQuantityError.Visible = true; } else { labelQuantityError.Visible = false; } if (labelSupplierError.Visible || labelProductDateError.Visible || labelQuantityError.Visible) { MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message. } else { bool checkDuplicate = false; foreach (DataGridViewRow row in dataGridViewSalesLines.Rows) { if (row.Cells[0].Value.ToString() == ProductId.ToString()) { checkDuplicate = true; MainClass.ShowMessage("Product already entered.", "Error", "Error"); } } if (checkDuplicate == false) { dataGridViewSalesLines.Rows.Add(ProductId, dataGridViewSalesLines.Rows.Count + 1, comboBoxSelectProduct.Text, textBoxQuantity.Text, textBoxUnit.Text, textBoxProdCost.Text, textBoxTotalCost.Text); labelGrandTotalValue.Text = (Convert.ToDecimal(labelGrandTotalValue.Text) + Convert.ToDecimal(textBoxTotalCost.Text)).ToString(); } } }
private void buttonExport_Click(object sender, EventArgs e) { if (comboBoxSalesNumber.SelectedIndex > 0) { CreateSalesPdfReport(SalesId); } else { MainClass.ShowMessage("Please Select a Sales Invoice first.", "Error", "Error"); } }
public static bool GetUserDetails(string UserName, string Password) { try { SqlCommand cmd = new SqlCommand(); cmd = new SqlCommand("LoginUser", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserName", UserName); cmd.Parameters.AddWithValue("@Password", Password); MainClass.con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { checklogin = true; while (dr.Read()) { User_ID = Convert.ToInt32(dr[0].ToString()); User_Name = dr[1].ToString(); usernames = dr[1].ToString(); passwordsnames = dr[2].ToString(); User_Type_Id = Convert.ToInt32(dr[3]); } } else { checklogin = false; if (usernames != null & passwordsnames != null) { if (usernames != UserName) { MainClass.ShowMessage("Invalid Username.", "Error", "Error"); } else if (passwordsnames != Password) { MainClass.ShowMessage("Invalid Password.", "Error", "Error"); } else if (usernames != UserName && passwordsnames != Password) { MainClass.ShowMessage("Invalid Username and Password.", "Error", "Error"); } } } MainClass.con.Close(); } catch (Exception exp) { MainClass.ShowMessage("Unable to Login.", "Error", "Error"); } return(checklogin); }
private void buttonExport_Click(object sender, EventArgs e) { if (comboBoxPO.SelectedIndex > 0) { /// CreateReceivingPdfReport(ReceivingId, POId); ReceivingReport rpt = new ReceivingReport(ReceivingId); rpt.Show(); } else { MainClass.ShowMessage("Please Select a Purchase Order first.", "Error", "Error"); } }
public override void buttonSave_Click(object sender, EventArgs e) { if (dataGridViewPOLines.Rows.Count > 0) { int quantityReceivedCheck = 0; foreach (DataGridViewRow row in dataGridViewPOLines.Rows) { if (row.Cells["QuantityReceivedDgv"].Value == null || row.Cells["QuantityReceivedDgv"].Value == string.Empty) { break; } quantityReceivedCheck += 1; } if (quantityReceivedCheck < dataGridViewPOLines.Rows.Count) { MainClass.ShowMessage("Please Enter received qunatity for all lines.", "Error", "Error"); } else { Updation Update = new Updation(); Insertion insert = new Insertion(); using (TransactionScope tc = new TransactionScope()) { ReceivingId = insert.SaveReceiving(POId, Convert.ToDecimal(labelGrandTotalValue.Text)); int recvLines = 0; foreach (DataGridViewRow row in dataGridViewPOLines.Rows) { recvLines += insert.SaveReceiveLine(ReceivingId, Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ReceivedQuantityCostDgv"].Value), Convert.ToDecimal(row.Cells["QuantityReceivedDgv"].Value), Convert.ToInt32(row.Cells["LineNo"].Value)); } if (recvLines > 0) { Update.UpdatePOStatus(POId, 2); MainClass.ShowMessage("Receiving perfromed successfully.", "Success", "Success"); CreateReceivingPdfReport(ReceivingId, POId); } else { MainClass.ShowMessage("Unable to perform receiving.", "Error", "Error"); } tc.Complete(); } } } else { MainClass.ShowMessage("Please Select a Purchase Order to perform receiving.", "Error", "Error"); } }
private void textBoxQuantity_TextChanged(object sender, EventArgs e) { if (textBoxQuantity.Text != "" && textBoxProdCost.Text != "") { decimal totalcost = Convert.ToDecimal(textBoxQuantity.Text) * Convert.ToDecimal(textBoxProdCost.Text); textBoxTotalCost.Text = totalcost.ToString(); if (Convert.ToDecimal(textBoxQuantity.Text) > AvailableStock) { MainClass.ShowMessage("Quantity not availabe in stocks.", "Error", "Error"); buttonAddToCart.Enabled = false; } else { buttonAddToCart.Enabled = true; } } }
private void buttonAddToStocks_Click(object sender, EventArgs e) { if (comboBoxSelectProduct.SelectedIndex == -1) { labelProductDateError.Visible = true; } else { labelProductDateError.Visible = false; } if (textBoxQuantity.Text == "") { labelQuantityError.Visible = true; } else { labelQuantityError.Visible = false; } if (labelProductDateError.Visible || labelQuantityError.Visible) { MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message. } else { Updation update = new Updation(); update.UpdateIncreaseRejectedStocks(Convert.ToInt32(comboBoxSelectProduct.SelectedValue.ToString()), Convert.ToDecimal(textBoxQuantity.Text), dateTimePickerEntryDate.Value); ShowDataInGrid(); //foreach (DataGridViewRow rows in dataGridViewProduct.Rows) //{ // if(Convert.ToDecimal(rows.Cells["ProductMinValGv"].Value)< Convert.ToDecimal(rows.Cells["AvailableStocks"].Value)) // { // rows.Cells["AvailableStocks"].Style.BackColor = Color.LightGreen; // rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black; // } // else // { // rows.Cells["AvailableStocks"].Style.BackColor = Color.IndianRed; // rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black; // } //} MainClass.ShowMessage("Stocks added sucessfully", "Success", "Success"); textBoxQuantity.Clear(); } }
public override void buttonSave_Click(object sender, EventArgs e) { if (dataGridViewSalesLines.Rows.Count > 0) { int SalesID = 0; Insertion insert = new Insertion(); using (TransactionScope tc = new TransactionScope()) { SalesID = insert.SaveSales(Convert.ToInt32(comboBoxCustomer.SelectedValue), Convert.ToDecimal(labelGrandTotalValue.Text), Retrievel.User_ID); int SalesLines = 0; foreach (DataGridViewRow row in dataGridViewSalesLines.Rows) { SalesLines += insert.SaveSalesLine(SalesID, Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ProductTotalPrice"].Value), Convert.ToDecimal(row.Cells["ProductQuantityGv"].Value), row.Cells["Unit"].Value.ToString(), Convert.ToInt32(row.Cells[1].Value)); if (SalesLines > 0) //decrease the stock { Updation update = new Updation(); int rowsDec = update.UpdateDecreaseAvailableStocks(Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ProductQuantityGv"].Value)); } } if (SalesLines > 0) { MainClass.ShowMessage("Sales Invoice Created Successfully.", "Success", "Success"); dataGridViewSalesLines.Rows.Clear(); textBoxSalesNumber.Text = retrieve.RetrunSalesNumber().ToString(); comboBoxCustomer.Text = ""; comboBoxSelectProduct.Text = ""; textBoxUnit.Clear(); textBoxQuantity.Clear(); textBoxProdCost.Clear(); textBoxTotalCost.Clear(); CreateSalesPdfReport(SalesID); labelGrandTotalValue.Text = "0.00"; } else { MainClass.ShowMessage("Unable to create Sales Invoice.", "Error", "Error"); } tc.Complete(); } } }