Example #1
0
        public List <WorkingLine> LoadWorkingLinesByWorkingLineID(Guid workingLineID)
        {
            string     sql = @"SELECT [WorkingLineID]
				, [WorkingLineName]
				, [Remark]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
				 FROM [BE_WorkingLine] WHERE [WorkingLineID]=@WorkingLineID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkingLineID = new SqlParameter("WorkingLineID", workingLineID);

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

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

            try
            {
                while (dr.Read())
                {
                    WorkingLine iret = new WorkingLine();
                    if (!Convert.IsDBNull(dr["WorkingLineID"]))
                    {
                        iret.WorkingLineID = (Guid)dr["WorkingLineID"];
                    }
                    iret.WorkingLineName = dr["WorkingLineName"].ToString();
                    iret.Remark          = dr["Remark"].ToString();
                    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 #2
0
        public int LoadWorkingLineByWorkingLineID(WorkingLine obj)
        {
            string     sql = @"SELECT [WorkingLineID]
				, [WorkingLineName]
				, [Remark]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
                FROM [BE_WorkingLine] WITH(NOLOCK) WHERE [WorkingLineID]=@WorkingLineID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkingLineID = new SqlParameter("WorkingLineID", Convert2DBnull(obj.WorkingLineID));

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

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

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["WorkingLineID"]))
                    {
                        obj.WorkingLineID = (Guid)dr["WorkingLineID"];
                    }
                    obj.WorkingLineName = dr["WorkingLineName"].ToString();
                    obj.Remark          = dr["Remark"].ToString();
                    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 #3
0
        public int UpdateWorkingLineByWorkingLineName(WorkingLine obj)
        {
            string     sql = @"UPDATE [BE_WorkingLine] SET [WorkingLineID]=@WorkingLineID
				, [Remark]=@Remark
				, [Created]=@Created
				, [CreatedBy]=@CreatedBy
				, [Modified]=@Modified
				, [ModifiedBy]=@ModifiedBy
                WHERE [WorkingLineName]=@WorkingLineName"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkingLineID = new SqlParameter("WorkingLineID", Convert2DBnull(obj.WorkingLineID));

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

            SqlParameter pRemark = new SqlParameter("Remark", Convert2DBnull(obj.Remark));

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

            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 pWorkingLineName = new SqlParameter("WorkingLineName", Convert2DBnull(obj.WorkingLineName));

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

            return(cmd.ExecuteNonQuery());
        }