public bool Save(HoaDonNhapHang hd) { this.connect(); bool bCheck = true; string query = "insert into HoaDonNhapHang([id],[idNguoiLap],[NgayLap],[TongGiaTien])" + "values(@ID,@IDuser,@date,@tong)"; this.cm = new SqlCommand(query, cnn); this.cm.Parameters.AddWithValue("ID", hd.ID.Trim()); this.cm.Parameters.AddWithValue("IDuser", hd.IDNguoiLap.Trim()); this.cm.Parameters.AddWithValue("date", hd.NgayLap.ToString("yyyy-MM-dd")); this.cm.Parameters.AddWithValue("tong", hd.TongTien); try { this.cm.ExecuteNonQuery(); this.disconnect(); } catch (Exception ex) { this.disconnect(); bCheck = false; throw ex; } return(bCheck); }
public bool Update(HoaDonNhapHang hd) { this.connect(); bool bCheck = true; string query = "update HoaDonNhapHang set [NgayLap]=@date, [TongGiaTien]=@tong" + " where [id] = @ID"; this.cm = new SqlCommand(query, cnn); this.cm.Parameters.AddWithValue("ID", hd.ID.Trim()); this.cm.Parameters.AddWithValue("date", hd.NgayLap.ToString("yyyy-MM-dd")); this.cm.Parameters.AddWithValue("tong", hd.TongTien); try { this.cm.ExecuteNonQuery(); this.disconnect(); } catch (Exception ex) { this.disconnect(); bCheck = false; throw ex; } return(bCheck); }
public bool update(string idHD, string idNguoiLap, DateTime ngayLap, int tong) { HoaDonNhapHang hd = new HoaDonNhapHang(idHD, idNguoiLap, ngayLap, tong); return(dataHDNH.Update(hd)); }