private void btsua_Click(object sender, EventArgs e)
        {
            EC_CTHDN hdn = new EC_CTHDN();

            hdn.MaHDN = txtMaHDN.Text;
            hdn.MaSP  = cbsanpham.SelectedValue.ToString();
            if (txtdg.Text != "")
            {
                hdn.DonGia = float.Parse(txtdg.Text);
            }
            hdn.SoLuong = Int32.Parse(txtsl.Text);
            if (txttt.Text != "")
            {
                hdn.ThanhTien = float.Parse(txttt.Text);
            }
            if (thucthi.updateCTHDN(hdn))
            {
                MessageBox.Show("Sửa thành công");
                loadData();
            }
            else
            {
                MessageBox.Show("Sửa thất bại");
            }
        }
        public static bool deleteCTHDN(EC_CTHDN cthd)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "CTHDN_Delete";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MAHDN", SqlDbType.NVarChar).Value = cthd.MaHDN;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value  = cthd.MaSP;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateCTHDN(EC_CTHDN cthd)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "CTHDN_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@MAHDN", SqlDbType.NVarChar).Value  = cthd.MaHDN;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value   = cthd.MaSP;
            cmd.Parameters.Add("@SOLUONG", SqlDbType.Int).Value     = cthd.SoLuong;
            cmd.Parameters.Add("@DONGIA", SqlDbType.Float).Value    = cthd.DonGia;
            cmd.Parameters.Add("@THANHTIEN", SqlDbType.Float).Value = cthd.ThanhTien;

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
Пример #4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string thanhtien = Convert.ToString(Convert.ToInt32(txtDGN.Text) * Convert.ToInt32(nudSoLuong.Text));

            TongTien        += Convert.ToInt32(thanhtien);
            txtTongTien.Text = TongTien.ToString();

            EC_CTHDN CTHDN = new EC_CTHDN();

            CTHDN.SoHDN     = txtMaHD.Text;
            CTHDN.MaHang    = cbxMaHH.Text;
            CTHDN.SoLuong   = nudSoLuong.Value.ToString();
            CTHDN.ThanhTien = thanhtien;
            CTHDNs.Add(CTHDN);
            this.dgvChiTiet.Rows.Add(cbxMaHH.Text, txtTenHH.Text, txtTenDVT.Text, txtDGN.Text, nudSoLuong.Value.ToString(), thanhtien);
            //ActCTHDB.AddCTHDB(CTHDB);
        }
        private void btxoa_Click(object sender, EventArgs e)
        {
            EC_CTHDN hdn = new EC_CTHDN();

            hdn.MaHDN = txtMaHDN.Text;
            hdn.MaSP  = cbsanpham.SelectedValue.ToString();

            if (thucthi.deleteCTHDN(hdn))
            {
                MessageBox.Show("Xóa thành công");
                loadData();
            }
            else
            {
                MessageBox.Show("Xóa thất bại");
            }
        }
Пример #6
0
        public void AddCTHDN(EC_CTHDN _cthdn)
        {
            try
            {
                Connect.SqlConnect.Open();
                string sqlquery = @"INSERT INTO tb_CTHDN
					  (sohdn, mahang, soluong, thanhtien)
							 VALUES (N'{0}',N'{1}','{2}', '{3}')"                            ;
                sqlquery = string.Format(sqlquery, _cthdn.SoHDN, _cthdn.MaHang, _cthdn.SoLuong, _cthdn.ThanhTien);
                SqlCommand cmd = new SqlCommand(sqlquery, Connect.SqlConnect);
                cmd.ExecuteNonQuery();
                Connect.SqlConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public bool deleteCTHDN(EC_CTHDN cthdn)
 {
     return(DA_CTHDN.deleteCTHDN(cthdn));
 }
 public bool updateCTHDN(EC_CTHDN cthdn)
 {
     return(DA_CTHDN.updateCTHDN(cthdn));
 }
 public bool insertCTHDN(EC_CTHDN cthdn)
 {
     return(DA_CTHDN.insertCTHDN(cthdn));
 }
Пример #10
0
 public void AddCTHDN(EC_CTHDN _cthdn)
 {
     SqlCTHDN.AddCTHDN(_cthdn);
 }