コード例 #1
0
        public static TheKhuyenMai SelectById(Guid TKM_ID)
        {
            var Item = new TheKhuyenMai();
            var obj  = new SqlParameter[1];

            obj[0] = new SqlParameter("TKM_ID", TKM_ID);
            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblSpaMgr_TheKhuyenMai_Select_SelectById_linhnx", obj))
            {
                while (rd.Read())
                {
                    Item = getFromReader(rd);
                }
            }
            return(Item);
        }
コード例 #2
0
        public static TheKhuyenMai getFromReader(IDataReader rd)
        {
            var Item = new TheKhuyenMai();

            if (rd.FieldExists("TKM_ID"))
            {
                Item.ID = (Guid)(rd["TKM_ID"]);
            }
            if (rd.FieldExists("TKM_KM_ID"))
            {
                Item.KM_ID = (Guid)(rd["TKM_KM_ID"]);
            }
            if (rd.FieldExists("TKM_Ma"))
            {
                Item.Ma = (String)(rd["TKM_Ma"]);
            }
            if (rd.FieldExists("TKM_KH_ID"))
            {
                Item.KH_ID = (Guid)(rd["TKM_KH_ID"]);
            }
            if (rd.FieldExists("TKM_DVTC_ID"))
            {
                Item.DVTC_ID = (Guid)(rd["TKM_DVTC_ID"]);
            }
            if (rd.FieldExists("TKM_GiaNY"))
            {
                Item.GiaNY = (Double)(rd["TKM_GiaNY"]);
            }
            if (rd.FieldExists("TKM_Gia"))
            {
                Item.Gia = (Double)(rd["TKM_Gia"]);
            }
            if (rd.FieldExists("TKM_HanSuDung"))
            {
                Item.HanSuDung = (DateTime)(rd["TKM_HanSuDung"]);
            }
            if (rd.FieldExists("TKM_HanDoiThe"))
            {
                Item.HanDoiThe = (DateTime)(rd["TKM_HanDoiThe"]);
            }
            if (rd.FieldExists("TKM_TinhTrang"))
            {
                Item.TinhTrang = (Boolean)(rd["TKM_TinhTrang"]);
            }
            if (rd.FieldExists("TKM_DV_ID"))
            {
                Item.DV_ID = (Guid)(rd["TKM_DV_ID"]);
            }
            if (rd.FieldExists("TKM_NgayPhatHanh"))
            {
                Item.NgayPhatHanh = (DateTime)(rd["TKM_NgayPhatHanh"]);
            }
            if (rd.FieldExists("TKM_NgayNhan"))
            {
                Item.NgayNhan = (DateTime)(rd["TKM_NgayNhan"]);
            }
            if (rd.FieldExists("TKM_NguoiNhan"))
            {
                Item.NguoiNhan = (String)(rd["TKM_NguoiNhan"]);
            }
            if (rd.FieldExists("TKM_NgayTao"))
            {
                Item.NgayTao = (DateTime)(rd["TKM_NgayTao"]);
            }
            if (rd.FieldExists("TKM_NgayCapNhat"))
            {
                Item.NgayCapNhat = (DateTime)(rd["TKM_NgayCapNhat"]);
            }
            if (rd.FieldExists("TKM_NguoiTao"))
            {
                Item.NguoiTao = (String)(rd["TKM_NguoiTao"]);
            }
            if (rd.FieldExists("TKM_NguoiCapNhat"))
            {
                Item.NguoiCapNhat = (String)(rd["TKM_NguoiCapNhat"]);
            }
            if (rd.FieldExists("TKM_DaDung"))
            {
                Item.DaDung = (Boolean)(rd["TKM_DaDung"]);
            }
            if (rd.FieldExists("TKM_KM_Ten"))
            {
                Item.KM_Ten = (String)(rd["TKM_KM_Ten"]);
            }
            if (rd.FieldExists("TKM_KH_Ten"))
            {
                Item.KH_Ten = (String)(rd["TKM_KH_Ten"]);
            }
            if (rd.FieldExists("TKM_DV_Ten"))
            {
                Item.DV_Ten = (String)(rd["TKM_DV_Ten"]);
            }
            if (rd.FieldExists("TKM_DVTC_Ten"))
            {
                Item.DVTC_Ten = (String)(rd["TKM_DVTC_Ten"]);
            }
            if (rd.FieldExists("TKM_NguoiNhan_Ten"))
            {
                Item.NguoiNhan_Ten = (String)(rd["TKM_NguoiNhan_Ten"]);
            }
            return(Item);
        }
コード例 #3
0
        public static TheKhuyenMai Update(TheKhuyenMai item)
        {
            var Item = new TheKhuyenMai();
            var obj  = new SqlParameter[19];

            obj[0] = new SqlParameter("TKM_ID", item.ID);
            obj[1] = new SqlParameter("TKM_KM_ID", item.KM_ID);
            obj[2] = new SqlParameter("TKM_Ma", item.Ma);
            obj[3] = new SqlParameter("TKM_KH_ID", item.KH_ID);
            obj[4] = new SqlParameter("TKM_DVTC_ID", item.DVTC_ID);
            obj[5] = new SqlParameter("TKM_GiaNY", item.GiaNY);
            obj[6] = new SqlParameter("TKM_Gia", item.Gia);
            if (item.HanSuDung > DateTime.MinValue)
            {
                obj[7] = new SqlParameter("TKM_HanSuDung", item.HanSuDung);
            }
            else
            {
                obj[7] = new SqlParameter("TKM_HanSuDung", DBNull.Value);
            }
            if (item.HanDoiThe > DateTime.MinValue)
            {
                obj[8] = new SqlParameter("TKM_HanDoiThe", item.HanDoiThe);
            }
            else
            {
                obj[8] = new SqlParameter("TKM_HanDoiThe", DBNull.Value);
            }
            obj[9]  = new SqlParameter("TKM_TinhTrang", item.TinhTrang);
            obj[10] = new SqlParameter("TKM_DV_ID", item.DV_ID);
            if (item.NgayPhatHanh > DateTime.MinValue)
            {
                obj[11] = new SqlParameter("TKM_NgayPhatHanh", item.NgayPhatHanh);
            }
            else
            {
                obj[11] = new SqlParameter("TKM_NgayPhatHanh", DBNull.Value);
            }
            if (item.NgayNhan > DateTime.MinValue)
            {
                obj[12] = new SqlParameter("TKM_NgayNhan", item.NgayNhan);
            }
            else
            {
                obj[12] = new SqlParameter("TKM_NgayNhan", DBNull.Value);
            }
            obj[13] = new SqlParameter("TKM_NguoiNhan", item.NguoiNhan);
            if (item.NgayTao > DateTime.MinValue)
            {
                obj[14] = new SqlParameter("TKM_NgayTao", item.NgayTao);
            }
            else
            {
                obj[14] = new SqlParameter("TKM_NgayTao", DBNull.Value);
            }
            if (item.NgayCapNhat > DateTime.MinValue)
            {
                obj[15] = new SqlParameter("TKM_NgayCapNhat", item.NgayCapNhat);
            }
            else
            {
                obj[15] = new SqlParameter("TKM_NgayCapNhat", DBNull.Value);
            }
            obj[16] = new SqlParameter("TKM_NguoiTao", item.NguoiTao);
            obj[17] = new SqlParameter("TKM_NguoiCapNhat", item.NguoiCapNhat);
            obj[18] = new SqlParameter("TKM_DaDung", item.DaDung);

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