public void ShowProducts(DataGridView gv, DataGridViewColumn proIDGV, DataGridViewColumn proNameGV, DataGridViewColumn expiryGV, DataGridViewColumn catGV, DataGridViewColumn priceGV, DataGridViewColumn barGV, DataGridViewColumn catIDGV) { try { SqlCommand cmd = new SqlCommand("st_getProductsData", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); proIDGV.DataPropertyName = dt.Columns["Product_ID"].ToString(); proNameGV.DataPropertyName = dt.Columns["product"].ToString(); barGV.DataPropertyName = dt.Columns["Barcode"].ToString(); expiryGV.DataPropertyName = dt.Columns["Expiry"].ToString(); priceGV.DataPropertyName = dt.Columns["price"].ToString(); catGV.DataPropertyName = dt.Columns["Category"].ToString(); catIDGV.DataPropertyName = dt.Columns["Category ID"].ToString(); gv.DataSource = dt; } catch (Exception) { MainClass.ShowMSG("unable to category data", "Error", "Error"); } }
public void ShowStock(DataGridView gv, DataGridViewColumn StockIDGV, DataGridViewColumn SprodIDGV, DataGridViewColumn ProductNamepwGV, DataGridViewColumn PQuantityGV, DataGridViewColumn PurchaseRateGV, DataGridViewColumn PSalesRateGV) { try { SqlCommand cmd = new SqlCommand("st_GetstockData", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); StockIDGV.DataPropertyName = dt.Columns["Stock_ID"].ToString(); PQuantityGV.DataPropertyName = dt.Columns["Stock_QTY"].ToString(); PurchaseRateGV.DataPropertyName = dt.Columns["Purchase_Rate"].ToString(); PSalesRateGV.DataPropertyName = dt.Columns["Sales_Rate"].ToString(); SprodIDGV.DataPropertyName = dt.Columns["Product_ID"].ToString(); ProductNamepwGV.DataPropertyName = dt.Columns["product"].ToString(); gv.DataSource = dt; } catch (Exception) { MainClass.ShowMSG("unable to category data", "Error", "Error"); } }
private void button1_Click(object sender, EventArgs e) { if (Usernametext.Text == "") { usernameerroelbl.Visible = true; } else { usernameerroelbl.Visible = false; } if (Passwordtext.Text == "") { passworderrorlbl.Visible = true; } else { passworderrorlbl.Visible = false; } if (usernameerroelbl.Visible || passworderrorlbl.Visible) { MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error massage with main class } else { if (Retrival.getUserDetail(Usernametext.Text, Passwordtext.Text)) { HomeScreen obj = new HomeScreen(); MainClass.showWindow(obj, this, MDI.ActiveForm); } else { } } }
public override void upodatebtn_Click(object sender, EventArgs e) { if (Categrytxt.Text == "") { Caterrorlbl.Visible = true; } else { Caterrorlbl.Visible = false; } if (ActiveDD.SelectedIndex == -1) { Activeerrorlbl.Visible = true; } else { Activeerrorlbl.Visible = false; } if (Caterrorlbl.Visible || Activeerrorlbl.Visible) { MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error massage with main class } else { if (ActiveDD.SelectedIndex == 0) { stat = 1; } else if (ActiveDD.SelectedIndex == 1) { stat = 0; } if (edit == 0) //code for save operation { Insertion i = new Insertion(); i.InsertCat(Categrytxt.Text, stat); R.ShowCategories(dataGridView1, catIDGV, catNameGV, StatusGV); MainClass.disable_reset(leftpanel); } else if (edit == 1) //code for update operation { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question...", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Updation u = new Updation(); u.updateCat(catID, Categrytxt.Text, stat); R.ShowCategories(dataGridView1, catIDGV, catNameGV, StatusGV); MainClass.disable_reset(leftpanel); } } } }
public static bool getUserDetail(string username, string password) { try { SqlCommand cmd = new SqlCommand("st_GetUsersDetails", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@user", username); cmd.Parameters.AddWithValue("@pass", password); MainClass.con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { checklogin = true; while (dr.Read()) { USER_ID = Convert.ToInt32(dr["ID"].ToString()); EMP_NAME = dr["Name"].ToString(); user_name = dr["Username"].ToString(); pass_word = dr["password"].ToString(); } } else { checklogin = false; if (user_name != null && pass_word != null) { if (user_name != username && pass_word == password) { MainClass.ShowMSG("Invalid Username", "Error", "Error"); } else if (user_name == username && pass_word != password) { MainClass.ShowMSG("Invalid Password", "Error", "Error"); } else if (user_name != username && pass_word != password) { MainClass.ShowMSG("Invalid Username/Password", "Error", "Error"); } } } MainClass.con.Close(); } catch (Exception) { MainClass.con.Close(); MainClass.ShowMSG("Unable to Login", "Error", "Error"); } return(checklogin); }
public void delete(object id, string proc, string param) { try { SqlCommand cmd = new SqlCommand(proc, MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(param, id); MainClass.con.Open(); cmd.ExecuteNonQuery(); MainClass.con.Close(); MainClass.ShowMSG(" Data delete to the system successfully..", "Success..", "sucess"); } catch (Exception ex) { MainClass.con.Close(); MainClass.ShowMSG(ex.Message, "Error....", "Error"); } }
//category insertion public void InsertCat(string name, Int16 status) { try { SqlCommand cmd = new SqlCommand("st_insertCategory", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@isActive", status); MainClass.con.Open(); cmd.ExecuteNonQuery(); MainClass.con.Close(); MainClass.ShowMSG(name + " added to the system successfully..", "Success..", "Sucess"); } catch (Exception ex) { MainClass.con.Close(); MainClass.ShowMSG(ex.Message, "Error....", "Error"); } }
public void ShowCategories(DataGridView gv, DataGridViewColumn catIDGV, DataGridViewColumn catNameGV, DataGridViewColumn StatusGV) { try { SqlCommand cmd = new SqlCommand("st_getCategoriesData", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); catIDGV.DataPropertyName = dt.Columns["ID"].ToString(); catNameGV.DataPropertyName = dt.Columns["category"].ToString(); StatusGV.DataPropertyName = dt.Columns["Status"].ToString(); gv.DataSource = dt; } catch (Exception) { MainClass.ShowMSG("unable to category data", "Error", "Error"); } }
//Stock Insertion public void InsertStock(int stokproID, float Quantity, float purchaserate, float salesrate) { try { SqlCommand cmd = new SqlCommand("st_StockInsert", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Stockqty", Quantity); cmd.Parameters.AddWithValue("@purchaserate", purchaserate); cmd.Parameters.AddWithValue("@salesrate", salesrate); cmd.Parameters.AddWithValue("@sto_proID", stokproID); MainClass.con.Open(); cmd.ExecuteNonQuery(); MainClass.con.Close(); MainClass.ShowMSG(stokproID + " added to the system successfully..", "Success..", "Sucess"); } catch (Exception ex) { MainClass.con.Close(); MainClass.ShowMSG(ex.Message, "Error....", "Error"); } }
//product insertion public void InsertProduct(string product, string barcode, float price, DateTime?expiry, int catID) { try { SqlCommand cmd = new SqlCommand("st_ProductInsert", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", product); cmd.Parameters.AddWithValue("@barcode", barcode); cmd.Parameters.AddWithValue("@price", price); cmd.Parameters.AddWithValue("@expiry", expiry); cmd.Parameters.AddWithValue("@catID", catID); MainClass.con.Open(); cmd.ExecuteNonQuery(); MainClass.con.Close(); MainClass.ShowMSG(product + " added to the system successfully..", "Success..", "Sucess"); } catch (Exception ex) { MainClass.con.Close(); MainClass.ShowMSG(ex.Message, "Error....", "Error"); } }
//user insertiom public void InsertUser(string name, string username, string pass, string email, string phone, Int16 status) { try { SqlCommand cmd = new SqlCommand("st_insertUsers", MainClass.con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@psw", pass); cmd.Parameters.AddWithValue("@phone", phone); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@status", status); MainClass.con.Open(); cmd.ExecuteNonQuery(); MainClass.con.Close(); MainClass.ShowMSG(name + " added to the system successfully..", "Success..", "Sucess"); } catch (Exception ex) { MainClass.con.Close(); MainClass.ShowMSG(ex.Message, "Error....", "Error"); } }
public override void upodatebtn_Click(object sender, EventArgs e) { if (nametxtusr.Text == "") { nameerrorlabl.Visible = true; } else { nameerrorlabl.Visible = false; } if (usernametxtusr.Text == "") { usrnameerrorlbl.Visible = true; } else { usrnameerrorlbl.Visible = false; } if (pswttxtusr.Text == "") { pswerrorlbl.Visible = true; } else { pswerrorlbl.Visible = false; } if (phonetxtusr.Text == "") { phoneerroelbl.Visible = true; } else { phoneerroelbl.Visible = false; } if (emailtxtusr.Text == "") { emailerroelbl.Visible = true; } else { emailerroelbl.Visible = false; } if (Statuscombousr.SelectedIndex == -1) { statuseror.Visible = true; } else { statuseror.Visible = false; } if (nameerrorlabl.Visible || usrnameerrorlbl.Visible || pswerrorlbl.Visible || phoneerroelbl.Visible || emailerroelbl.Visible || statuseror.Visible) { MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error massage with main class } else { if (Statuscombousr.SelectedIndex == 0) { stat = 1; } else if (Statuscombousr.SelectedIndex == 1) { stat = 0; } if (edit == 0) //code for save operation { Insertion i = new Insertion(); i.InsertUser(nametxtusr.Text, usernametxtusr.Text, pswttxtusr.Text, emailtxtusr.Text, phonetxtusr.Text, stat); R.ShowUsers(dataGridView1, userIDGV, NameGV, UserNameGV, PasswordGV, PhoneGV, EmailGV, StatusGV); MainClass.disable_reset(leftpanel); } else if (edit == 1) //code for update operation { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question...", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Updation u = new Updation(); u.updateUser(UserID, nametxtusr.Text, usernametxtusr.Text, pswttxtusr.Text, emailtxtusr.Text, phonetxtusr.Text, stat); R.ShowUsers(dataGridView1, userIDGV, NameGV, UserNameGV, PasswordGV, PhoneGV, EmailGV, StatusGV); MainClass.disable_reset(leftpanel); } } } }
public override void upodatebtn_Click(object sender, EventArgs e) { if (pronamtxtp.Text == "") { pnameerrorlbl.Visible = true; } else { pnameerrorlbl.Visible = false; } if (barcodetxtp.Text == "") { barcodeperrorlbl.Visible = true; } else { barcodeperrorlbl.Visible = false; } if (Expirypickerp.Value < DateTime.Now) { expiryerrorplbl.Visible = true; expiryerrorplbl.Text = "Invalid Date..."; } else { expiryerrorplbl.Visible = false; } if (pptxt.Text == "") { pperrorlbl.Visible = true; } else { pperrorlbl.Visible = false; } if (categoryDD.SelectedIndex == -1 || categoryDD.SelectedIndex == 0) { caterrorlbl.Visible = true; } else { caterrorlbl.Visible = false; } if (pnameerrorlbl.Visible || barcodeperrorlbl.Visible || expiryerrorplbl.Visible || pperrorlbl.Visible || caterrorlbl.Visible) { MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error massage with main class } else { if (edit == 0) //code for save operation { Insertion i = new Insertion(); i.InsertProduct(pronamtxtp.Text, barcodetxtp.Text, Convert.ToSingle(pptxt.Text), Expirypickerp.Value, Convert.ToInt32(categoryDD.SelectedValue)); R.ShowProducts(dataGridView1, proIDGV, proNameGV, ExpiryGV, CatGV, PriceGV, barcodeGV, CatIDGV); MainClass.disable_reset(leftpanel); } else if (edit == 1) //code for update operation { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question...", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Updation u = new Updation(); u.updateProduct(prodID, pronamtxtp.Text, barcodetxtp.Text, Convert.ToSingle(pptxt.Text), Expirypickerp.Value, Convert.ToInt32(categoryDD.SelectedValue)); R.ShowProducts(dataGridView1, proIDGV, proNameGV, ExpiryGV, CatGV, PriceGV, barcodeGV, CatIDGV); MainClass.disable_reset(leftpanel); } } } }