示例#1
0
 public bool Them(string makh, string tenkh, string diachi, string sdt)
 {
     try
     {
         KHACHHANG kh = new KHACHHANG();
         kh.MAKH     = makh;
         kh.TENKH    = tenkh;
         kh.DIACHI   = diachi;
         kh.SDT      = sdt;
         kh.MALOAIKH = "LK001";
         db.KHACHHANGs.InsertOnSubmit(kh);
         db.SubmitChanges();
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
示例#2
0
        public bool Insert(KHACHHANG kh)
        {
            try
            {
                _cn.Open();

                string SQL = "INSERT INTO KHACHHANG   VALUES ('" + kh.MAKHO + "',N'" + kh.HOTEN + "',N'" + kh.SDT + "', N'" + kh.DIACHI + "',N'" + kh.FB + "')";

                SqlCommand cmd = new SqlCommand(SQL, _cn);
                cmd.ExecuteNonQuery();
                _cn.Close();
                //SqlDataAdapter da = new SqlDataAdapter("select * from XUATKHO")
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#3
0
        public bool Update(KHACHHANG kh, string MAKHO)
        {
            try
            {
                _cn.Open();

                // Query string
                string SQL = "update KHACHHANG set DIACHI = N'" + kh.DIACHI + "' , FB = N'" + kh.FB + "' , SDT = N'" + kh.SDT + "' , HOTEN = N'" + kh.HOTEN + "' where MAKHO = '" + MAKHO + "'";

                // Command (mặc định command type = text nên chúng ta khỏi phải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, _cn);

                // Query và kiểm tra
                cmd.ExecuteNonQuery();
                _cn.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }