示例#1
0
 public void showStockDetails(DataGridView gv, DataGridViewColumn proIDGV, DataGridViewColumn proGV, DataGridViewColumn barcadeGV, DataGridViewColumn expiryGV, DataGridViewColumn priceGV, DataGridViewColumn catGV, DataGridViewColumn availStGV, DataGridViewColumn statusGV, DataGridViewColumn totGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getALLStock", MainClass.con);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);                 //to excute the query this class is responsible.
         DataTable      dt = new DataTable();
         da.Fill(dt);
         proIDGV.DataPropertyName   = dt.Columns["Product ID"].ToString();
         proGV.DataPropertyName     = dt.Columns["Product"].ToString();
         barcadeGV.DataPropertyName = dt.Columns["Barcode"].ToString();
         expiryGV.DataPropertyName  = dt.Columns["Expiry Date"].ToString();
         priceGV.DataPropertyName   = dt.Columns["Price"].ToString();
         catGV.DataPropertyName     = dt.Columns["Category"].ToString();
         availStGV.DataPropertyName = dt.Columns["Available Stock"].ToString();
         statusGV.DataPropertyName  = dt.Columns["Status"].ToString();
         totGV.DataPropertyName     = dt.Columns["Total Amount"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception)
     {
         MainClass.ShowMSG("Unable to load stock data.", "Error", "Error");
     }
 }
示例#2
0
        public void showSuppliers(DataGridView gv, DataGridViewColumn suppIDGV, DataGridViewColumn comNameGV, DataGridViewColumn personGV, DataGridViewColumn phone1GV, DataGridViewColumn phone2GV, DataGridViewColumn addressGV, DataGridViewColumn ntnGV, DataGridViewColumn statusGV)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_getSupplierData", MainClass.con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);                 //to excute the query this class is responsible.
                DataTable      dt = new DataTable();
                da.Fill(dt);
                suppIDGV.DataPropertyName  = dt.Columns["ID"].ToString();
                comNameGV.DataPropertyName = dt.Columns["Company"].ToString();
                personGV.DataPropertyName  = dt.Columns["Contact Person"].ToString();
                phone1GV.DataPropertyName  = dt.Columns["Phone1"].ToString();
                phone2GV.DataPropertyName  = dt.Columns["Phone2"].ToString();

                addressGV.DataPropertyName = dt.Columns["Address"].ToString();
                statusGV.DataPropertyName  = dt.Columns["Status"].ToString();
                ntnGV.DataPropertyName     = dt.Columns["NTN #"].ToString();

                gv.DataSource = dt;
            }
            catch (Exception)
            {
                MainClass.ShowMSG("Unable to load suppliers data.", "Error", "Error");
            }
        }
        public void insertProduct(string product, string barcode, float price, int catID, DateTime?expiry = null)
        {
            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);
                if (expiry == null)
                {
                    cmd.Parameters.AddWithValue("@expiry", DBNull.Value);
                }
                else
                {
                    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...", "success");
            }
            catch (Exception ex)
            {
                MainClass.con.Close();
                MainClass.ShowMSG(ex.Message, "Error...", "Error");
            }
        }
示例#4
0
 public static bool getUserDetails(string username, string password)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getUserDetails", 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 (username != null && password != 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");
                 }
                 if (user_name != username && pass_word != password)
                 {
                     MainClass.ShowMSG("Invalid Username and Password", "Error", "Error");
                 }
             }
         }
         MainClass.con.Close();
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.ShowMSG("Unable to login...", "Error", "Error");
     }
     return(checkLogin);
 }
示例#5
0
 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 Deleted successfully", "Success...", "success");
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.ShowMSG(ex.Message, "Error...", "Error");
     }
 }
 private void cartBtn_Click(object sender, EventArgs e)
 {
     if (supplierDD.SelectedIndex == -1)
     {
         suppErrorLabel.Visible = true;
     }
     else
     {
         suppErrorLabel.Visible = false;
     }
     if (quanTxt.Text == "")
     {
         quantityErrorLabel.Visible = true;
     }
     else
     {
         quantityErrorLabel.Visible = false;
     }
     if (barcodeTxt.Text == "")
     {
         barErrorLabel.Visible = true;
     }
     else
     {
         barErrorLabel.Visible = false;
     }
     if (suppErrorLabel.Visible || quantityErrorLabel.Visible || barErrorLabel.Visible)
     {
         MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");                 //error is a type of message
     }
     else
     {
         dataGridView1.Rows.Add(productID, productTxt.Text, quanTxt.Text, pupTxt.Text, totLabel.Text);
         gt += Convert.ToSingle(totLabel.Text);
         grossTotLabel.Text = gt.ToString();
         productID          = 0;
         productTxt.Text    = "";
         pupTxt.Text        = "";
         barcodeTxt.Text    = "";
         totLabel.Text      = "0.00";
         quanTxt.Text       = "";
         Array.Clear(prodARR, 0, prodARR.Length);
     }
 }
 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...", "success");
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.ShowMSG(ex.Message, "Error...", "Error");
     }
 }
示例#8
0
 public void showCategories(DataGridView gv, DataGridViewColumn catIDGV, DataGridViewColumn catNameGV, DataGridViewColumn statGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getCategoriesDate", MainClass.con);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         SqlDataAdapter da = new SqlDataAdapter(cmd);                 //to excute the query this class is responsible.
         DataTable      dt = new DataTable();
         da.Fill(dt);
         catIDGV.DataPropertyName   = dt.Columns["ID"].ToString();
         catNameGV.DataPropertyName = dt.Columns["Category"].ToString();
         statGV.DataPropertyName    = dt.Columns["Status"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception)
     {
         MainClass.ShowMSG("Unable to load categories data.", "Error", "Error");
     }
 }
示例#9
0
        public void updateSupplier(int supID, string company, string person, string phone1, string address, Int16 status, string phone2 = null, string ntn = null)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_updateSupplier", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@company", company);
                cmd.Parameters.AddWithValue("@conPerson", person);
                cmd.Parameters.AddWithValue("@phone1", phone1);
                if (phone2 == null)
                {
                    cmd.Parameters.AddWithValue("@phone2", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@phone2", phone2);
                }
                if (ntn == null)
                {
                    cmd.Parameters.AddWithValue("@ntn", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@ntn", ntn);
                }

                cmd.Parameters.AddWithValue("@address", address);
                cmd.Parameters.AddWithValue("@status", status);
                cmd.Parameters.AddWithValue("@suppID", supID);

                MainClass.con.Open();
                cmd.ExecuteNonQuery();
                MainClass.con.Close();
                MainClass.ShowMSG(company + " Updated successfully", "Success...", "success");
            }
            catch (Exception ex)
            {
                MainClass.con.Close();
                MainClass.ShowMSG(ex.Message, "Error...", "Error");
            }
        }
 public void insertDeletedItem(Int64 pid, int proid, int quan, int userid, DateTime date)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_insertDeletedItemPI", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@pi", pid);
         cmd.Parameters.AddWithValue("@usrID", userid);
         cmd.Parameters.AddWithValue("@proID", proid);
         cmd.Parameters.AddWithValue("@quan", quan);
         cmd.Parameters.AddWithValue("@date", date);
         MainClass.con.Open();
         cmd.ExecuteNonQuery();
         MainClass.con.Close();
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.ShowMSG(ex.Message, "Error...", "Error");
     }
 }
示例#11
0
 public void showPurchaseInvoiceDetails(Int64 pid, DataGridView gv, DataGridViewColumn mPIDGV, DataGridViewColumn proIDGV, DataGridViewColumn proNameGV, DataGridViewColumn quantGV, DataGridViewColumn pupGV, DataGridViewColumn totGV)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_getPurchaseINvoiceDetails", MainClass.con);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@pid", pid);
         SqlDataAdapter da = new SqlDataAdapter(cmd);                 //to excute the query this class is responsible.
         DataTable      dt = new DataTable();
         da.Fill(dt);
         mPIDGV.DataPropertyName    = dt.Columns["mPID"].ToString();
         proIDGV.DataPropertyName   = dt.Columns["Product ID"].ToString();
         proNameGV.DataPropertyName = dt.Columns["Product"].ToString();
         pupGV.DataPropertyName     = dt.Columns["Per Unit Price"].ToString();
         totGV.DataPropertyName     = dt.Columns["Total Price"].ToString();
         quantGV.DataPropertyName   = dt.Columns["Qunatity"].ToString();
         gv.DataSource = dt;
     }
     catch (Exception)
     {
         MainClass.ShowMSG("Unable to load categories data.", "Error", "Error");
     }
 }
 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("@pwd", 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...", "success");
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.ShowMSG(ex.Message, "Error...", "Error");
     }
 }
 public Int64 insertPurchaseInvoice(DateTime date, int doneBy, int suppID)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_insertPurchaseINvoice", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@date", date);
         cmd.Parameters.AddWithValue("@doneBy", doneBy);
         cmd.Parameters.AddWithValue("@suppID", suppID);
         MainClass.con.Open();
         cmd.ExecuteNonQuery();
         cmd.CommandText = "st_getLastPurchaseID";
         cmd.Parameters.Clear();
         purchaseInvoiceID = Convert.ToInt64(cmd.ExecuteScalar());
         MainClass.con.Close();
     }
     catch (Exception ex)
     {
         MainClass.con.Close();
         MainClass.ShowMSG(ex.Message, "Error...", "Error");
     }
     return(purchaseInvoiceID);
 }
 public override void saveBtn_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count > 0)
     {
         Int64     purchaseInvoiceID;
         insertion i = new insertion();
         using (TransactionScope sc = new TransactionScope())
         {
             purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrieval.USER_ID, Convert.ToInt32(supplierDD.SelectedValue));
             foreach (DataGridViewRow row in dataGridView1.Rows)
             {
                 co += i.insertPurchaseInvoiceDetails(purchaseInvoiceID, Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), Convert.ToSingle(row.Cells["TotGV"].Value.ToString()));
                 int    q;
                 object ob = r.getProductQuantity(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()));
                 if (ob != null)
                 {
                     q  = Convert.ToInt32(ob);
                     q += Convert.ToInt32(row.Cells["quantGV"].Value.ToString());
                     u.updateStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), q);
                 }
                 else
                 {
                     i.insertStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()));
                 }
             }
             if (co > 0)
             {
                 MainClass.ShowMSG("Purchase Invoice Created Successfully.", "success", "success");
             }
             else
             {
                 MainClass.ShowMSG("Unable to create purchase invoice.", "Error", "Error");
             }
             sc.Complete();
         }
     }
 }
示例#15
0
        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 = System.Data.CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);                 //to excute the query this class is responsible.
                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();
                priceGV.DataPropertyName   = dt.Columns["price"].ToString();
                expiryGV.DataPropertyName  = dt.Columns["Expiry"].ToString();

                catGV.DataPropertyName   = dt.Columns["Category"].ToString();
                catIDGV.DataPropertyName = dt.Columns["Category ID"].ToString();
                gv.DataSource            = dt;
            }
            catch (Exception)
            {
                MainClass.ShowMSG("Unable to load categories data.", "Error", "Error");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (usernameTXt.Text == "")
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }

            if (passTxt.Text == "")
            {
                passErrorLabel.Visible = true;
            }
            else
            {
                passErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || passErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");                //Error is the type of message.
            }
            else
            {
                if (retrieval.getUserDetails(usernameTXt.Text, passTxt.Text))
                {
                    HomeScreen hm = new HomeScreen();
                    MainClass.showWindow(hm, this, MDI.ActiveForm);
                }
                else
                {
                }
            }
        }
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (proTxt.Text == "")
            {
                proErrorLabel.Visible = true;
            }
            else
            {
                proErrorLabel.Visible = false;
            }

            if (barcodeTxt.Text == "")
            {
                barcodeErrorLabel.Visible = true;
            }
            else
            {
                barcodeErrorLabel.Visible = false;
            }

            if (expiryPicker.Value < DateTime.Now)
            {
                expiryErrorLabel.Visible = true; expiryErrorLabel.Text = "Invalid Date";
            }
            else
            {
                expiryErrorLabel.Visible = false;
            }
            if (expiryPicker.Value.Date == DateTime.Now.Date)
            {
                expiryErrorLabel.Visible = false;
            }

            if (priceTxt.Text == "")
            {
                priceErrorLabel.Visible = true;
            }
            else
            {
                priceErrorLabel.Visible = false;
            }

            if (categoryDD.SelectedIndex == -1 || categoryDD.SelectedIndex == 0)
            {
                catErrorLabel.Visible = true;
            }
            else
            {
                catErrorLabel.Visible = false;
            }

            if (proErrorLabel.Visible || barcodeErrorLabel.Visible || expiryErrorLabel.Visible || priceErrorLabel.Visible || catErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");                //Error is the type of message.
            }
            else
            {
                if (edit == 0)                //code for SAVE operation.
                {
                    insertion i = new insertion();
                    if (expiryPicker.Value.Date == DateTime.Now.Date)
                    {
                        i.insertProduct(proTxt.Text, barcodeTxt.Text, Convert.ToSingle(priceTxt.Text), Convert.ToInt32(categoryDD.SelectedValue));
                    }
                    else
                    {
                        i.insertProduct(proTxt.Text, barcodeTxt.Text, Convert.ToSingle(priceTxt.Text), Convert.ToInt32(categoryDD.SelectedValue), expiryPicker.Value);
                    }

                    r.showProducts(dataGridView1, proIDGV, proGV, 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();
                        if (expiryPicker.Value.Date == DateTime.Now.Date)
                        {
                            u.updateProduct(prodID, proTxt.Text, barcodeTxt.Text, Convert.ToSingle(priceTxt.Text), Convert.ToInt32(categoryDD.SelectedValue));
                        }
                        else
                        {
                            u.updateProduct(prodID, proTxt.Text, barcodeTxt.Text, Convert.ToSingle(priceTxt.Text), Convert.ToInt32(categoryDD.SelectedValue), expiryPicker.Value);
                        }

                        r.showProducts(dataGridView1, proIDGV, proGV, expiryGV, catGV, priceGV, barcodeGV, catIDGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (catTxt.Text == "")
            {
                catErrorLabel.Visible = true;
            }
            else
            {
                catErrorLabel.Visible = false;
            }

            if (activeDD.SelectedIndex == -1)
            {
                activeErrorLabel.Visible = true;
            }
            else
            {
                activeErrorLabel.Visible = false;
            }

            if (activeErrorLabel.Visible || catErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");                //Error is the type of message.
            }
            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(catTxt.Text, stat);
                    r.showCategories(dataGridView1, catIDGV, NameGV, 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();
                        if (activeDD.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (activeDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        if (activeDD.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (activeDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catID, catTxt.Text, stat);
                        r.showCategories(dataGridView1, catIDGV, NameGV, statusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
示例#19
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (supplierCompanyTxt.Text == "")
            {
                supNameErrorLabel.Visible = true;
            }
            else
            {
                supNameErrorLabel.Visible = false;
            }

            if (personNameTxt.Text == "")
            {
                personErrorLabel.Visible = true;
            }
            else
            {
                personErrorLabel.Visible = false;
            }

            if (Phone1Txt.Text == "")
            {
                phone1ErrorLabel.Visible = true;
            }
            else
            {
                phone1ErrorLabel.Visible = false;
            }

            if (adderssTxt.Text == "")
            {
                addressErrorLabel.Visible = true;
            }
            else
            {
                addressErrorLabel.Visible = false;
            }


            if (statusDD.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (supNameErrorLabel.Visible || personErrorLabel.Visible || phone1ErrorLabel.Visible || addressErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");                //Error is the type of message.
            }
            else
            {
                if (statusDD.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusDD.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)                //code for SAVE operation.
                {
                    insertion i = new insertion();
                    if (phone2Txt.Text == "" && ntnTxt.Text != "")
                    {
                        i.insertSupplier(supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, null, ntnTxt.Text);
                    }
                    else if (phone2Txt.Text != "" && ntnTxt.Text == "")
                    {
                        i.insertSupplier(supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, phone2Txt.Text, null);
                    }
                    else if (phone2Txt.Text == "" && ntnTxt.Text == "")
                    {
                        i.insertSupplier(supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, null, null);
                    }
                    else
                    {
                        i.insertSupplier(supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, phone2Txt.Text, ntnTxt.Text);
                    }


                    r.showSuppliers(dataGridView1, suppIDGV, companyGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, 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();
                        if (statusDD.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        if (phone2Txt.Text == "" && ntnTxt.Text != "")
                        {
                            u.updateSupplier(SupplierID, supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, null, ntnTxt.Text);
                        }
                        else if (phone2Txt.Text != "" && ntnTxt.Text == "")
                        {
                            u.updateSupplier(SupplierID, supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, phone2Txt.Text, null);
                        }
                        else if (phone2Txt.Text == "" && ntnTxt.Text == "")
                        {
                            u.updateSupplier(SupplierID, supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, null, null);
                        }
                        else
                        {
                            u.updateSupplier(SupplierID, supplierCompanyTxt.Text, personNameTxt.Text, Phone1Txt.Text, adderssTxt.Text, stat, phone2Txt.Text, ntnTxt.Text);
                        }

                        r.showSuppliers(dataGridView1, suppIDGV, companyGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, statusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }

            if (usernameTxt.Text == "")
            {
                usernameErrorLabel.Visible = true;
            }
            else
            {
                usernameErrorLabel.Visible = false;
            }

            if (passTxt.Text == "")
            {
                passErrorLabel.Visible = true;
            }
            else
            {
                passErrorLabel.Visible = false;
            }

            if (emailTxt.Text == "")
            {
                emailErrorLabel.Visible = true;
            }
            else
            {
                emailErrorLabel.Visible = false;
            }

            if (phoneTxt.Text == "")
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }

            if (statusDD.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passErrorLabel.Visible || emailErrorLabel.Visible || phoneErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error");               //Error is the type of message.
            }
            else
            {
                if (statusDD.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusDD.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)                //code for SAVE operation.
                {
                    insertion i = new insertion();
                    i.insertUser(nameTxt.Text, usernameTxt.Text, passTxt.Text, emailTxt.Text, phoneTxt.Text, stat);
                    r.showUsers(dataGridView1, userIDGV, NameGV, USerNameGV, PassGV, EmailGV, PhoneGV, 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();
                        if (statusDD.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateUser(userID, nameTxt.Text, usernameTxt.Text, passTxt.Text, emailTxt.Text, phoneTxt.Text, stat);
                        r.showUsers(dataGridView1, userIDGV, NameGV, USerNameGV, PassGV, EmailGV, PhoneGV, statusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }