Example #1
0
        private void btnCapNhatTong_Click(object sender, EventArgs e)
        {
            //cập nhật tổng tiền
            float g;

            g = float.Parse(txtTong.Text);

            dtK.Clear();
            BLChiTiet bl   = new BLChiTiet();
            DataSet   dsdh = bl.ktra(txtMaDH.Text);

            dsdh = bl.lay2cot();
            dtK  = dsdh.Tables[0];

            foreach (DataRow a in dtK.Rows)
            {
                if (txtMaDH.Text == a[BLDonHang.madh].ToString())
                {
                    txtTong.Text = a[BLChiTiet.money].ToString();
                    g            = float.Parse(txtTong.Text);
                    blDH.CapNhatDonHang(this.txtMaDH.Text, this.cbbMaKH.Text, this.cbbMaNV.Text, g, NgLap, ref err);
                    LoadData();
                }
            }
        }
Example #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            int   sl  = int.Parse(txtSL.Text);
            float gia = float.Parse(txtGia.Text);

            float g;
            float t;

            g            = float.Parse(txtGia.Text);
            t            = g * sl;
            txtTien.Text = t.ToString();
            dtK          = new DataTable();
            dtK.Clear();
            DataSet ds = blDH.LayChiTietDH();

            dtK = ds.Tables[0];
            foreach (DataRow a in dtK.Rows)
            {
                txtTien.Text = t.ToString();
            }



            if (Them)
            {
                try
                {
                    BLChiTiet bldh = new BLChiTiet();
                    bldh.ThemChitiet(this.cbbMaDH.Text, this.cbbMaSP.Text, sl, gia, t, ref err);
                    LoadData();
                    MessageBox.Show("Đã thêm xong!");
                }
                catch (SqlException)
                {
                    MessageBox.Show("Không thêm được. Lỗi rồi!");
                }
            }
            else
            {
                BLChiTiet bldh = new BLChiTiet();
                bldh.CapNhatChitiet(this.cbbMaDH.Text, this.cbbMaSP.Text, sl, gia, t, ref err);
                LoadData();
                MessageBox.Show("Đã sửa xong!");
            }
            bTien = txtTien.Text;
        }