Ejemplo n.º 1
0
        public string AutoUpdateFK()
        {
            string    result = "";
            DataTable dt     = new DataTable();

            cmd.CommandText = "select top(1) MaHD from HoaDon order by NgayLap desc";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
                String hd   = dt.Rows[0][0].ToString();
                String hdD  = hd.Substring(0, 8);
                string curD = DateTime.UtcNow.ToString("dd-MM-yyyy");
                curD = curD.Replace("-", "");
                int id = int.Parse(hd.Substring(8));
                if (curD.Equals(hdD))
                {
                    result = curD + formatID(id + 1);
                }
                else
                {
                    result = curD + "0001";
                }
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public string AutoUpdateFK()
        {
            string    result = "";
            DataTable dt     = new DataTable();

            cmd.CommandText = "select top(1) MaNV from NhanVien order by MaNV desc";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
                String hd = dt.Rows[0][0].ToString();
                int    id = int.Parse(hd);
                result = formatID(id + 1);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(result);
        }
Ejemplo n.º 3
0
 public bool AddData(KhachHangObj khObj)
 {
     cmd.CommandText = "Insert into tb_KhachHang values ('" + khObj.MaKhachHang + "',N'" + khObj.TenKhachHang + "',N'" + khObj.GioiTinh + "',CONVERT(DATE,'" + khObj.NamSinh + "',103),N'" + khObj.DienThoai + "','" + khObj.DiaChi + "',0,'" + khObj.Email + "')";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
Ejemplo n.º 4
0
        public DataTable GetData()
        {
            DataTable dt = new DataTable();

            cmd.CommandText = "select MaNV, TenNV, GioiTinh, NamSinh, DiaChi, SDT  from tb_NhanVien";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(dt);
        }
Ejemplo n.º 5
0
        public DataTable GetData(string ma)
        {
            DataTable dt = new DataTable();

            cmd.CommandText = @"select ct.MaHD, hh.TenHang HangHoa, ct.SoLuong, ct.DonGia, ct.SoLuong*ct.DonGia ThanhTien from CTHD ct, HangHoa hh where ct.MaHH = hh.MaHang and MaHD = '" + ma + "'";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(dt);
        }
Ejemplo n.º 6
0
        public DataTable GetData()
        {
            DataTable dt = new DataTable();

            cmd.CommandText = @"select hd.MaHD, hd.NgayLap, nv.TenNV, kh.TenKH from tb_HoaDon hd, tb_KhachHang kh, tb_NhanVien nv where kh.MaKH = hd.KhachHang and nv.MaNV = hd.NguoiLap";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(dt);
        }
Ejemplo n.º 7
0
        public DataTable GetData()
        {
            DataTable dt = new DataTable();

            cmd.CommandText = "select *  from tb_DangNhap";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dt);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(dt);
        }