Example #1
0
        public int InsertSpecialCompanent(SpecialCompanent obj)
        {
            string     sql = @"INSERT INTO[BE_SpecialCompanent]([SpecialID]
				, [ItemName]
				, [IsDisabled]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
				) VALUES(@SpecialID
				, @ItemName
				, @IsDisabled
				, @Created
				, @CreatedBy
				, @Modified
				, @ModifiedBy
				)"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pSpecialID = new SqlParameter("SpecialID", Convert2DBnull(obj.SpecialID));

            pSpecialID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pSpecialID);

            SqlParameter pItemName = new SqlParameter("ItemName", Convert2DBnull(obj.ItemName));

            pItemName.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pItemName);

            SqlParameter pIsDisabled = new SqlParameter("IsDisabled", Convert2DBnull(obj.IsDisabled));

            pIsDisabled.SqlDbType = SqlDbType.Bit;
            cmd.Parameters.Add(pIsDisabled);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            SqlParameter pModified = new SqlParameter("Modified", Convert2DBnull(obj.Modified));

            pModified.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pModified);

            SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", Convert2DBnull(obj.ModifiedBy));

            pModifiedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pModifiedBy);

            return(cmd.ExecuteNonQuery());
        }
Example #2
0
        public List <SpecialCompanent> LoadSpecialCompanentsByModifiedBy(string modifiedBy)
        {
            string     sql = @"SELECT [SpecialID]
				, [ItemName]
				, [IsDisabled]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
				 FROM [BE_SpecialCompanent] WHERE [ModifiedBy]=@ModifiedBy"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", modifiedBy);

            pModifiedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pModifiedBy);

            List <SpecialCompanent> ret = new List <SpecialCompanent>();
            SqlDataReader           dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    SpecialCompanent iret = new SpecialCompanent();
                    if (!Convert.IsDBNull(dr["SpecialID"]))
                    {
                        iret.SpecialID = (Guid)dr["SpecialID"];
                    }
                    iret.ItemName = dr["ItemName"].ToString();
                    if (!Convert.IsDBNull(dr["IsDisabled"]))
                    {
                        iret.IsDisabled = (bool)dr["IsDisabled"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        iret.Created = (DateTime)dr["Created"];
                    }
                    iret.CreatedBy = dr["CreatedBy"].ToString();
                    if (!Convert.IsDBNull(dr["Modified"]))
                    {
                        iret.Modified = (DateTime)dr["Modified"];
                    }
                    iret.ModifiedBy = dr["ModifiedBy"].ToString();
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
Example #3
0
        public int LoadSpecialCompanentBySpecialID(SpecialCompanent obj)
        {
            string     sql = @"SELECT [SpecialID]
				, [ItemName]
				, [IsDisabled]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
                FROM [BE_SpecialCompanent] WITH(NOLOCK) WHERE [SpecialID]=@SpecialID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pSpecialID = new SqlParameter("SpecialID", Convert2DBnull(obj.SpecialID));

            pSpecialID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pSpecialID);

            int           ret = 0;
            SqlDataReader dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["SpecialID"]))
                    {
                        obj.SpecialID = (Guid)dr["SpecialID"];
                    }
                    obj.ItemName = dr["ItemName"].ToString();
                    if (!Convert.IsDBNull(dr["IsDisabled"]))
                    {
                        obj.IsDisabled = (bool)dr["IsDisabled"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        obj.Created = (DateTime)dr["Created"];
                    }
                    obj.CreatedBy = dr["CreatedBy"].ToString();
                    if (!Convert.IsDBNull(dr["Modified"]))
                    {
                        obj.Modified = (DateTime)dr["Modified"];
                    }
                    obj.ModifiedBy = dr["ModifiedBy"].ToString();
                    ret           += 1;
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
Example #4
0
        public int UpdateSpecialCompanentBySpecialID(SpecialCompanent obj)
        {
            string     sql = @"UPDATE [BE_SpecialCompanent] SET [ItemName]=@ItemName
				, [IsDisabled]=@IsDisabled
				, [Created]=@Created
				, [CreatedBy]=@CreatedBy
				, [Modified]=@Modified
				, [ModifiedBy]=@ModifiedBy
                WHERE [SpecialID]=@SpecialID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pItemName = new SqlParameter("ItemName", Convert2DBnull(obj.ItemName));

            pItemName.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pItemName);

            SqlParameter pIsDisabled = new SqlParameter("IsDisabled", Convert2DBnull(obj.IsDisabled));

            pIsDisabled.SqlDbType = SqlDbType.Bit;
            cmd.Parameters.Add(pIsDisabled);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            SqlParameter pModified = new SqlParameter("Modified", Convert2DBnull(obj.Modified));

            pModified.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pModified);

            SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", Convert2DBnull(obj.ModifiedBy));

            pModifiedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pModifiedBy);

            SqlParameter pSpecialID = new SqlParameter("SpecialID", Convert2DBnull(obj.SpecialID));

            pSpecialID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pSpecialID);

            return(cmd.ExecuteNonQuery());
        }