Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            StringBuilder where = new StringBuilder();
            where.Append("username='******' AND password='******'");
            int resUser = db.searchData("users", null, where);

            if (resUser >= 1)
            {
                notification notification = new notification("Username or password already existing.", notification.AlertType.error);
                notification.ShowDialog();
            }
            else if (txtUsername.Text != "" && txtPassword.Text != "" && txtFullName.Text != "")
            {
                StringBuilder param  = new StringBuilder();
                StringBuilder values = new StringBuilder();

                param.Append(
                    "username," +
                    "password," +
                    "email," +
                    "contact," +
                    "other_info," +
                    "full_name"
                    );

                values.Append(
                    txtUsername.Text + "," +
                    txtPassword.Text + "," +
                    txtEmail.Text + "," +
                    txtContact.Text + "," +
                    txtOtherInfo.Text + "," +
                    txtFullName.Text
                    );

                db.GCInsertToDb("users", param, values);
                notification notification = new notification("User has been saved to the database.", notification.AlertType.success);
                notification.Show();

                DataTable dt = db.GCSelectFromDb("users", null, null);
                dgUsers.DataSource = null;
                dgUsers.DataSource = dt;
            }
            else
            {
                notification notification = new notification("Check the fields before saving.", notification.AlertType.error);
                notification.Show();
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtSuppName.Text != "" && txtContact.Text != "")
            {
                StringBuilder whereSearch = new StringBuilder();
                whereSearch.Append("gc_supp_name LIKE '" + txtSuppName.Text + "'");
                int resSupp = db.searchData("suppliers", null, whereSearch);

                if (resSupp >= 1)
                {
                    notification = new notification("Supplier already existing.", notification.AlertType.error);
                    notification.ShowDialog();
                }
                else
                {
                    StringBuilder param  = new StringBuilder();
                    StringBuilder values = new StringBuilder();

                    param.Append(
                        "gc_supp_name," +
                        "gc_supp_add," +
                        "gc_contact," +
                        "gc_email," +
                        "gc_other_info"
                        );

                    values.Append(
                        txtSuppName.Text + "," +
                        txtAddress.Text + "," +
                        txtContact.Text + "," +
                        txtEmail.Text + "," +
                        txtOtherInfo.Text
                        );

                    db.GCInsertToDb("suppliers", param, values);

                    DataTable dt = db.GCSelectFromDb("suppliers", null, null);
                    dgSuppliers.DataSource = null;
                    dgSuppliers.DataSource = dt;

                    notification = new notification("Supplier saved to the database.", notification.AlertType.success);
                    notification.ShowDialog();
                }
            }
        }
Esempio n. 3
0
        public void updateTrans(string tblname, string itemCode, string actionName, int itemQty, int currQty, string itmName)
        {
            string        randID = view.Random("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 5);
            StringBuilder param  = new StringBuilder();
            StringBuilder values = new StringBuilder();

            param.Append("gc_from_tbl,gc_action_name,gc_item_qty,gc_curr_qty,gc_trans_date,gc_unique_id,gc_item_code,gc_item_name,gc_total_price");
            values.Append(
                tblname + "," +
                actionName + "," +
                itemQty + "," +
                currQty + "," +
                DateTime.ParseExact(DateTime.Now.ToShortDateString(), "MM/dd/yyyy", CultureInfo.InvariantCulture) + "," +
                randID + "," +
                itemCode + "," +
                itmName + "," +
                itemSrp * itemQty
                );
            db.GCInsertToDb("transact", param, values);
        }
Esempio n. 4
0
        private void BtnAddQty_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder paramInv    = new StringBuilder();
                StringBuilder whereInv    = new StringBuilder();
                StringBuilder whereSearch = new StringBuilder();

                whereSearch.Append("gc_item_code='" + itemCode + "'");
                int resItemCode = db.searchData("stock", null, whereSearch);

                paramInv.Append("gc_item_qty");
                whereInv.Append("gc_item_code='" + itemCode + "'");

                DataTable dtInv = db.GCSelectFromDb("inventory", paramInv, whereInv);
                foreach (DataRow rowInv in dtInv.Rows)
                {
                    currInventory = int.Parse(rowInv[0].ToString());
                }

                if (currInventory >= int.Parse(invQtyPage.txtQty.Text))
                {
                    StringBuilder param = new StringBuilder();
                    StringBuilder where = new StringBuilder();

                    param.Append("gc_item_qty");
                    where.Append("gc_item_code='" + itemCode + "'");

                    DataTable dt = db.GCSelectFromDb("stock", param, where);
                    foreach (DataRow row in dt.Rows)
                    {
                        currStock = int.Parse(row[0].ToString());
                    }

                    if (resItemCode == 1)
                    {
                        StringBuilder paramUpdate  = new StringBuilder();
                        StringBuilder valuesUpdate = new StringBuilder();
                        StringBuilder whereUpdate  = new StringBuilder();

                        whereUpdate.Append("gc_item_code='" + itemCode + "'");
                        paramUpdate.Append("gc_item_qty");
                        valuesUpdate.Append(currStock + int.Parse(invQtyPage.txtQty.Text));
                        db.GCUpdateDb("stock", paramUpdate, valuesUpdate, whereUpdate);
                        notification = new notification("Stock has been updated", notification.AlertType.success);
                        notification.ShowDialog();
                        invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
                    }
                    else
                    {
                        StringBuilder paramInsert  = new StringBuilder();
                        StringBuilder valuesInsert = new StringBuilder();

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

                        valuesInsert.Append(
                            itemName + "," +
                            int.Parse(invQtyPage.txtQty.Text) + "," +
                            itemDesc + "," +
                            itemSupp + "," +
                            itemBrand + "," +
                            itemUm + "," +
                            itemCost + "," +
                            itemSrp + "," +
                            DateTime.Today.ToString("MM/dd/yyyy") + "," +
                            itemCode + "," +
                            itemType
                            );
                        db.GCInsertToDb("stock", paramInsert, valuesInsert);
                        notification = new notification("Item has been added to stock!", notification.AlertType.success);
                        notification.ShowDialog();
                        invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
                    }

                    updateTrans("stock", itemCode, "in", int.Parse(invQtyPage.txtQty.Text), currStock, itemName);

                    StringBuilder paramUpdateInv = new StringBuilder();
                    StringBuilder valuesUpdteInv = new StringBuilder();
                    StringBuilder whereUpdateInv = new StringBuilder();

                    whereUpdateInv.Append("gc_item_code='" + itemCode + "'");
                    paramUpdateInv.Append("gc_item_qty");

                    valuesUpdteInv.Append(currInventory - int.Parse(invQtyPage.txtQty.Text));
                    db.GCUpdateDb("inventory", paramUpdateInv, valuesUpdteInv, whereUpdateInv);
                    updateTrans("inventory", itemCode, "out", int.Parse(invQtyPage.txtQty.Text), currInventory, itemName);


                    dgStock.DataSource = null;

                    DataTable dtRefresh = db.GCSelectFromDb("inventory", null, null, "ORDER BY id DESC");
                    dgStock.DataSource          = dtRefresh;
                    invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
                }
                else
                {
                    MessageBox.Show("Not enough item on inventory", "Inventory Dont have enought Item", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                    invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
                invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
            }

            invQtyPage.btnAddQty.Click -= BtnAddQty_Click;
            dgStock.Refresh();
            invQtyPage.Close();
        }
Esempio n. 5
0
        private void BtnMove_Click(object sender, EventArgs e)
        {
            StringBuilder param       = new StringBuilder();
            StringBuilder values      = new StringBuilder();
            StringBuilder whereSave   = new StringBuilder();
            StringBuilder whereSearch = new StringBuilder();

            StringBuilder paramInv = new StringBuilder();
            StringBuilder whereInv = new StringBuilder();

            StringBuilder valuesUpdate = new StringBuilder();
            StringBuilder paramUpdate  = new StringBuilder();
            StringBuilder whereUpdate  = new StringBuilder();

            StringBuilder whereDelivUpdateStat  = new StringBuilder();
            StringBuilder paramDelivUpdateStat  = new StringBuilder();
            StringBuilder valuesDelivUpdateStat = new StringBuilder();

            //StringBuilder whereDelete = new StringBuilder();
            //StringBuilder valueDelete = new StringBuilder();

            DialogResult dialogMove = MessageBox.Show("Are you sure you want to move item to inventory?", "Move Item to inventory", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogMove == DialogResult.Yes && deliveryInfoPage.txtItemCode.Text != "")
            {
                whereSave.Append("gc_item_code='" + deliveryInfoPage.txtItemCode.Text + "'");
                int invRes = db.searchData("inventory", null, whereSave);
                if (invRes >= 1)
                {
                    try
                    {
                        paramInv.Append("gc_item_qty");
                        whereInv.Append("gc_item_name='" + deliveryInfoPage.itemName + "'");
                        whereInv.Append(" AND gc_item_supp='" + deliveryInfoPage.itemSupp + "'");
                        whereInv.Append(" AND gc_item_brand='" + deliveryInfoPage.itemBrand + "'");

                        DataTable dt = db.GCSelectFromDb("inventory", paramInv, whereInv);
                        foreach (DataRow row in dt.Rows)
                        {
                            currInventory = int.Parse(row[0].ToString());
                        }

                        paramUpdate.Append("gc_item_qty");
                        valuesUpdate.Append(currInventory + int.Parse(deliveryInfoPage.txtQty.Text));

                        whereUpdate.Append("gc_item_name='" + deliveryInfoPage.itemName + "'");
                        whereUpdate.Append(" AND gc_item_brand='" + deliveryInfoPage.itemBrand + "'");
                        whereUpdate.Append(" AND gc_item_supp='" + deliveryInfoPage.itemSupp + "'");

                        whereDelivUpdateStat.Append("gc_item_name='" + deliveryInfoPage.itemName + "'");
                        whereDelivUpdateStat.Append(" AND gc_item_supp='" + deliveryInfoPage.itemSupp + "'");
                        whereDelivUpdateStat.Append(" AND gc_item_brand='" + deliveryInfoPage.itemBrand + "'");
                        paramDelivUpdateStat.Append("gc_item_status");
                        valuesDelivUpdateStat.Append("Delivered");
                        //whereDelete.Append("gc_item_name,gc_item_brand,gc_item_supp");
                        //valueDelete.Append(deliveryInfoPage.itemName + "," + deliveryInfoPage.itemBrand + "," + deliveryInfoPage.itemSupp);

                        db.GCUpdateDb("delivery", paramDelivUpdateStat, valuesDelivUpdateStat, whereDelivUpdateStat);
                        db.GCUpdateDb("inventory", paramUpdate, valuesUpdate, whereUpdate);
                        //db.GCDeleteFromDb("delivery", valueDelete, whereDelete);

                        string        randID          = view.Random("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 5);
                        StringBuilder valuesTransMove = new StringBuilder();

                        valuesTransMove.Append(
                            "inventory," +
                            "in," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            DateTime.Now.ToShortDateString() + "," +
                            randID + DateTime.Now.Millisecond.ToString() + "," +
                            deliveryInfoPage.txtItemCode.Text + "," +
                            "none" + "," +
                            "none" + "," +
                            deliveryInfoPage.txtUm.Text + "," +
                            deliveryInfoPage.txtDesc.Text + "," +
                            deliveryInfoPage.txtItemName.Text + "," +
                            float.Parse(deliveryInfoPage.txtQty.Text) * float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtSrp.Text) + "," +
                            0 + "," +
                            0 + "," +
                            0
                            );

                        transaction.insertToTrans(valuesTransMove);

                        foreach (Control ctrl in deliveryInfoPage.Controls)
                        {
                            if (ctrl.GetType() == typeof(TextBox))
                            {
                                ctrl.Text = "";
                            }
                        }

                        DataTable dtDelivery = db.GCSelectFromDb("delivery", null, null);
                        dgDelivery.DataSource = null;
                        dgDelivery.DataSource = dtDelivery;
                    }
                    catch (Exception a)
                    {
                        MessageBox.Show(a.Message);
                    }
                }
                else
                {
                    try
                    {
                        //StringBuilder whereDeleteDelivery = new StringBuilder();
                        //StringBuilder valueDeleteDelivery = new StringBuilder();
                        StringBuilder whereDelivUpdate  = new StringBuilder();
                        StringBuilder paramDelivUpdate  = new StringBuilder();
                        StringBuilder valuesDelivUpdate = new StringBuilder();

                        StringBuilder paramSave = new StringBuilder();
                        StringBuilder valueSave = new StringBuilder();

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

                        valueSave.Append(
                            deliveryInfoPage.txtItemName.Text + "," +
                            deliveryInfoPage.cmbSupp.Text + "," +
                            deliveryInfoPage.txtBrand.Text + "," +
                            deliveryInfoPage.cmbItemStatus.Text + "," +
                            float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtSrp.Text) + "," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            deliveryInfoPage.txtItemCode.Text + "," +
                            deliveryInfoPage.cmbItemType.Text + "," +
                            deliveryInfoPage.txtDesc.Text + "," +
                            deliveryInfoPage.txtUm.Text
                            );

                        db.GCInsertToDb("inventory", paramSave, valueSave);


                        string        randIDDel          = view.Random("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 5);
                        StringBuilder valuesTransMoveDel = new StringBuilder();

                        valuesTransMoveDel.Append(
                            "delivery," +
                            "moved to inventory," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            DateTime.Now.ToShortDateString() + "," +
                            randIDDel + DateTime.Now.Millisecond.ToString() + "," +
                            deliveryInfoPage.txtItemCode.Text + "," +
                            "none" + "," +
                            "none" + "," +
                            deliveryInfoPage.txtUm.Text + "," +
                            deliveryInfoPage.txtDesc.Text + "," +
                            deliveryInfoPage.txtItemName.Text + "," +
                            float.Parse(deliveryInfoPage.txtQty.Text) * float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtSrp.Text) + "," +
                            0 + "," +
                            0 + "," +
                            0
                            );

                        string        randID          = view.Random("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 5);
                        StringBuilder valuesTransMove = new StringBuilder();

                        valuesTransMove.Append(
                            "inventory," +
                            "in," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                            DateTime.Now.ToShortDateString() + "," +
                            randID + DateTime.Now.Millisecond.ToString() + "," +
                            deliveryInfoPage.txtItemCode.Text + "," +
                            "none" + "," +
                            "none" + "," +
                            deliveryInfoPage.txtUm.Text + "," +
                            deliveryInfoPage.txtDesc.Text + "," +
                            deliveryInfoPage.txtItemName.Text + "," +
                            float.Parse(deliveryInfoPage.txtQty.Text) * float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtCost.Text) + "," +
                            float.Parse(deliveryInfoPage.txtSrp.Text) + "," +
                            0 + "," +
                            0 + "," +
                            0
                            );

                        transaction.insertToTrans(valuesTransMove);
                        transaction.insertToTrans(valuesTransMoveDel);

                        foreach (Control ctrl in deliveryInfoPage.Controls)
                        {
                            if (ctrl.GetType() == typeof(TextBox))
                            {
                                ctrl.Text = "";
                            }
                        }

                        whereDelivUpdateStat.Append("gc_item_name='" + deliveryInfoPage.itemName + "'");
                        whereDelivUpdateStat.Append(" AND gc_item_supp='" + deliveryInfoPage.itemSupp + "'");
                        whereDelivUpdateStat.Append(" AND gc_item_brand='" + deliveryInfoPage.itemBrand + "'");
                        paramDelivUpdateStat.Append("gc_item_status");
                        valuesDelivUpdateStat.Append("Delivered");

                        db.GCUpdateDb("delivery", paramDelivUpdateStat, valuesDelivUpdateStat, whereDelivUpdateStat);

                        //whereDeleteDelivery.Append("gc_item_name,gc_item_supp,gc_item_brand");

                        /*valueDeleteDelivery.Append(
                         *  deliveryInfoPage.itemName + "," +
                         *  deliveryInfoPage.itemSupp + "," +
                         *  deliveryInfoPage.itemBrand
                         * );*/

                        //db.GCDeleteFromDb("delivery", valueDeleteDelivery, whereDeleteDelivery);

                        DataTable dtDelivery = db.GCSelectFromDb("delivery", null, null);
                        dgDelivery.DataSource = null;
                        dgDelivery.DataSource = dtDelivery;
                    }
                    catch (Exception a)
                    {
                        MessageBox.Show(a.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please check if all fields have value. Before moving to inventory please put an Item code.", "Some fields are not valid.", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }

            deliveryInfoPage.btnMove.Click -= BtnMove_Click;
            deliveryInfoPage.Close();
        }
Esempio n. 6
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();
            }
        }