Ejemplo n.º 1
0
        public int UpdateWorkShopByWorkShopCode(WorkShop obj)
        {
            string     sql = @"UPDATE [BE_WorkShop] SET [WorkShopID]=@WorkShopID
				, [WorkShopName]=@WorkShopName
				, [WorkingLineID]=@WorkingLineID
				, [Remark]=@Remark
				, [Created]=@Created
				, [CreatedBy]=@CreatedBy
				, [Modified]=@Modified
				, [ModifiedBy]=@ModifiedBy
                WHERE [WorkShopCode]=@WorkShopCode"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkShopID = new SqlParameter("WorkShopID", Convert2DBnull(obj.WorkShopID));

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

            SqlParameter pWorkShopName = new SqlParameter("WorkShopName", Convert2DBnull(obj.WorkShopName));

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

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

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

            return(cmd.ExecuteNonQuery());
        }
Ejemplo n.º 2
0
        public List <WorkShop> LoadWorkShopsByWorkingLineID(Guid workingLineID)
        {
            string     sql = @"SELECT [WorkShopID]
				, [WorkShopCode]
				, [WorkShopName]
				, [WorkingLineID]
				, [Remark]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
				 FROM [BE_WorkShop] 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 <WorkShop> ret = new List <WorkShop>();
            SqlDataReader   dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    WorkShop iret = new WorkShop();
                    if (!Convert.IsDBNull(dr["WorkShopID"]))
                    {
                        iret.WorkShopID = (Guid)dr["WorkShopID"];
                    }
                    iret.WorkShopCode = dr["WorkShopCode"].ToString();
                    iret.WorkShopName = dr["WorkShopName"].ToString();
                    if (!Convert.IsDBNull(dr["WorkingLineID"]))
                    {
                        iret.WorkingLineID = (Guid)dr["WorkingLineID"];
                    }
                    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);
        }
Ejemplo n.º 3
0
        public int LoadWorkShopByWorkShopID(WorkShop obj)
        {
            string     sql = @"SELECT [WorkShopID]
				, [WorkShopCode]
				, [WorkShopName]
				, [WorkingLineID]
				, [Remark]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
                FROM [BE_WorkShop] WITH(NOLOCK) WHERE [WorkShopID]=@WorkShopID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkShopID = new SqlParameter("WorkShopID", Convert2DBnull(obj.WorkShopID));

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

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

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["WorkShopID"]))
                    {
                        obj.WorkShopID = (Guid)dr["WorkShopID"];
                    }
                    obj.WorkShopCode = dr["WorkShopCode"].ToString();
                    obj.WorkShopName = dr["WorkShopName"].ToString();
                    if (!Convert.IsDBNull(dr["WorkingLineID"]))
                    {
                        obj.WorkingLineID = (Guid)dr["WorkingLineID"];
                    }
                    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);
        }
Ejemplo n.º 4
0
        public int InsertWorkShop(WorkShop obj)
        {
            string     sql = @"INSERT INTO[BE_WorkShop]([WorkShopID]
				, [WorkShopCode]
				, [WorkShopName]
				, [WorkingLineID]
				, [Remark]
				, [Created]
				, [CreatedBy]
				, [Modified]
				, [ModifiedBy]
				) VALUES(@WorkShopID
				, @WorkShopCode
				, @WorkShopName
				, @WorkingLineID
				, @Remark
				, @Created
				, @CreatedBy
				, @Modified
				, @ModifiedBy
				)"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pWorkShopID = new SqlParameter("WorkShopID", Convert2DBnull(obj.WorkShopID));

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

            SqlParameter pWorkShopCode = new SqlParameter("WorkShopCode", Convert2DBnull(obj.WorkShopCode));

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

            SqlParameter pWorkShopName = new SqlParameter("WorkShopName", Convert2DBnull(obj.WorkShopName));

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

            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);

            return(cmd.ExecuteNonQuery());
        }