Example #1
0
        public static ChamSoc Insert(ChamSoc item)
        {
            var Item = new ChamSoc();
            var obj  = new SqlParameter[8];

            obj[0] = new SqlParameter("CS_ID", item.ID);
            obj[1] = new SqlParameter("CS_Ma", item.Ma);
            obj[2] = new SqlParameter("CS_KH_ID", item.KH_ID);
            obj[3] = new SqlParameter("CS_TT_ID", item.TT_ID);
            obj[4] = new SqlParameter("CS_LOAI_ID", item.LOAI_ID);
            obj[5] = new SqlParameter("CS_NoiDung", item.NoiDung);
            obj[6] = new SqlParameter("CS_NguoiTao", item.NguoiTao);
            if (item.NgayTao > DateTime.MinValue)
            {
                obj[7] = new SqlParameter("CS_NgayTao", item.NgayTao);
            }
            else
            {
                obj[7] = new SqlParameter("CS_NgayTao", DBNull.Value);
            }

            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblChamSoc_Insert_InsertNormal_linhnx", obj))
            {
                while (rd.Read())
                {
                    Item = getFromReader(rd);
                }
            }
            return(Item);
        }
Example #2
0
        public static ChamSoc getFromReader(IDataReader rd)
        {
            var Item = new ChamSoc();

            if (rd.FieldExists("CS_ID"))
            {
                Item.ID = (Guid)(rd["CS_ID"]);
            }
            if (rd.FieldExists("CS_Ma"))
            {
                Item.Ma = (String)(rd["CS_Ma"]);
            }
            if (rd.FieldExists("CS_KH_ID"))
            {
                Item.KH_ID = (Guid)(rd["CS_KH_ID"]);
            }
            if (rd.FieldExists("CS_TT_ID"))
            {
                Item.TT_ID = (Guid)(rd["CS_TT_ID"]);
            }
            if (rd.FieldExists("CS_LOAI_ID"))
            {
                Item.LOAI_ID = (Guid)(rd["CS_LOAI_ID"]);
            }
            if (rd.FieldExists("CS_NoiDung"))
            {
                Item.NoiDung = (String)(rd["CS_NoiDung"]);
            }
            if (rd.FieldExists("CS_NguoiTao"))
            {
                Item.NguoiTao = (String)(rd["CS_NguoiTao"]);
            }
            if (rd.FieldExists("CS_NgayTao"))
            {
                Item.NgayTao = (DateTime)(rd["CS_NgayTao"]);
            }
            if (rd.FieldExists("TT_Ten"))
            {
                Item.TT_Ten = (String)(rd["TT_Ten"]);
            }
            if (rd.FieldExists("LOAI_Ten"))
            {
                Item.LOAI_Ten = (String)(rd["LOAI_Ten"]);
            }
            if (rd.FieldExists("KH_Ten"))
            {
                Item.KH_Ten = (String)(rd["KH_Ten"]);
            }
            return(Item);
        }
Example #3
0
        public static ChamSoc SelectById(SqlConnection con, Guid CS_ID)
        {
            var Item = new ChamSoc();
            var obj  = new SqlParameter[1];

            obj[0] = new SqlParameter("CS_ID", CS_ID);
            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblChamSoc_Select_SelectById_linhnx", obj))
            {
                while (rd.Read())
                {
                    Item = getFromReader(rd);
                }
            }
            return(Item);
        }