public bool Them(TheKhachHangDTO the) { this.connect(); bool bCheck = true; string query = "INSERT INTO TheKhachHang([id],[HoTen],[SDT],[NgaySinh],[CMND],[DiemTichLuy])" + " VALUES(@ID,@HOTEN,@SDT,@NGAYSINH,@CMND,@DIEMTICHLUY)"; this.cm = new SqlCommand(query, cnn); this.cm.Parameters.Add(new SqlParameter("@ID", String.Concat("KH", sMaThe))); this.cm.Parameters.Add(new SqlParameter("@HOTEN", the.HoTen.Trim())); this.cm.Parameters.Add(new SqlParameter("@SDT", the.SDT.Trim())); this.cm.Parameters.Add(new SqlParameter("@NGAYSINH", the.NgaySinh.Date)); this.cm.Parameters.Add(new SqlParameter("@CMND", the.CMND.Trim())); this.cm.Parameters.Add(new SqlParameter("@DIEMTICHLUY", 20)); try { this.cm.ExecuteNonQuery(); this.disconnect(); } catch (Exception ex) { this.disconnect(); bCheck = false; throw ex; } return(bCheck); }
public bool Them(string hoten, string sdt, DateTime ngaysinh, string cmnd, int diemtichluy) { TheKhachHangDTO the = new TheKhachHangDTO(hoten, sdt, ngaysinh, cmnd, diemtichluy); if (dataThe.Them(the)) { return(true); } return(false); }