コード例 #1
0
        public bool Insert(MODELloginGroup MODELloginGroup)
        {
            StringBuilder str = new StringBuilder();

            str.Append("INSERT INTO loginGroup(groupId,groupName,MEMO) ");
            str.Append("VALUES(@groupId,@groupName,@MEMO)");
            SqlParameter[] para =
            {
                new SqlParameter("@groupId",   SqlDbType.VarChar, 10),
                new SqlParameter("@groupName", SqlDbType.VarChar, 50),
                new SqlParameter("@MEMO",      SqlDbType.VarChar, 50)
            };
            para[0].Value = MODELloginGroup.groupId;
            para[1].Value = MODELloginGroup.groupName;
            para[2].Value = MODELloginGroup.MEMO;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public MODELloginGroup GetModelloginGroup(string strDepID)
        {
            DataTable       dt = new DataTable();
            MODELloginGroup MODELloginGroup = new MODELloginGroup();
            StringBuilder   str             = new StringBuilder();

            str.Append("SELECT * FROM loginGroup WHERE groupId=@groupId");
            SqlParameter[] para =
            {
                new SqlParameter("@groupId", SqlDbType.VarChar, 30)
            };
            para[0].Value = strDepID;
            dt            = DBUtility.DbHelperSQL.Query(str.ToString(), para).Tables[0];
            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                MODELloginGroup.groupName = dt.Rows[0]["groupName"].ToString();
                if (dt.Rows[0]["MEMO"] != null)
                {
                    MODELloginGroup.MEMO = dt.Rows[0]["MEMO"].ToString();
                }
                return(MODELloginGroup);
            }
        }
コード例 #3
0
        public bool Update(MODELloginGroup MODELloginGroup)
        {
            StringBuilder str = new StringBuilder();

            str.Append("UPDATE loginGroup SET groupName=@groupName,MEMO=@MEMO ");
            str.Append("WHERE groupId=@groupId");
            SqlParameter[] para =
            {
                new SqlParameter("@groupName", SqlDbType.VarChar, 50),
                new SqlParameter("@MEMO",      SqlDbType.VarChar, 50),
                new SqlParameter("@groupId",   SqlDbType.VarChar, 50)
            };
            para[0].Value = MODELloginGroup.groupName;
            para[1].Value = MODELloginGroup.MEMO;
            para[2].Value = MODELloginGroup.groupId;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        private void toolSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtID.Text == "0001")
                {
                    mes.Show("该用户组无法修改和删除!");
                    return;
                }
                if (txtName.Text.Trim() == "")
                {
                    mes.Show("请输入组名称!");
                    txtName.Focus();
                    return;
                }

                MODELloginGroup MODELloginGroup = new MODELloginGroup();
                MODELloginGroup.groupName = txtName.Text;
                MODELloginGroup.MEMO      = txtMemo.Text;
                if (txtID.Text == "")
                {
                    MODELloginGroup.groupId = GETTABLEID.GetTableID("", "loginGroup");
                    if (BLLloginGroup.Insert(MODELloginGroup))
                    {
                        toolSearch_Click(null, null);
                        dgList.ClearSelection();
                        dgList.CurrentCell = dgList.Rows[dgList.Rows.Count - 1].Cells[1];
                        dgList_SelectionChanged(null, null);
                    }
                    else
                    {
                        mes.Show("添加失败,请重新点击保存按钮!");
                        return;
                    }
                }
                else
                {
                    MODELloginGroup.groupId = txtID.Text;
                    if (BLLloginGroup.Update(MODELloginGroup))
                    {
                        dgList.CurrentRow.Cells["groupId"].Value   = MODELloginGroup.groupId;
                        dgList.CurrentRow.Cells["groupName"].Value = MODELloginGroup.groupName;
                        dgList.CurrentRow.Cells["MEMO"].Value      = MODELloginGroup.MEMO;
                    }
                    else
                    {
                        mes.Show("修改失败,请重新点击保存按钮!");
                        return;
                    }
                }
                //DisEnableControl(gbDetail);

                dgList.Enabled     = true;
                toolAdd.Text       = "添加";
                toolDelete.Enabled = true;
                toolSearch.Enabled = true;
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, MsgType.Error);
                mes.Show(ex.Message);
            }
        }