| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | using CCWin.SkinClass;using DevComponents.DotNetBar;using SyntacticSugar;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using WCS_Client.UC;using WCS_Client.Utility;namespace WCS_Client.Frm{    public partial class FrmUpdatePriority : Office2007Form    {        DataRow dr = null; DataTable dt = null;        public FrmUpdatePriority(DataTable datarow)        {            InitializeComponent();            dt = datarow;            int maxPriority = 0;            for (int i = 0; i < dt.Rows.Count; i++)            {                var pr = dt.Rows[i]["Priority"].ToInt32();                if (pr > maxPriority)                {                    maxPriority = pr;                }            }            nudPriority.Value = maxPriority;        }        private void btnCancel_Click(object sender, EventArgs e)        {            this.Close();        }        private void btnSave_Click(object sender, EventArgs e)        {            if (string.IsNullOrEmpty(txtReason.Text))            {                MessageBox.Show("请输入原因");                return;            }            var result = MessageUtil.ShowYesNoAndWarning(string.Format("确定要变更优先级吗?"));            if (result == DialogResult.Yes)            {                //dt = dt.Clone();                string res = "";                for (int i = 0; i < dt.Rows.Count; i++)                {                    var dr = dt.Rows[i];                    var task_no = Convert.ToInt32(dr["ID"].ToString());                    int priority = nudPriority.Value.ToInt32();                    res = TryCachHelper.TryTranExecute((db) =>                   {                       var task = db.Queryable<WCS_TASK>().First(v => v.ID == task_no);                       if (task == null)                       {                           throw new Exception(string.Format("未查询到WCS任务[{0}]信息", task_no));                       }                       else                       {                           if (db.Updateable<WCS_TASK>()                                 .UpdateColumns(it => new WCS_TASK                                 {                                     Priority = priority,                                     UPDATEUSER = CurrentHelper.User.Use_Name,                                     UPDATETIME = DateTime.Now                                 })                                 .Where(v => v.ID == task_no).ExecuteCommand() < 0)                           {                               throw new Exception(string.Format("WCS任务[{0}]调整优先级失败", task_no));                           }                           //string msg = string.Format("任务[{0}]调整优先级为[{1}]成功。", task_no, priority);                       }                   });                    if (string.IsNullOrWhiteSpace(res))                    {                        //res = string.Format("任务[{0}]调整优先级[{1}]成功。", task_no.ToString(), priority);                    }                }                MessageBox.Show(res);                //string massge = BaseWorkflow.UpdateTaskPriority(Convert.ToInt32(lbltask_no.Text.Trim()), (int)nudPriority.Value);                //MessageUtil.ShowTips(res);                this.Close();            }        }    }}
 |