public static CongNoDauKy SelectById(Guid CNKH_ID)
        {
            var Item = new CongNoDauKy();
            var obj  = new SqlParameter[1];

            obj[0] = new SqlParameter("CNKH_ID", CNKH_ID);
            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblCongNoDauKy_Select_SelectById_linhnx", obj))
            {
                while (rd.Read())
                {
                    Item = getFromReader(rd);
                }
            }
            return(Item);
        }
        public static CongNoDauKy getFromReader(IDataReader rd)
        {
            var Item = new CongNoDauKy();

            if (rd.FieldExists("CNKH_ID"))
            {
                Item.ID = (Guid)(rd["CNKH_ID"]);
            }
            if (rd.FieldExists("CNKH_KH_ID"))
            {
                Item.KH_ID = (Guid)(rd["CNKH_KH_ID"]);
            }
            if (rd.FieldExists("CNKH_Tien"))
            {
                Item.Tien = (Double)(rd["CNKH_Tien"]);
            }
            if (rd.FieldExists("CNKH_NgayTao"))
            {
                Item.NgayTao = (DateTime)(rd["CNKH_NgayTao"]);
            }
            if (rd.FieldExists("CNKH_NguoiTao"))
            {
                Item.NguoiTao = (String)(rd["CNKH_NguoiTao"]);
            }
            if (rd.FieldExists("CNKH_NgayCapNhat"))
            {
                Item.NgayCapNhat = (DateTime)(rd["CNKH_NgayCapNhat"]);
            }
            if (rd.FieldExists("CNKH_NguoiCapNhat"))
            {
                Item.NguoiCapNhat = (String)(rd["CNKH_NguoiCapNhat"]);
            }
            if (rd.FieldExists("CNKH_No"))
            {
                Item.No = (Boolean)(rd["CNKH_No"]);
            }
            Item._KhachHang = KhachHangDal.getFromReader(rd);
            return(Item);
        }
        public static CongNoDauKy Insert(CongNoDauKy item)
        {
            var Item = new CongNoDauKy();
            var obj  = new SqlParameter[8];

            obj[0] = new SqlParameter("CNKH_ID", item.ID);
            obj[1] = new SqlParameter("CNKH_KH_ID", item.KH_ID);
            obj[2] = new SqlParameter("CNKH_Tien", item.Tien);
            if (item.NgayTao > DateTime.MinValue)
            {
                obj[3] = new SqlParameter("CNKH_NgayTao", item.NgayTao);
            }
            else
            {
                obj[3] = new SqlParameter("CNKH_NgayTao", DBNull.Value);
            }
            obj[4] = new SqlParameter("CNKH_NguoiTao", item.NguoiTao);
            if (item.NgayCapNhat > DateTime.MinValue)
            {
                obj[5] = new SqlParameter("CNKH_NgayCapNhat", item.NgayCapNhat);
            }
            else
            {
                obj[5] = new SqlParameter("CNKH_NgayCapNhat", DBNull.Value);
            }
            obj[6] = new SqlParameter("CNKH_NguoiCapNhat", item.NguoiCapNhat);
            obj[7] = new SqlParameter("CNKH_No", item.No);

            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblCongNoDauKy_Insert_InsertNormal_linhnx", obj))
            {
                while (rd.Read())
                {
                    Item = getFromReader(rd);
                }
            }
            return(Item);
        }