public override void saveButton_Click(object sender, EventArgs e)
        {
            if (categoryComboBox.SelectedIndex != -1 && categoryComboBox.SelectedIndex != 0)
            {
                foreach (DataGridViewRow row in displayDataGridView.Rows)
                {
                    if ((bool)row.Cells["selectGV"].FormattedValue == true)
                    {
                        float disc, pm, bp, sp;
                        int   pID;
                        pID = Convert.ToInt32(row.Cells["proIDGV"].Value.ToString());
                        bp  = Convert.ToSingle(row.Cells["buyingPriceGV"].Value.ToString());

                        disc = row.Cells["discountGV"].Value == null? 0 : Convert.ToSingle(row.Cells["discountGV"].Value.ToString());
                        pm   = row.Cells["profitMarginGV"].Value == null? 0 : Convert.ToSingle(row.Cells["profitMarginGV"].Value.ToString());
                        if (disc == 0 && pm == 0)
                        {
                            sp = bp;
                        }
                        else
                        {
                            sp = Convert.ToSingle(row.Cells["FinalPriceGV"].Value.ToString());
                        }

                        u.updateProductPrice(pID, bp, sp, disc, pm);
                    }
                }

                MainClass.ShowMsg("Product Pricing Updated Successfully...", "Success", "Success");
            }
        }
 private void loginButton_Click(object sender, EventArgs e)
 {
     if (usernameTextBox.Text == "")
     {
         nameErrorLabel.Visible = true;
     }
     else
     {
         nameErrorLabel.Visible = false;
     }
     if (passwordTextBox.Text == "")
     {
         passwordErrorLabel.Visible = true;
     }
     else
     {
         passwordErrorLabel.Visible = false;
     }
     if (nameErrorLabel.Visible || passwordErrorLabel.Visible)
     {
         MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
     }
     else
     {
         if (retrival.getUserDetails(usernameTextBox.Text, passwordTextBox.Text))
         {
             HomeScreen hs = new HomeScreen();
             MainClass.showWindow(hs, this, MDI.ActiveForm);
         }
         else
         {
         }
     }
 }
Пример #3
0
        public void showStockDetails(DataGridView gv, DataGridViewColumn proIDGV, DataGridViewColumn proGV, DataGridViewColumn barcodeGV, DataGridViewColumn expiryGV, DataGridViewColumn catGV, DataGridViewColumn bpGV, DataGridViewColumn spGV, DataGridViewColumn availStGV, DataGridViewColumn statusGV, DataGridViewColumn totGV)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("sp_getAllStock", 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();
                proGV.DataPropertyName     = dt.Columns["Product"].ToString();
                barcodeGV.DataPropertyName = dt.Columns["Barcode"].ToString();
                expiryGV.DataPropertyName  = dt.Columns["Expiry Date"].ToString();
                bpGV.DataPropertyName      = dt.Columns["Buying Price"].ToString();
                spGV.DataPropertyName      = dt.Columns["Selling Price"].ToString();
                catGV.DataPropertyName     = dt.Columns["Catergory"].ToString();
                statusGV.DataPropertyName  = dt.Columns["Status"].ToString();
                availStGV.DataPropertyName = dt.Columns["Available Stock"].ToString();
                totGV.DataPropertyName     = dt.Columns["Total Amount"].ToString();

                gv.DataSource = dt;
            }
            catch (Exception)
            {
                MainClass.ShowMsg("Unable to load Suppliers Data.", "Error", "Error");
            }
        }
 public void updateProduct(int proID, string product, string barcode, int catID, DateTime?expiry = null)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("st_productUpdate", MainClass.con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@name", product);
         cmd.Parameters.AddWithValue("@barcode", barcode);
         if (expiry == null)
         {
             cmd.Parameters.AddWithValue("@expiry", DBNull.Value);
         }
         else
         {
             cmd.Parameters.AddWithValue("@expiry", expiry);
         }
         cmd.Parameters.AddWithValue("@catID", catID);
         cmd.Parameters.AddWithValue("@proID", proID);
         MainClass.con.Open();
         cmd.ExecuteNonQuery();
         MainClass.con.Close();
         MainClass.ShowMsg(product + "updated to the system successfully", "Success", "Success");
     }
     catch (Exception e)
     {
         MainClass.con.Close();
         MainClass.ShowMsg(e.Message, "Error", "Error");
     }
 }
Пример #5
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("sp_getPurchaseInvoiceDetails", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@pid", pid);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                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["quantity"].ToString();

                gv.DataSource = dt;
            }
            catch (Exception)
            {
                MainClass.ShowMsg("Unable to load Product Data.", "Error", "Error");
            }
        }
Пример #6
0
        public void showProductsWRTCategory(int catID, DataGridView gv, DataGridViewColumn proIDGV, DataGridViewColumn proNameGV, DataGridViewColumn bpGV, DataGridViewColumn spGV,
                                            DataGridViewColumn disGV, DataGridViewColumn profitPerGV)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_getProductsWRTCategory", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@catID", catID);
                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();
                bpGV.DataPropertyName        = dt.Columns["Buying Price"].ToString();
                spGV.DataPropertyName        = dt.Columns["Selling Price"].ToString();
                disGV.DataPropertyName       = dt.Columns["Discount"].ToString();
                profitPerGV.DataPropertyName = dt.Columns["Profit Percentage"].ToString();


                gv.DataSource = dt;
            }
            catch (Exception)
            {
                MainClass.ShowMsg("Unable to load Products Data.", "Error", "Error");
            }
        }
        public void updateUser(int id, string name, string username, string pass, string email, string phone, Int16 status)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_updateUsers", 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("@id", id);

                cmd.Parameters.AddWithValue("@status", status);
                MainClass.con.Open();
                cmd.ExecuteNonQuery();
                MainClass.con.Close();
                MainClass.ShowMsg(name + "updated to the system successfully", "Success", "Success");
            }
            catch (Exception e)
            {
                MainClass.con.Close();
                MainClass.ShowMsg(e.Message, "Error", "Error");
            }
        }
Пример #8
0
        public void showCategories(DataGridView gv, DataGridViewColumn catIDGV, DataGridViewColumn catNameGV, DataGridViewColumn statusGV, string data = null)
        {
            try
            {
                SqlCommand cmd;
                if (data == null)
                {
                    cmd = new SqlCommand("st_getCategoriesData", MainClass.con);
                }
                else
                {
                    cmd = new SqlCommand("st_getCategoryDataLIKE", MainClass.con);
                    cmd.Parameters.AddWithValue("@data", data);
                }



                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 load Categories Data.", "Error", "Error");
            }
        }
Пример #9
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("sp_getSupplierData", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);

                suppIDGV.DataPropertyName  = dt.Columns["ID"].ToString();
                comNameGV.DataPropertyName = dt.Columns["Compnay"].ToString();
                personGV.DataPropertyName  = dt.Columns["Contact Person"].ToString();
                phone1GV.DataPropertyName  = dt.Columns["Phone 1"].ToString();
                phone2GV.DataPropertyName  = dt.Columns["Phone 2"].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 override void saveButton_Click(object sender, EventArgs e)
        {
            if (displayDataGridView.Rows.Count > 0)
            {
                Int64     purchaseInvoiceID;
                insertion i = new insertion();
                updation  u = new updation();
                using (TransactionScope sc = new TransactionScope())
                {
                    purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrival.USER_ID,
                                                                Convert.ToInt32(supplierComboBox.SelectedValue));

                    foreach (DataGridViewRow row in displayDataGridView.Rows)
                    {
                        co += i.insertPurchaseInvoiceDetails(purchaseInvoiceID, Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), Convert.ToSingle(row.Cells["totalGV"].Value.ToString()));
                        if (r.checkProductPriceExistance(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString())))
                        {
                            u.updateProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString()));
                        }
                        else
                        {
                            i.insertProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].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();
                }
            }
        }
Пример #11
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");
                 }
                 else if (user_name != username && pass_word != password)
                 {
                     MainClass.ShowMsg("Invalid Password & Username", "Error", "Error");
                 }
             }
         }
         MainClass.con.Close();
     }
     catch (Exception)
     {
         MainClass.con.Close();
         MainClass.ShowMsg("Unable to login....", "Error", "Error");
     }
     return(checkLogin);
 }
        private void cartButton_Click(object sender, EventArgs e)
        {
            if (supplierComboBox.SelectedIndex == -1)
            {
                supplierErrorLabel.Visible = true;
            }
            else
            {
                supplierErrorLabel.Visible = false;
            }
            if (quantityTextBox.Text == "")
            {
                quantityErrorLabel.Visible = true;
            }
            else
            {
                quantityErrorLabel.Visible = false;
            }
            if (barcodeTextBox.Text == "")
            {
                barcodeErrorLabel.Visible = true;
            }
            else
            {
                barcodeErrorLabel.Visible = false;
            }

            if (supplierErrorLabel.Visible || quantityErrorLabel.Visible || barcodeErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                displayDataGridView.Rows.Add(productID, producTextBox.Text, quantityTextBox.Text, priceTextBox.Text,
                                             totlabel.Text);
                gt += Convert.ToSingle(totlabel.Text);
                grossLabel.Text      = gt.ToString();
                productID            = 0;
                producTextBox.Text   = "";
                priceTextBox.Text    = "";
                barcodeTextBox.Text  = "";
                totlabel.Text        = "0.00";
                quantityTextBox.Text = "";
                Array.Clear(prodARR, 0, prodARR.Length);
            }
        }
        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 e)
            {
                MainClass.con.Close();
                MainClass.ShowMsg(e.Message, "Error", "Error");
            }
        }
        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("sp_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 e)
            {
                MainClass.con.Close();
                MainClass.ShowMsg(e.Message, "Error", "Error");
            }
        }
        public void insertProductPrice(int proID, float buyingAmount)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("st_insertProductPrice", MainClass.con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@proID", proID);
                cmd.Parameters.AddWithValue("@bp", buyingAmount);


                MainClass.con.Open();
                cmd.ExecuteNonQuery();
                MainClass.con.Close();
            }
            catch (Exception e)
            {
                MainClass.con.Close();
                MainClass.ShowMsg(e.Message, "Error", "Error");
            }
        }
        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 e)
            {
                MainClass.con.Close();
                MainClass.ShowMsg(e.Message, "Error", "Error");
            }
        }
 public void insertDeletedItem(Int64 pid, int proid, int quan, int userid, DateTime date)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("sp_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 e)
     {
         MainClass.con.Close();
         MainClass.ShowMsg(e.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 e)
     {
         MainClass.con.Close();
         MainClass.ShowMsg(e.Message, "Error", "Error");
     }
     return(purchaseInvoiceID);
 }
Пример #19
0
        public void showProducts(DataGridView gv, DataGridViewColumn proIDGV, DataGridViewColumn proNameGV, DataGridViewColumn expiryGV, DataGridViewColumn catGV, DataGridViewColumn barcodeGV, 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();
                barcodeGV.DataPropertyName = dt.Columns["Barcode"].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 Product Data.", "Error", "Error");
            }
        }
Пример #20
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (productTextBox.Text == "")
            {
                productNameErrorLabel.Visible = true;
            }
            else
            {
                productNameErrorLabel.Visible = false;
            }
            if (barcodeTextBox.Text == "")
            {
                barcodeErrorLabel.Visible = true;
            }
            else
            {
                barcodeErrorLabel.Visible = false;
            }
            if (expiryDateTimePicker.Value < DateTime.Now)
            {
                expiryDateLabel.Visible = true; expiryDateLabel.Text = "invalid Date";
            }
            else
            {
                expiryDateLabel.Visible = false;
            }
            if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
            {
                expiryDateLabel.Visible = false;
            }

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


            if (productNameErrorLabel.Visible || barcodeErrorLabel.Visible || expiryDateLabel.Visible || categoryErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();
                    if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
                    {
                        i.insertProduct(productTextBox.Text, barcodeTextBox.Text,
                                        Convert.ToInt32(categoryComboBox.SelectedValue));
                    }
                    else
                    {
                        i.insertProduct(productTextBox.Text, barcodeTextBox.Text,
                                        Convert.ToInt32(categoryComboBox.SelectedValue), expiryDateTimePicker.Value);
                    }


                    r.showProducts(displayDataGridView, proIDGV, proGV, ExpiryGV, catGV, barcodeGV, CatIDGV);
                    MainClass.disableReset(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.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (expiryDateTimePicker.Value.Date == DateTime.Now.Date)
                        {
                            u.updateProduct(prodId, productTextBox.Text, barcodeTextBox.Text, Convert.ToInt32(categoryComboBox.SelectedValue));
                        }
                        else
                        {
                            u.updateProduct(prodId, productTextBox.Text, barcodeTextBox.Text, Convert.ToInt32(categoryComboBox.SelectedValue), expiryDateTimePicker.Value);
                        }

                        r.showProducts(displayDataGridView, proIDGV, proGV, ExpiryGV, catGV, barcodeGV, CatIDGV);
                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
Пример #21
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text == "")
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }
            if (usernameTextBox.Text == "")
            {
                usernameErrorLabel.Visible = true;
            }
            else
            {
                usernameErrorLabel.Visible = false;
            }
            if (passwordTextBox.Text == "")
            {
                passwordErrorLabel.Visible = true;
            }
            else
            {
                passwordErrorLabel.Visible = false;
            }
            if (emailTextBox.Text == "")
            {
                emailErrorLabel.Visible = true;
            }
            else
            {
                emailErrorLabel.Visible = false;
            }
            if (phoneTextBox.Text == "")
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }
            if (statusComboBox.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passwordErrorLabel.Visible ||
                emailErrorLabel.Visible || phoneErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (statusComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();


                    i.insertUser(nameTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, emailTextBox.Text, phoneTextBox.Text, stat);
                    r.showUsers(displayDataGridView, userIDGV, NameGV, UserNameGV, passGV, EmailGV, PhoneGV, statusGV);
                    MainClass.disableReset(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.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (statusComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateUser(userId, nameTextBox.Text, usernameTextBox.Text, passwordTextBox.Text, emailTextBox.Text, phoneTextBox.Text, stat);
                        r.showUsers(displayDataGridView, userIDGV, NameGV, UserNameGV, passGV, EmailGV, PhoneGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (supplierTextBox.Text == "")
            {
                supplierNameErrorLabel.Visible = true;
            }
            else
            {
                supplierNameErrorLabel.Visible = false;
            }
            if (personNameTextBox.Text == "")
            {
                contactPersonLabel.Visible = true;
            }
            else
            {
                contactPersonLabel.Visible = false;
            }
            if (phone1TextBox.Text == "")
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }
            if (addressTextBox.Text == "")
            {
                addressErrorLabel.Visible = true;
            }
            else
            {
                addressErrorLabel.Visible = false;
            }
            if (statusComboBox.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (supplierNameErrorLabel.Visible || contactPersonLabel.Visible || phoneErrorLabel.Visible ||
                addressErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (statusComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();

                    if (phone2TextBox.Text == "" && nTNTextBox.Text != "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, nTNTextBox.Text);
                    }
                    else if (phone2TextBox.Text != "" && nTNTextBox.Text == "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, null);
                    }
                    else if (phone2TextBox.Text == "" && nTNTextBox.Text == "")
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, null);
                    }
                    else
                    {
                        i.insertSupplier(supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, nTNTextBox.Text);
                    }
                    r.showSuppliers(displayDataGridView, suppIDGV, comGV, conPerGV, phone1GV, phone2GV, addressGV,
                                    ntnGV, statusGV);
                    MainClass.disableReset(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.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (statusComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        if (phone2TextBox.Text == "" && nTNTextBox.Text != "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, nTNTextBox.Text);
                        }
                        else if (phone2TextBox.Text != "" && nTNTextBox.Text == "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, null);
                        }
                        else if (phone2TextBox.Text == "" && nTNTextBox.Text == "")
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, null, null);
                        }
                        else
                        {
                            u.updateSupplier(supplierId, supplierTextBox.Text, personNameTextBox.Text, phone1TextBox.Text, addressTextBox.Text, stat, phone2TextBox.Text, nTNTextBox.Text);
                        }

                        r.showSuppliers(displayDataGridView, suppIDGV, comGV, conPerGV, phone1GV, phone2GV, addressGV,
                                        ntnGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
Пример #23
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (categoryTextBox.Text == "")
            {
                categoryNameErrorLabel.Visible = true;
            }
            else
            {
                categoryNameErrorLabel.Visible = false;
            }


            if (isActiveComboBox.SelectedIndex == -1)
            {
                isActiveErrorLabel.Visible = true;
            }
            else
            {
                isActiveErrorLabel.Visible = false;
            }

            if (isActiveErrorLabel.Visible || categoryNameErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (isActiveComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (isActiveComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();


                    i.insertCat(categoryTextBox.Text, stat);
                    r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);
                    MainClass.disableReset(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.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (isActiveComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (isActiveComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catId, categoryTextBox.Text, stat);
                        r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }