Example #1
0
        public void orderItem(string a)
        {
            sqlCommandAB o     = new sqlCommandAB();
            DataTable    dt    = o.QueryDT("SELECT * FROM OrderItem " + a);
            int          count = dt.Rows.Count;

            string[] dr;
            for (int i = 0; i < count; i++)
            {
                dr = new string[] { (string)dt.Rows[i]["pCode"], (string)dt.Rows[i]["pName"], dt.Rows[i]["pSellingPrice"].ToString(), dt.Rows[i]["pQuantity"].ToString(), dt.Rows[i]["pTotalAmount"].ToString() };
                dataGridView2.Rows.Add(dr);
            }

            DataTable dz = o.QueryDT("SELECT * FROM Payment " + a);
            int       c  = dz.Rows.Count;

            if (c > 0)
            {
                groupBox2.Visible = true;
                grandTotal.Text   = "R" + dz.Rows[0]["OrderAmount"].ToString();
                pAmount.Text      = "R" + dz.Rows[0]["pAmount"].ToString();
                pChange.Text      = "R" + dz.Rows[0]["pChange"].ToString();
                pMode.Text        = dz.Rows[0]["pType"].ToString();
            }
        }
Example #2
0
        public MainPos()
        {
            InitializeComponent();
            currentOrderNum = makeInvoicNumber();
            DataTable data = posSql.QueryDT("Select * FROM OrderItem");

            cart  = new DataTable();
            cart2 = new DataTable();
            cart3 = new DataTable();
            string[] columns  = { "pName", "pCode", "pSellingPrice", "pQuantity", "pTotalAmount", };
            string[] columns2 = { "Order_Number", "pName", "pCode", "pSellingPrice", "pQuantity", "pTotalAmount", "pDiscount", "pVAT" };
            for (int i = 0; i < columns.Length; i++)
            {
                cart.Columns.Add(new DataColumn(columns[i]));
            }
            for (int i = 0; i < columns2.Length; i++)
            {
                cart2.Columns.Add(new DataColumn(columns2[i]));
                cart3.Columns.Add(new DataColumn(columns2[i]));
            }

            invoiceTB.Text = currentOrderNum;
            executionPath  = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
            executionPath  = executionPath.Substring(6);
        }
Example #3
0
        public void InserPayment()
        {
            // MessageBox.Show((string)oNumberTB.Text + " " + (string)custNumberTB.Text + " " + Convert.ToDouble(orderAmount) + " " + Convert.ToInt32(orderQty) + " " +
            //     Convert.ToDouble(amountPaidTB.Text) + " " + (string)paymentCB.Text);
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    dt       = brandSql.QueryDT("SELECT * FROM Payment");
            DataRow      dr       = dt.NewRow();

            dr["Order_Number"]    = (string)oNumberTB.Text;
            dr["staff_Number"]    = (string)custNumberTB.Text;
            dr["Customer_Number"] = (string)custNumberTB.Text;
            dr["OrderAmount"]     = Convert.ToDouble(orderAmount);
            if (change > 0)
            {
                dr["pChange"] = Convert.ToDouble(change);
            }
            dr["OrderQuantity"] = Convert.ToInt32(orderQty);
            try
            {
                dr["pAmount"] = Convert.ToDouble(amountPaidTB.Text);
            }
            catch (Exception) {
                dr["pAmount"] = 0;
            }
            dr["pType"] = (string)paymentCB.Text;
            dt.Rows.Add(dr);
            brandSql.UpDate(dt);
        }
Example #4
0
        private void button6_Click(object sender, EventArgs e)
        {
            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

            string       a           = Convert.ToString(selectedRow.Cells["custNumber"].Value);
            sqlCommandAB customerSql = new sqlCommandAB();
            DialogResult dr          = MessageBox.Show("Are you sure you want to Delete " + nameTB.Text.ToString() + "Permanently?", "Confim Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dr == DialogResult.Yes)
            {
                if (sqlCommandAB.message != null)
                {
                    MessageBox.Show(sqlCommandAB.message);
                }
                else
                {
                    DataTable DT = customerSql.QueryDT("DELETE  FROM Customer where Customer_Number ='" + a + "' ");
                    dataGridView1.Rows.Clear();
                    Customer[] customer;
                    getCatData(out customer);
                    loadData();
                    Clear();
                }
            }
        }
Example #5
0
        private DataTable getUserLoginDetails(string a)
        {
            sqlCommandAB customerSql = new sqlCommandAB();
            DataTable    DT          = customerSql.QueryDT("SELECT staff_Number, staff_Username, staff_Password FROM Staff where staff_Number ='" + a + "' ");

            return(DT);
        }
Example #6
0
        private void deleteBTN_Click(object sender, EventArgs e)
        {
            int             selectedrowindex = dataGridView3.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow      = dataGridView3.Rows[selectedrowindex];

            string       a           = Convert.ToString(selectedRow.Cells["code"].Value);
            sqlCommandAB customerSql = new sqlCommandAB();
            DialogResult dr          = MessageBox.Show("Are you sure you want to Delete " + tb_itemName.Text.ToString() + "Permanently?", "Confim Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dr == DialogResult.Yes)
            {
                if (sqlCommandAB.message != null)
                {
                    MessageBox.Show(sqlCommandAB.message);
                }
                else
                {
                    DataTable DT = customerSql.QueryDT("DELETE  FROM Product where pCode ='" + a + "' ");
                    dataGridView3.Rows.Clear();
                    addProductForm[] products;
                    getProduct(out products);
                    loadData();
                    Clear();
                }
            }
        }
Example #7
0
        private void brandDBTN_Click(object sender, EventArgs e)
        {
            int selectedrowindex = dataGridView2.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView2.Rows[selectedrowindex];

            string       a           = Convert.ToString(selectedRow.Cells["brandNameDT"].Value);
            sqlCommandAB customerSql = new sqlCommandAB();
            int          id          = customerSql.getSingleValue("SELECT brandID FROM Brand WHERE( categoryName = '" + selectCat.SelectedItem.ToString() + "' AND brandName ='" + a + "')");


            DialogResult dr = MessageBox.Show("Are you sure you want to Delete " + brandNameTB.Text.ToString() + " Permanently?", "Confim Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dr == DialogResult.Yes)
            {
                DataTable DT = customerSql.QueryDT("DELETE  FROM Brand WHERE brandID = '" + id + "' AND brandName ='" + a + "' ");
                if (sqlCommandAB.message != null)
                {
                    MessageBox.Show(sqlCommandAB.message + "Couldn't delete " + a);
                }
                else
                {
                    dataGridView2.Rows.Clear();
                    CategorysAndBrand[] customer;
                    getBrandData(out customer);
                    Clear();
                }
            }
        }
Example #8
0
        public void getCustSearch(out Customer[] Cast_Array)
        {
            dataGridView1.Rows.Clear();
            string       allQ     = (string)textBox1.Text;
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM Customer WHERE ((Customer_IDNumber LIKE '" + allQ + "%') OR (Customer_Number LIKE '%" + allQ + "%')) OR (Customer_Name LIKE '%" + allQ + "%')");

            Cast_Array = null;
            if (sqlCommandAB.message != null)
            {
                MessageBox.Show(sqlCommandAB.message);
            }
            else
            {
                int rowCount = DT.Rows.Count;
                Cast_Array = new Customer[rowCount];
                string[] row;
                for (int j = 0; j < rowCount; j++)
                {
                    row = new string[] { (string)DT.Rows[j]["Customer_Number"], (string)DT.Rows[j]["Customer_Name"], (string)DT.Rows[j]["Customer_Surname"], DT.Rows[j]["Customer_Cell"].ToString(), (string)DT.Rows[j]["Customer_Address"] };
                    dataGridView1.Rows.Add(row);
                    loadData();
                }
            }
        }
Example #9
0
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            Clear();
            brandNameTB.Text = brandDescriptionTB.Text = "";
            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

            string a = Convert.ToString(selectedRow.Cells["CategoryName"].Value);

            sqlCommandAB customerSql = new sqlCommandAB();
            DataTable    DT          = customerSql.QueryDT("SELECT * FROM Category where categoryName ='" + a + "' ");

            CategoryNameTB.Text         = (string)DT.Rows[0]["categoryName"];
            Category_DescriptionTB.Text = (string)DT.Rows[0]["categoryDescription"];



            //This should fill the Brand Table
            dataGridView2.Rows.Clear();
            CategorysAndBrand[] brandArray;
            selectCat.SelectedItem = a;

            getBrandData(out brandArray, a);

            deleteBTN.Enabled = true;
            updateBTN.Enabled = true;
            saveBTN.Enabled   = false;
        }
Example #10
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Clear();
            disable();
            creditControl.Visible = true;
            saveBTN.Enabled       = false;


            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

            string a = Convert.ToString(selectedRow.Cells["custNumber"].Value);

            customer_Number = a;
            textBox2.Text   = getCreditA(a).ToString();
            balanceTB.Text  = getCreditB(a).ToString();

            sqlCommandAB customerSql = new sqlCommandAB();
            DataTable    DT          = customerSql.QueryDT("SELECT * FROM Customer where Customer_Number ='" + a + "' ");

            if (sqlCommandAB.message != null)
            {
                MessageBox.Show(sqlCommandAB.message);
            }
            else
            {
                populate(DT);
                deleteBTN.Enabled = true;
            }
            // MessageBox.Show((string)DT.Rows[0]["Customer_Surname"]);
        }
Example #11
0
        public void InsertNewProduct()
        {
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    dt       = brandSql.QueryDT("SELECT * FROM Product");
            DataRow      dr       = dt.NewRow();

            try { dr["categoryName"] = selectCat.SelectedItem.ToString(); }
            catch (NullReferenceException) {
                MessageBox.Show("Please Select a category first.");
            }

            dr["brandID"] = brandID;
            dr["pCode"]   = tb_itemBarCode.Text.ToString();
            dr["pName"]   = tb_itemName.Text.ToString();
            try
            {
                dr["pCostPrice"]    = Convert.ToDecimal(tb_itemStockPrice.Text);
                dr["pSellingPrice"] = Convert.ToDecimal(tb_itemSellingPrice.Text);
                dr["pReorderQty"]   = Convert.ToInt32(ReorderPoint.Value);
                dr["pQty"]          = Convert.ToInt32(qty.Value);
            }
            catch (FormatException) {
                MessageBox.Show("Check your input values");
            }
            dr["pDescription"] = tb_itemDescription.Text.ToString();
            // dr["pImage"] = imageString;


            dt.Rows.Add(dr);
            brandSql.UpDate(dt);
        }
Example #12
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int             rowIndex = dataGridView2.SelectedCells[0].RowIndex;
            DataGridViewRow dv       = dataGridView2.Rows[rowIndex];

            orderQty         = dv.Cells["OrderQuantity"].Value.ToString();
            orderAmount      = dv.Cells["OrderAmount"].Value.ToString();
            amountDueTB.Text = "R" + orderAmount;
            orderNumber      = dv.Cells["Order_Number"].Value.ToString();
            oNumberTB.Text   = orderNumber;
            ClearAll();
            panelPayment.Visible = true;
            button_Edit.Visible  = false;
            buttonRemove.Visible = false;
            string order_Num = dv.Cells["Order_Number"].Value.ToString();

            cart2 = posSql.QueryDT("Select * from OrderItem where Order_Number ='" + order_Num + "'");
            cart3 = cart2;
            for (int i = 0; i < cart2.Rows.Count; i++)
            {
                invoiceTB.Text = cart2.Rows[i]["Order_Number"].ToString();

                DataRow row = cart.NewRow();
                row["pName"]         = cart2.Rows[i]["pName"].ToString();
                row["pCode"]         = cart2.Rows[i]["pCode"].ToString();
                row["pSellingPrice"] = cart2.Rows[i]["pSellingPrice"].ToString();
                row["pQuantity"]     = cart2.Rows[i]["pQuantity"].ToString();
                row["pTotalAmount"]  = cart2.Rows[i]["pTotalAmount"].ToString();
                cart.Rows.Add(row);
            }
            dataGridView3.DataSource = cart;

            sqlCommandAB custBal = new sqlCommandAB();
            DataTable    dt      = custBal.QueryDT("SELECT Customer_CreditBalance, Customer_CreditLimit FROM Customer WHERE (Customer_Number ='" + (string)custNumberTB.Text + "')");

            if (sqlCommandAB.message != null)
            {
                MessageBox.Show("There is an error by the Connecting to the Database, Cannot get Customer Details");
            }

            else
            {
                //dt.Rows[0]["Customer_CreditBalance"].ToString();
                try
                {
                    if ((decimal.TryParse(dt.Rows[0]["Customer_CreditLimit"].ToString(), out creditLimit) && decimal.TryParse(dt.Rows[0]["Customer_CreditBalance"].ToString(), out customerCreditBal)))
                    {
                    }
                    else
                    {
                        MessageBox.Show("Customer Credit Details unavaileable, Please Restart the system...");
                    }
                    AccountBalanceTB.Text = "R" + customerCreditBal.ToString();
                }
                catch (Exception) { AccountBalanceTB.Text = "0.00"; MessageBox.Show("You may recieve cash payments only."); }
            }
        }
Example #13
0
        public void insertUser()
        {
            sqlCommandAB iu = new sqlCommandAB();
            DataTable    dt = iu.QueryDT("SELECT * FROM loginLog");
            DataRow      dr = dt.NewRow();

            dr["staff_Number"] = sNumber;
            dr["staff_Name"]   = sName;
            dt.Rows.Add(dr);
            iu.UpDate(dt);
        }
Example #14
0
        public void InserNewCategory()
        {
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    dt       = brandSql.QueryDT("SELECT * FROM Category");
            DataRow      dr       = dt.NewRow();

            dr["categoryName"]        = CategoryNameTB.Text;
            dr["categoryDescription"] = Category_DescriptionTB.Text;
            dt.Rows.Add(dr);
            brandSql.UpDate(dt);
        }
Example #15
0
        public void updateInventory()
        {
            sqlCommandAB upInv = new sqlCommandAB();
            DataTable    dt    = upInv.QueryDT("SELECT pCode,pQuantity FROM OrderItem WHERE (Order_Number ='" + (string)oNumberTB.Text + "')");

            int count = dt.Rows.Count;

            //  MessageBox.Show(count.ToString() + " order Number" + (string)oNumberTB.Text );
            for (int i = 0; i < count; i++)
            {
                updateInv(dt.Rows[i]["pCode"].ToString(), Convert.ToInt32(dt.Rows[i]["pQuantity"]));
            }
        }
Example #16
0
        public void InsertNewBrand()
        {
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    dt       = brandSql.QueryDT("SELECT * FROM Brand");
            DataRow      dr       = dt.NewRow();

            dr["categoryName"]     = selectCat.SelectedItem.ToString();
            dr["brandName"]        = brandNameTB.Text;
            dr["brandDescription"] = brandDescriptionTB.Text;

            dt.Rows.Add(dr);
            brandSql.UpDate(dt);
        }
Example #17
0
        //Modifications to make to get customers from the database....
        public void getCustomers()
        {
            dataGridView1.Rows.Clear();
            sqlCommandAB addCustomer = new sqlCommandAB();
            DataTable    DT          = addCustomer.QueryDT("SELECT * FROM customer");

            String[] rows;
            for (int j = 0; j < DT.Rows.Count; j++)
            {
                rows = new string[] { (string)DT.Rows[j]["Customer_Number"], (string)DT.Rows[j]["Customer_Name"], (string)DT.Rows[j]["Customer_Surname"], DT.Rows[j]["Customer_IDNumber"].ToString(), "0" + DT.Rows[j]["Customer_Cell"].ToString(), DT.Rows[j]["Customer_Email"].ToString(), (string)DT.Rows[j]["Customer_Address"] };
                dataGridView1.Rows.Add(rows);
            }
        }
Example #18
0
        public void getBrandData(out CategorysAndBrand[] Cat_Array)
        {
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM Brand");
            int          rowCount = DT.Rows.Count;

            Cat_Array = new CategorysAndBrand[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                row = new string[] { (string)DT.Rows[j]["brandName"], (string)DT.Rows[j]["categoryName"], (string)DT.Rows[j]["brandDescription"] };
                dataGridView2.Rows.Add(row);
            }
        }
Example #19
0
        public void getProducts()
        {
            dataGridView1.Rows.Clear();
            sqlCommandAB addProducts = new sqlCommandAB();
            DataTable    DT          = addProducts.QueryDT("SELECT * FROM Product");

            String[] row;
            for (int j = 0; j < DT.Rows.Count; j++)
            {
                string brand = addProducts.getSingleString("SELECT brandName FROM brand WHERE brandID = '" + DT.Rows[j]["brandID"] + "'");
                row = new string[] { (string)DT.Rows[j]["pName"], DT.Rows[j]["pCode"].ToString(), (string)DT.Rows[j]["categoryName"], (string)brand, "R" + DT.Rows[j]["pSellingPrice"].ToString(), DT.Rows[j]["pQty"].ToString(), DT.Rows[j]["pReorderQty"].ToString(), (string)DT.Rows[j]["pDescription"] };
                dataGridView1.Rows.Add(row);
            }
        }
Example #20
0
        public void fillGrid(string a)
        {
            dataGridView1.Rows.Clear();
            sqlCommandAB o     = new sqlCommandAB();
            DataTable    dt    = o.QueryDT("SELECT * FROM Orders " + a);
            int          count = dt.Rows.Count;

            string[] dr;
            for (int i = 0; i < count; i++)
            {
                dr = new string[] { (string)dt.Rows[i]["Order_Number"], (string)dt.Rows[i]["Customer_Number"], (string)dt.Rows[i]["staff_Number"], dt.Rows[i]["OrderAmount"].ToString(), dt.Rows[i]["OrderQuantity"].ToString(), (string)dt.Rows[i]["OrderStatus"], dt.Rows[i]["OrderDate"].ToString() };
                dataGridView1.Rows.Add(dr);
            }
        }
Example #21
0
        private static void getProductDetails(String id)
        {
            sqlCommandAB getPro = new sqlCommandAB();
            DataTable    DT     = getPro.QueryDT("SELECT * FROM Product WHERE pCode = '" + id + "'");

            if (DT.Rows.Count > 0)
            {
                pName         = (string)DT.Rows[0]["pName"];
                pCode         = (string)DT.Rows[0]["pCode"];
                pSellingPrice = Convert.ToDecimal(DT.Rows[0]["pSellingPrice"]);
                pQty          = Convert.ToInt32(DT.Rows[0]["pQty"]);
                costPrice     = Convert.ToDecimal(DT.Rows[0]["pCostPrice"]);
                profit        = (pSellingPrice - costPrice);
            }
        }
Example #22
0
        public void validateUser(string inUserName)
        {
            sqlCommandAB lg    = new sqlCommandAB();
            DataTable    dt    = lg.QueryDT("SELECT staff_Number, staff_Type, staff_Username,staff_Password,staff_Name FROM Staff WHERE (staff_Number = '" + inUserName + "' OR staff_Username ='******')");
            int          count = dt.Rows.Count;

            if (count >= 1)
            {
                sPassword = dt.Rows[0]["staff_Password"].ToString();
                sNumber   = dt.Rows[0]["staff_Number"].ToString();
                sUsername = dt.Rows[0]["staff_Username"].ToString();
                sName     = dt.Rows[0]["staff_Name"].ToString();
                sType     = dt.Rows[0]["staff_Type"].ToString();
            }
        }
Example #23
0
        public void getCatData(out Staff[] staff_Array)
        {
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM staff");
            int          rowCount = DT.Rows.Count;

            staff_Array = new Staff[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                row = new string[] { (string)DT.Rows[j]["staff_Number"], (string)DT.Rows[j]["staff_Name"], (string)DT.Rows[j]["staff_Surname"], DT.Rows[j]["staff_Cell"].ToString(), (string)DT.Rows[j]["staff_Type"] };
                dataGridView1.Rows.Add(row);
                loadData();
            }
        }
Example #24
0
        private void insertSale()
        {
            sqlCommandAB saleQuery = new sqlCommandAB();
            DataTable    dt        = saleQuery.QueryDT("SELECT * FROM sale");
            DataRow      dr        = dt.NewRow();

            dr["invoiceNumber"] = "Abrahale Kiros";
            dr["qty"]           = (counter + 1);
            dr["total_profit"]  = totalProfit;
            dr["amountDue"]     = pAmount;
            dr["amountPayed"]   = paidAmount;
            dr["total_cost"]    = totalCost;
            dr["change"]        = (paidAmount - pAmount);
            dr["tithe"]         = (double)totalProfit * 0.10;
            dt.Rows.Add(dr);
            saleQuery.UpDate(dt);
        }
Example #25
0
        public void getStaffData(out Staff[] staff_Array)
        {
            dataGridView1.Rows.Clear();
            string       allQ     = (string)textBox1.Text;
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM staff WHERE ((staff_IDNumber LIKE '" + allQ + "%') OR (staff_Number LIKE '%" + allQ + "%')) OR (staff_Name LIKE '%" + allQ + "%')");
            int          rowCount = DT.Rows.Count;

            staff_Array = new Staff[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                row = new string[] { (string)DT.Rows[j]["staff_Number"], (string)DT.Rows[j]["staff_Name"], (string)DT.Rows[j]["staff_Surname"], DT.Rows[j]["staff_Cell"].ToString(), (string)DT.Rows[j]["staff_Type"] };
                dataGridView1.Rows.Add(row);
                loadData();
            }
        }
Example #26
0
        public void getBrandData(out CategorysAndBrand[] Cat_Array, string category)
        {
            comboBox1.Items.Clear();


            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM Brand WHERE categoryName= '" + category + "' ");
            int          rowCount = DT.Rows.Count;

            Cat_Array = new CategorysAndBrand[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                row = new string[] { (string)DT.Rows[j]["brandName"], (string)DT.Rows[j]["brandDescription"] };

                comboBox1.Items.Add(DT.Rows[j]["brandName"]);
            }
        }
Example #27
0
        public void getCatData(out CategorysAndBrand[] Cat_Array)
        {
            selectCat.Items.Clear();
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM Category");
            int          rowCount = DT.Rows.Count;

            Cat_Array = new CategorysAndBrand[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                row = new string[] { (string)DT.Rows[j]["categoryName"], (string)DT.Rows[j]["categoryDescription"] };
                dataGridView1.Rows.Add(row);

                selectCat.Items.Add(DT.Rows[j]["categoryName"]);
            }
            selectCat.SelectedIndex = -1;
        }
Example #28
0
        public void getProduct(out addProductForm[] Cat_Array)
        {
            dataGridView3.Rows.Clear();
            sqlCommandAB brandSql = new sqlCommandAB();
            DataTable    DT       = brandSql.QueryDT("SELECT * FROM Product");
            int          rowCount = DT.Rows.Count;

            Cat_Array = new addProductForm[rowCount];
            string[] row;
            for (int j = 0; j < rowCount; j++)
            {
                string brandName = brandSql.getSingleString("SELECT brandName FROM Brand WHERE brandID = '" + Convert.ToInt32(DT.Rows[j]["brandID"]) + "'");
                row = new string[] { (string)DT.Rows[j]["pCode"], (string)DT.Rows[j]["pName"], (string)DT.Rows[j]["categoryName"], brandName, DT.Rows[j]["pSellingPrice"].ToString() };

                dataGridView3.Rows.Add(row);
                loadData();
            }
        }
Example #29
0
        private void deleteBTN_Click(object sender, EventArgs e)
        {
            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

            string       a           = Convert.ToString(selectedRow.Cells["staff_Number"].Value);
            sqlCommandAB customerSql = new sqlCommandAB();
            DialogResult dr          = MessageBox.Show("Are you sure you want to Delete " + nameTB.Text.ToString() + "Permanently?", "Confim Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dr == DialogResult.Yes)
            {
                DataTable DT = customerSql.QueryDT("DELETE  FROM Staff where staff_Number ='" + a + "' ");
                dataGridView1.Rows.Clear();
                Staff[] staff;
                getCatData(out staff);
                Clear();
            }
        }
Example #30
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            disabled();
            groupBox1.Visible = true;
            Clear();

            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];

            string       a           = Convert.ToString(selectedRow.Cells["staff_Number"].Value);
            sqlCommandAB customerSql = new sqlCommandAB();
            DataTable    DT          = customerSql.QueryDT("SELECT * FROM Staff where staff_Number ='" + a + "' ");

            populate(DT);
            populateLoginDetails(getUserLoginDetails(a));
            groupBox1.Visible = true;
            deleteBTN.Enabled = true;
        }