Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.SMT_DEPT_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SMT_DEPT_USER(");
            strSql.Append("DEPT_ID,USER_ID)");
            strSql.Append(" values (");
            strSql.Append("@DEPT_ID,@USER_ID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DEPT_ID", SqlDbType.Decimal, 9),
                new SqlParameter("@USER_ID", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.DEPT_ID;
            parameters[1].Value = model.USER_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SMT_DEPT_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SMT_DEPT_USER set ");
#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
            strSql.Append("DEPT_ID=@DEPT_ID,");
            strSql.Append("USER_ID=@USER_ID");
            strSql.Append(" where DEPT_ID=@DEPT_ID and USER_ID=@USER_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DEPT_ID", SqlDbType.Decimal, 9),
                new SqlParameter("@USER_ID", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.DEPT_ID;
            parameters[1].Value = model.USER_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SMT_DEPT_USER GetModel(decimal DEPT_ID, decimal USER_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 DEPT_ID,USER_ID from SMT_DEPT_USER ");
            strSql.Append(" where DEPT_ID=@DEPT_ID and USER_ID=@USER_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DEPT_ID", SqlDbType.Decimal, 9),
                new SqlParameter("@USER_ID", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = DEPT_ID;
            parameters[1].Value = USER_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.SMT_DEPT_USER DataRowToModelEx(DataRow row)
 {
     Maticsoft.Model.SMT_DEPT_USER model = new Maticsoft.Model.SMT_DEPT_USER();
     if (row != null)
     {
         if (row["DEPT_ID"] != null && row["DEPT_ID"].ToString() != "")
         {
             model.DEPT_ID = decimal.Parse(row["DEPT_ID"].ToString());
         }
         if (row["USER_ID"] != null && row["USER_ID"].ToString() != "")
         {
             model.USER_ID = decimal.Parse(row["USER_ID"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            List <Node> nodes = advTree.GetNodeList(true, typeof(Maticsoft.Model.SMT_USER_INFO));

            SelectedUsers = new List <Maticsoft.Model.SMT_DEPT_USER>();
            foreach (var item in nodes)
            {
                Maticsoft.Model.SMT_USER_INFO user = (Maticsoft.Model.SMT_USER_INFO)item.Tag;
                Maticsoft.Model.SMT_DEPT_USER du   = new Maticsoft.Model.SMT_DEPT_USER();
                du.DEPT_ID   = _orgId;
                du.USER_ID   = user.ID;
                du.USER_INFO = user;
                SelectedUsers.Add(du);
            }
            Maticsoft.BLL.SMT_DEPT_USER duBll = new Maticsoft.BLL.SMT_DEPT_USER();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    foreach (var item in SelectedUsers)
                    {
                        if (_selectUserIds.Contains(item.USER_ID))
                        {
                            continue;
                        }
                        else
                        {
                            duBll.Add(item);
                        }
                    }
                    this.BeginInvoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存异常!" + ex.Message);
                }
            });

            waiting.Show(this);
        }