コード例 #1
0
        public static void insertKhachHangNgayByGoiHD(int IdPCTHD, int IdNgayHD)
        {
            SqlCommand    cmd    = null;
            SqlConnection conn   = Common.Connection.SqlConnect();
            String        Select = "select * from PackageChiTietHoaDon pcthd ";

            Select         += "left join SYS_CUSTOMER sc on sc.ID = pcthd.IDKhachHang ";
            Select         += "where pcthd.ID = " + IdPCTHD;
            cmd             = new SqlCommand(Select);
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn;
            conn.Open();
            using (SqlDataReader oReader = cmd.ExecuteReader())
            {
                while (oReader.Read())
                {
                    DataObject.KhachHangNgay obj = new DataObject.KhachHangNgay();
                    obj.NgayHoaDonId = IdNgayHD;
                    obj.MaQuan       = oReader["MaQuan"].ToString();
                    obj.PhoneNumber  = oReader["PhoneNumber"].ToString();
                    obj.Email        = oReader["Email"].ToString();
                    obj.CustomerName = oReader["CustomerName"].ToString();
                    if (oReader["BirthDay"].ToString() != "" && oReader["BirthDay"].ToString() != null)
                    {
                        String createDate = String.Format("{0:dd/MM/yyyy}", oReader["BirthDay"].ToString());
                        obj.BirthDay = DateTime.Parse(createDate);
                    }
                    obj.Address = oReader["Address"].ToString();
                    Servies.SysCustomerServices.InsertDataKHNgayReturnId(obj);
                    conn.Close();
                    break;
                }
            }
        }
コード例 #2
0
        public int returnIdKHNgay(string soDienThoai, string hoten, string email, string diaChi, string maquan, string ngaySinh, int NgayHoaDon)
        {
            DataObject.KhachHangNgay sysCustomer = new DataObject.KhachHangNgay();
            sysCustomer.PhoneNumber  = soDienThoai;
            sysCustomer.CustomerName = hoten;
            sysCustomer.Email        = email;
            sysCustomer.Address      = diaChi;
            sysCustomer.MaQuan       = maquan;
            if (ngaySinh != "")
            {
                sysCustomer.BirthDay = DateTime.ParseExact(ngaySinh, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            sysCustomer.NgayHoaDonId = NgayHoaDon;
            int IdKhachHang = Servies.SysCustomerServices.InsertDataKHNgayReturnId(sysCustomer);

            return(IdKhachHang);
        }
コード例 #3
0
        public static int InsertDataKHNgayReturnId(DataObject.KhachHangNgay obj)
        {
            String        Insert = "INSERT INTO KhachHangNgay (CustomerName,PhoneNumber,Email,BirthDay,Address,MaQuan,NgayHoaDonId) VALUES (@CustomerName,@PhoneNumber,@Email,@BirthDay,@Address,@MaQuan,@NgayHoaDonId);SELECT SCOPE_IDENTITY();";
            SqlConnection conn   = Common.Connection.SqlConnect();
            SqlCommand    cmd    = new SqlCommand(Insert);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn;
            cmd.Parameters.AddWithValue("@CustomerName", obj.CustomerName);
            cmd.Parameters.AddWithValue("@PhoneNumber", obj.PhoneNumber);
            cmd.Parameters.AddWithValue("@Email", obj.Email);
            cmd.Parameters.AddWithValue("@BirthDay", obj.BirthDay);
            cmd.Parameters.AddWithValue("@Address", obj.Address);
            cmd.Parameters.AddWithValue("@MaQuan", obj.MaQuan);
            cmd.Parameters.AddWithValue("@NgayHoaDonId", obj.NgayHoaDonId);
            conn.Open();
            int modified = cmd.ExecuteNonQuery();

            cmd.Parameters.Clear();
            conn.Close();
            return(1);
        }