Пример #1
0
 private void progressTimer_Tick(object sender, EventArgs e)
 {
     if (pBar.Value <= 99)
     {
         pBar.Value      = counter;
         lblPercent.Text = counter.ToString() + "%";
     }
     else
     {
         progressTimer.Stop();
         this.Hide();
         main = new Inventory_Main();
         main.Show();
         notification notification = new notification("Welcome Admin!", notification.AlertType.info);
         notification.ShowDialog();
     }
     counter++;
 }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            StringBuilder whereSearch      = new  StringBuilder();
            StringBuilder whereSearchInv   = new StringBuilder();
            StringBuilder whereSearchStock = new StringBuilder();

            main = new Inventory_Main();
            whereSearch.Append("gc_item_code='" + txtItemCode.Text + "'");
            whereSearchInv.Append("gc_item_code='" + txtItemCode.Text + "'");
            whereSearchStock.Append("gc_item_code='" + txtItemCode.Text + "'");
            int resInv   = db.searchData("inventory", null, whereSearchInv);
            int resStock = db.searchData("stock", null, whereSearchStock);
            int resProd  = db.searchData("products", null, whereSearch);

            if (resProd >= 1 || resInv >= 1 || resStock >= 1)
            {
                notification = new notification("Item Code is already existing.", notification.AlertType.error);
                notification.ShowDialog();
            }
            else if (txtItemName.Text != "" && txtItemCode.Text != "")
            {
                try
                {
                    StringBuilder param          = new StringBuilder();
                    StringBuilder paramInv       = new StringBuilder();
                    StringBuilder values         = new StringBuilder();
                    StringBuilder valuesInv      = new StringBuilder();
                    StringBuilder whereInvSearch = new StringBuilder();

                    StringBuilder paramStock  = new StringBuilder();
                    StringBuilder valuesStock = new StringBuilder();

                    param.Append(
                        "gc_item_name," +
                        "gc_item_code," +
                        "gc_item_brand," +
                        "gc_item_type," +
                        "gc_item_supp," +
                        "gc_item_um," +
                        "gc_item_cost," +
                        "gc_item_srp," +
                        "gc_item_desc," +
                        "gc_item_status"
                        );

                    values.Append(
                        txtItemName.Text + "," +
                        txtItemCode.Text + "," +
                        txtBrand.Text + "," +
                        cmbItemType.Text + "," +
                        cmbSupp.Text + "," +
                        txtUm.Text + "," +
                        float.Parse(txtCost.Text) + "," +
                        float.Parse(txtSrp.Text) + "," +
                        txtDesc.Text + "," +
                        cmbStatus.Text
                        );

                    paramInv.Append(
                        "gc_item_name," +
                        "gc_item_code," +
                        "gc_item_brand," +
                        "gc_item_type," +
                        "gc_item_supp," +
                        "gc_item_um," +
                        "gc_item_cost," +
                        "gc_item_srp," +
                        "gc_item_desc," +
                        "gc_item_status," +
                        "gc_item_qty"
                        );

                    valuesInv.Append(
                        txtItemName.Text + "," +
                        txtItemCode.Text + "," +
                        txtBrand.Text + "," +
                        cmbItemType.Text + "," +
                        cmbSupp.Text + "," +
                        txtUm.Text + "," +
                        float.Parse(txtCost.Text) + "," +
                        float.Parse(txtSrp.Text) + "," +
                        txtDesc.Text + "," +
                        "registered," +
                        int.Parse(txtInvQty.Text)
                        );

                    whereInvSearch.Append("gc_item_code='" + txtItemCode.Text + "'");
                    int invSearch = db.searchData("inventory", null, whereInvSearch);
                    if (invSearch <= 0)
                    {
                        db.GCInsertToDb("inventory", paramInv, valuesInv);
                    }

                    paramStock.Append(
                        "gc_item_name," +
                        "gc_item_code," +
                        "gc_item_brand," +
                        "gc_item_type," +
                        "gc_item_supp," +
                        "gc_item_um," +
                        "gc_item_cost," +
                        "gc_item_srp," +
                        "gc_item_desc," +
                        "gc_item_status," +
                        "gc_item_qty"
                        );

                    valuesStock.Append(
                        txtItemName.Text + "," +
                        txtItemCode.Text + "," +
                        txtBrand.Text + "," +
                        cmbItemType.Text + "," +
                        cmbSupp.Text + "," +
                        txtUm.Text + "," +
                        float.Parse(txtCost.Text) + "," +
                        float.Parse(txtSrp.Text) + "," +
                        txtDesc.Text + "," +
                        "registered," +
                        int.Parse(txtStockQty.Text)
                        );

                    db.GCInsertToDb("stock", paramStock, valuesStock);
                    db.GCInsertToDb("products", param, values);

                    DataTable dt = db.GCSelectFromDb("products", null, null, "ORDER BY id DESC");
                    dgProducts.DataSource = null;
                    dgProducts.DataSource = dt;



                    notification = new notification("Product saved to the database", notification.AlertType.success);
                    notification.ShowDialog();
                }
                catch (Exception a)
                {
                    notification = new notification("Please check the values on the fields. : ", notification.AlertType.error);
                    notification.ShowDialog();
                }
            }
            else
            {
                notification = new notification("Please check the values on the fields.", notification.AlertType.error);
                notification.ShowDialog();
            }
        }