Exemple #1
0
        private void InfoBind()
        {
            SpotSelectProblem SpotSelectProblem = db.SpotSelectProblem.FirstOrDefault(t => t.ID == ID);

            if (SpotSelectProblem != null)
            {
                this.txt_Problem.Text = SpotSelectProblem.Problem;
                this.txt_Order.Text   = SpotSelectProblem.Order.ToString();
            }
        }
Exemple #2
0
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     try
     {
         try
         {
             string ids = this.hf_CheckIDS.Value.ToString();
             ids = ids.TrimEnd(',').TrimStart(',');
             foreach (string id in ids.Split(','))
             {
                 int iid = Convert.ToInt32(id);
                 SpotSelectProblem SpotSelectProblem = db.SpotSelectProblem.FirstOrDefault(t => t.ID == iid);
                 if (SpotSelectProblem == null)
                 {
                     ShowMessage("找不到选择的点检问题");
                     return;
                 }
                 SpotSelectProblem.IsDel = true;
             }
             db.SaveChanges();
             new SysLogDAO().AddLog(LogType.操作日志_删除, "成功删除点检问题信息", UserID);
         }
         catch
         {
             ShowMessage("删除失败");
             return;
         }
     }
     catch (Exception ex)
     {
         ShowMessage(ex.Message);
         new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID);
     }
     DataListBind();
     this.hf_CheckIDS.Value = "";
 }
Exemple #3
0
 protected void btn_Sumbit_Click(object sender, EventArgs e)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             try
             {
                 SpotSelectProblem SpotSelectProblem = db.SpotSelectProblem.FirstOrDefault(t => t.ID == ID);
                 if (SpotSelectProblem == null)
                 {
                     SpotSelectProblem         = new SpotSelectProblem();
                     SpotSelectProblem.Problem = txt_Problem.Text;
                     if (string.IsNullOrEmpty(SpotSelectProblem.Problem))
                     {
                         ShowMessage("请输入问题描述");
                         return;
                     }
                     if (db.SpotSelectProblem.FirstOrDefault(x => x.Problem == this.txt_Problem.Text.ToString()) != null)
                     {
                         ShowMessage("该问题已存在,请检查后重新添加");
                         return;
                     }
                     SpotSelectProblem.Order = Convert.ToInt32(txt_Order.Text);
                     SpotSelectProblem.IsDel = false;
                     db.SpotSelectProblem.Add(SpotSelectProblem);
                     db.SaveChanges();
                 }
                 else
                 {
                     SpotSelectProblem.Problem = txt_Problem.Text;
                     if (string.IsNullOrEmpty(SpotSelectProblem.Problem))
                     {
                         ShowMessage("请输入问题描述");
                         ts.Dispose();
                         return;
                     }
                     if (db.SpotSelectProblem.FirstOrDefault(x => x.Problem == this.txt_Problem.Text.ToString() && x.ID != SpotSelectProblem.ID) != null)
                     {
                         ShowMessage("该问题已存在,请检查后重新添加");
                         return;
                     }
                     SpotSelectProblem.Order = Convert.ToInt32(txt_Order.Text);
                     db.SaveChanges();
                 }
                 ShowMessage();
                 LogType log = (ID == -1 ? LogType.操作日志_添加 : LogType.操作日志_修改);
                 new SysLogDAO().AddLog(log, (ID == -1 ? "增加" : "修改") + "点检问题信息");
                 ts.Complete();
             }
             catch
             {
                 ShowMessage("提交失败");
                 ts.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         ShowMessage(ex.Message);
         new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID);
     }
 }