protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            decimal currentSale = 0;

            SqlConnection con = new SqlConnection(
                WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
            con.Open();
            String     name;
            string     query = "select name from PRODUCT where productID = " + ProductList.SelectedValue;
            SqlCommand cmd   = new SqlCommand(query, con);
            name = cmd.ExecuteScalar().ToString();

            con.Close();

            TableRow tRow1 = new TableRow();


            TableCell tCell0 = new TableCell();
            tCell0.Text = ProductList.SelectedValue;
            tRow1.Cells.Add(tCell0);
            TableCell tCell1 = new TableCell();
            tCell1.Text = name;
            tRow1.Cells.Add(tCell1);
            TableCell tCell2 = new TableCell();
            tCell2.Text = PriceLabel.Text;
            tRow1.Cells.Add(tCell2);
            TableCell tCell3 = new TableCell();
            tCell3.Text = QuantityTxt.Text;
            tRow1.Cells.Add(tCell3);

            decimal   subtotal = Convert.ToDecimal(PriceLabel.Text) * Convert.ToDecimal(QuantityTxt.Text);
            TableCell tCell4   = new TableCell();
            tCell4.Text = subtotal.ToString();
            tRow1.Cells.Add(tCell4);


            TableRows.Add(tRow1);
            QuantityTxt.Text = "0";
            StockTxt.Text    = "0";

            foreach (TableRow row in TableRows)
            {
                Table1.Rows.Add(row);
                currentSale += Convert.ToDecimal(row.Cells[4].Text);
            }
            DepartmentList.ClearSelection();
            ProductList.SelectedIndex = 0;
            String currentTotal = currentSale.ToString();
            TotalLbl.Text = currentTotal;
        }
    }
Example #2
0
        public void refreshDepartments()
        {
            this.DepartmentList.Rows.Clear();
            List <object>[] rs;
            string[]        columns = { "strDepCode", "strDepName" };
            rs = dbConnect.Select("Select * from tblDepartment where boolDepIsDel = false;", columns);

            for (int i = 0; i < rs[0].Count; i++)
            {
                this.DepartmentList.Rows.Add(rs[0].ElementAt(i).ToString(), rs[1].ElementAt(i).ToString());
            }
            //clear selection
            DepartmentList.ClearSelection();
        }