/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.tTaskLook model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tTaskLook set ");
            strSql.Append("TaskId=@TaskId,");
            strSql.Append("DptId=@DptId");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskId", SqlDbType.Int, 4),
                new SqlParameter("@DptId",  SqlDbType.Int, 4),
                new SqlParameter("@Id",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.TaskId;
            parameters[1].Value = model.DptId;
            parameters[2].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.tTaskLook model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tTaskLook(");
            strSql.Append("TaskId,DptId)");
            strSql.Append(" values (");
            strSql.Append("@TaskId,@DptId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TaskId", SqlDbType.Int, 4),
                new SqlParameter("@DptId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.TaskId;
            parameters[1].Value = model.DptId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tTaskLook DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tTaskLook model = new Maticsoft.Model.tTaskLook();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["TaskId"] != null && row["TaskId"].ToString() != "")
         {
             model.TaskId = int.Parse(row["TaskId"].ToString());
         }
         if (row["DptId"] != null && row["DptId"].ToString() != "")
         {
             model.DptId = int.Parse(row["DptId"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tTaskLook GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,TaskId,DptId from tTaskLook ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Maticsoft.Model.tTaskLook model = new Maticsoft.Model.tTaskLook();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.tTaskLook BLLtt = new Maticsoft.BLL.tTaskLook();

            FineUIPro.TreeNode[] nodes = TreeDpt.GetCheckedNodes();


            if (nodes.Length <= 0)
            {
                Alert.ShowInTop("请选择接收单位!");
                return;
            }
            string dptlist = "";

            foreach (FineUIPro.TreeNode node in nodes)
            {
                dptlist += node.NodeID.ToString() + ",";
            }
            dptlist = dptlist.Substring(0, dptlist.Length - 1);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                string      Id = Request.QueryString["Id"];
                Model.tTask m  = bll.GetModel(Convert.ToInt32(Id));
                if (m == null)
                {
                    return;
                }
                string content2 = Request.Form["editorNew2"] == null ? "" : Request.Form["editorNew2"];
                m.TaskContent = content2;
                m.Title       = txtTitle.Text;
                m.SaveTime    = DateTimeTop.SelectedDate;
                m.LockTime    = DateTimeLock.SelectedDate;
                m.TaskLevel   = drpSearch.SelectedValue;
                if (m.LookDptString == dptlist)
                {
                }
                else
                {
                    BLLtt.Delete(m.Id);
                    Maticsoft.Model.tTaskLook mlook = new Maticsoft.Model.tTaskLook();

                    foreach (FineUIPro.TreeNode node in nodes)
                    {
                        mlook.TaskId = m.Id;
                        mlook.DptId  = int.Parse(node.NodeID);
                        BLLtt.Add(mlook);
                    }

                    m.LookDptString = dptlist;
                }
                if (bll.Update(m) == true)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("出错了!");
                }
            }
            else
            {
                Model.tTask m        = new Model.tTask();
                string      content2 = Request.Form["editorNew2"] == null ? "" : Request.Form["editorNew2"];
                m.TaskContent   = content2;
                m.Title         = txtTitle.Text;
                m.SaveTime      = DateTimeTop.SelectedDate;
                m.LockTime      = DateTimeLock.SelectedDate;
                m.TaskLevel     = drpSearch.SelectedValue;
                m.LookDptString = dptlist;
                m.IsCheck       = "待审核";
                m.SavaPeo       = GetIdentityUser().usersName;
                m.SaveDpt       = GetIdentityUser().dptId;
                int k = bll.Add(m);

                Maticsoft.Model.tTaskLook mlook = new Maticsoft.Model.tTaskLook();

                foreach (FineUIPro.TreeNode node in nodes)
                {
                    mlook.TaskId = k;
                    mlook.DptId  = int.Parse(node.NodeID);
                    BLLtt.Add(mlook);
                }

                if (k > 0)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
            }
        }