Esempio n. 1
0
        private void dgProducts_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 10)
            {
                editItemPage.itemCode         = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                editItemPage.txtItemName.Text = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                editItemPage.txtItemCode.Text = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                editItemPage.txtUm.Text       = senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
                editItemPage.txtDesc.Text     = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString();
                editItemPage.cmbSupp.Text     = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString();
                editItemPage.txtBrand.Text    = senderGrid.Rows[e.RowIndex].Cells[5].Value.ToString();
                editItemPage.txtCost.Text     = senderGrid.Rows[e.RowIndex].Cells[6].Value.ToString();
                editItemPage.txtSrp.Text      = senderGrid.Rows[e.RowIndex].Cells[7].Value.ToString();
                editItemPage.cmbItemType.Text = senderGrid.Rows[e.RowIndex].Cells[8].Value.ToString();

                editItemPage.btnSave.Click += BtnSave_Click;

                editItemPage.ShowDialog();
            }
            else if (e.ColumnIndex == 11)
            {
                StringBuilder whereDelProd  = new StringBuilder();
                StringBuilder valuesDelProd = new StringBuilder();

                StringBuilder whereDelInv  = new StringBuilder();
                StringBuilder valuesDelInv = new StringBuilder();

                DialogResult delRes = MessageBox.Show("Are you sure you want to delete this Product?", "Delete Product?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (delRes == DialogResult.Yes)
                {
                    whereDelProd.Append("gc_item_code");
                    valuesDelProd.Append(senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString());

                    whereDelInv.Append("gc_item_code");
                    valuesDelInv.Append(senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString());

                    db.GCDeleteFromDb("inventory", valuesDelInv, whereDelInv);
                    db.GCDeleteFromDb("products", valuesDelProd, whereDelProd);

                    notification = new notification("Product has been deleted.", notification.AlertType.success);
                    notification.ShowDialog();
                    DataTable dt = db.GCSelectFromDb("products", null, null, "ORDER BY id DESC");
                    dgProducts.DataSource = null;
                    dgProducts.DataSource = dt;
                }
            }
        }
Esempio n. 2
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            StringBuilder where = new StringBuilder();
            StringBuilder value = new StringBuilder();

            DialogResult dialog = MessageBox.Show("Are you sure you want to delete this item?", "Delete Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                where.Append("gc_item_name,gc_item_brand,gc_item_supp");
                value.Append(
                    deliveryInfoPage.itemName + "," +
                    deliveryInfoPage.itemBrand + "," +
                    deliveryInfoPage.itemSupp
                    );

                db.GCDeleteFromDb("delivery", value, where);

                DataTable dt = db.GCSelectFromDb("delivery", null, null);
                dgDelivery.DataSource = null;
                dgDelivery.DataSource = dt;

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

                valuesTransDel.Append(
                    "delivery," +
                    "delivered," +
                    int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                    int.Parse(deliveryInfoPage.txtQty.Text) + "," +
                    DateTime.Now.ToString("MM/dd/yyyy") + "," +
                    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
                    );

                transaction.insertToTrans(valuesTransDel);
                deliveryInfoPage.btnDelete.Click -= BtnDelete_Click;
            }
            deliveryInfoPage.btnDelete.Click -= BtnDelete_Click;
            deliveryInfoPage.Close();
        }
Esempio n. 3
0
        private void dgUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 6)
            {
                editPage.txtFullName.Text  = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                editPage.txtUsername.Text  = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                editPage.txtPass.Text      = senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
                editPage.txtEmail.Text     = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString();
                editPage.txtContact.Text   = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString();
                editPage.txtOtherInfo.Text = senderGrid.Rows[e.RowIndex].Cells[5].Value.ToString();

                editPage.lblFullName.Text = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                editPage.lblUserName.Text = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                editPage.lblEmail.Text    = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString();
                editPage.lblContact.Text  = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString();

                uname = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                pword = senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString();

                editPage.btnUpdate.Click += BtnUpdate_Click;

                editPage.ShowDialog();
            }
            else if (e.ColumnIndex == 7)
            {
                uname = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                pword = senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
                StringBuilder whereDel = new StringBuilder();
                StringBuilder valDel   = new StringBuilder();

                whereDel.Append("username,password");
                valDel.Append(uname + "," + pword);

                DialogResult delRes = MessageBox.Show("Are you sure you want to delete this record?", "Delete record?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (delRes == DialogResult.Yes)
                {
                    db.GCDeleteFromDb("users", valDel, whereDel);

                    DataTable dt = db.GCSelectFromDb("users", null, null);
                    dgUsers.DataSource = null;
                    dgUsers.DataSource = dt;

                    editPage.btnUpdate.Click -= BtnUpdate_Click;

                    notification = new notification("Successfully updated deleted Record.", notification.AlertType.success);
                    notification.ShowDialog();
                }
            }
        }
Esempio n. 4
0
        private void dgSuppliers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 5)
            {
                editSuppPage.txtSuppName.Text  = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                editSuppPage.txtAddress.Text   = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                editSuppPage.txtContact.Text   = senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
                editSuppPage.txtEmail.Text     = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString();
                editSuppPage.txtOtherInfo.Text = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString();

                editSuppPage.suppName = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();

                editSuppPage.btnUpdate.Click += BtnUpdate_Click;

                editSuppPage.ShowDialog();
            }
            else if (e.ColumnIndex == 6)
            {
                StringBuilder whereDelSupp  = new StringBuilder();
                StringBuilder valuesDelSupp = new StringBuilder();
                DialogResult  delRes        = MessageBox.Show("Are you sure you want to delete this supplier?", "Delete Supplier?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (delRes == DialogResult.Yes)
                {
                    whereDelSupp.Append("gc_supp_name");
                    valuesDelSupp.Append(senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                    db.GCDeleteFromDb("suppliers", valuesDelSupp, whereDelSupp);

                    notification = new notification("Supplier has been deleted.", notification.AlertType.success);
                    notification.ShowDialog();
                    DataTable dt = db.GCSelectFromDb("suppliers", null, null);
                    dgSuppliers.DataSource = null;
                    dgSuppliers.DataSource = dt;
                }
            }
        }
        private void dgTransHistory_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 7)
            {
                StringBuilder where = new StringBuilder();
                StringBuilder param = new StringBuilder();

                param.Append(
                    "gc_item_name," +
                    "gc_item_code," +
                    "gc_item_qty," +
                    "gc_item_srp," +
                    "gc_item_cost," +
                    "gc_um," +
                    "gc_item_desc," +
                    "gc_curr_qty," +
                    "gc_cust_cash," +
                    "gc_cust_change," +
                    "gc_customer_name," +
                    "gc_customer_add," +
                    "gc_unique_id"
                    );

                where.Append(
                    "gc_unique_id='" + senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "' " +
                    "AND gc_customer_name='" + senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString() + "'"
                    );

                DataTable dt = db.GCSelectFromDb("transact", param, where);
                transPage.lvCart.Items.Clear();
                foreach (DataRow row in dt.Rows)
                {
                    items[0] = row[0].ToString();
                    items[1] = row[1].ToString();
                    items[2] = row[2].ToString();
                    items[3] = row[3].ToString();
                    items[4] = row[4].ToString();
                    items[5] = row[5].ToString();
                    items[6] = row[6].ToString();
                    items[7] = row[7].ToString();
                    transPage.txtCustomerName.Text = row[10].ToString();
                    transPage.txtAddress.Text      = row[11].ToString();
                    transPage.txtCash.Text         = row[8].ToString();
                    transID = row[12].ToString();
                    ListViewItem lvi = new ListViewItem(items);
                    transPage.lvCart.Items.Add(lvi);
                }
                //transPage.lblTotal.Text = row[12].ToString();

                transPage.btnSaveTrans.Text = "Update Transaction";
                transPage.SaveMode          = false;

                totalPrice = 0;

                foreach (ListViewItem lviTotal in transPage.lvCart.Items)
                {
                    totalPrice += float.Parse(lviTotal.SubItems[3].Text) * float.Parse(lviTotal.SubItems[2].Text);
                }

                transPage.lblTotal.Text = totalPrice.ToString();

                transPage.btnSaveTrans.Click += BtnSaveTrans_Click;

                transPage.ShowDialog();
            }
            else if (e.ColumnIndex == 8)
            {
                receiptPage.transID = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                receiptPage.ShowDialog();
            }
            else if (e.ColumnIndex == 9)
            {
                DialogResult delTransHist = MessageBox.Show("Are you sure you want to delete this purchase history?", "Delete purchased History?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (delTransHist == DialogResult.Yes)
                {
                    StringBuilder whereDelHist  = new StringBuilder();
                    StringBuilder valuesDelHist = new StringBuilder();
                    StringBuilder whereHist     = new StringBuilder();
                    StringBuilder paramHist     = new StringBuilder();

                    paramHist.Append("DISTINCT gc_unique_id,gc_customer_name,gc_customer_add,gc_trans_date,gc_cust_cash,gc_cust_change");
                    whereHist.Append("gc_from_tbl='sales'");

                    whereDelHist.Append("gc_unique_id,gc_customer_name");
                    valuesDelHist.Append(
                        senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "," +
                        senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString()
                        );
                    db.GCDeleteFromDb("transact", valuesDelHist, whereDelHist);

                    dgTransHistory.DataSource = null;
                    DataTable dtDelHist = db.GCSelectFromDb("transact", paramHist, whereHist);
                    dgTransHistory.DataSource = dtDelHist;

                    notification = new notification("Purchased history deleted", notification.AlertType.error);
                    notification.ShowDialog();
                }
            }
        }
Esempio n. 6
0
        private void dgStock_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 12)
            {
                try
                {
                    itemName  = senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
                    itemCode  = senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
                    qty       = int.Parse(senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString());
                    itemDesc  = senderGrid.Rows[e.RowIndex].Cells[3].Value.ToString();
                    itemSupp  = senderGrid.Rows[e.RowIndex].Cells[4].Value.ToString();
                    itemBrand = senderGrid.Rows[e.RowIndex].Cells[5].Value.ToString();
                    itemUm    = senderGrid.Rows[e.RowIndex].Cells[6].Value.ToString();
                    itemCost  = float.Parse(senderGrid.Rows[e.RowIndex].Cells[7].Value.ToString());
                    itemSrp   = float.Parse(senderGrid.Rows[e.RowIndex].Cells[8].Value.ToString());
                    itemType  = senderGrid.Rows[e.RowIndex].Cells[10].Value.ToString();

                    stockAddPage.btnAddQty.Click += BtnAddQty_Click;
                    stockAddPage.ShowDialog();
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message);
                }
            }
            else if (e.ColumnIndex == 11)
            {
                StringBuilder whereDel  = new StringBuilder();
                StringBuilder valuesDel = new StringBuilder();

                StringBuilder paramInvUpdate  = new StringBuilder();
                StringBuilder valuesInvUpdate = new StringBuilder();
                StringBuilder whereInvUpdate  = new StringBuilder();

                StringBuilder paramInvAdd = new StringBuilder();
                StringBuilder whereInvAdd = new StringBuilder();

                DialogResult delRes = MessageBox.Show("Are you sure you want to delete this stock?", "Delete Supplier?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (delRes == DialogResult.Yes)
                {
                    paramInvAdd.Append("gc_item_qty");
                    whereInvAdd.Append("gc_item_code='" + senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString() + "'");
                    DataTable dtInv = db.GCSelectFromDb("inventory", paramInvAdd, whereInvAdd);
                    foreach (DataRow row in dtInv.Rows)
                    {
                        currInventory = int.Parse(row[0].ToString());
                    }
                    whereDel.Append("gc_item_code");
                    valuesDel.Append(senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString());
                    db.GCDeleteFromDb("stock", valuesDel, whereDel);

                    paramInvUpdate.Append("gc_item_qty");
                    valuesInvUpdate.Append(currInventory + int.Parse(senderGrid.Rows[e.RowIndex].Cells[2].Value.ToString()));
                    whereInvUpdate.Append("gc_item_code='" + senderGrid.Rows[e.RowIndex].Cells[1].Value.ToString() + "'");
                    db.GCUpdateDb("inventory", paramInvUpdate, valuesInvUpdate, whereInvUpdate);

                    notification = new notification("Stock has been deleted.", notification.AlertType.success);
                    notification.ShowDialog();

                    dgStock.DataSource = null;
                    DataTable dtRemove = db.GCSelectFromDb("stock", null, null, "ORDER BY id DESC");
                    dgStock.DataSource = dtRemove;
                }
            }
        }