コード例 #1
0
ファイル: userService.cs プロジェクト: TouchLQL/BookStore
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="sex"></param>
        /// <param name="birth"></param>
        /// <param name="mail"></param>
        /// <param name="realName"></param>
        /// <param name="address"></param>
        /// <param name="telephone"></param>
        /// <returns></returns>
        public string registe(string userName, string password, string sex, string birth,
                              string mail, string realName, string address, string telephone)
        {
            bool   isexist = false;
            string sql_1   = "select userName from [user] where userName = '******'";

            isexist = db.YNExistData(sql_1);
            if (isexist == false)
            {
                string    sql1   = "select max(userID) as userid from [user]";
                DataTable dt     = db.GetDataTable(sql1);
                int       userid = int.Parse(dt.Rows[0][0].ToString());
                userid = userid + 1;

                string sql = "insert into [user](userID,userName, password, sex, birth, email,realName,address, telephone,type,balance)" +
                             "values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')";
                sql = string.Format(sql, userid, userName, password, sex, birth, mail, realName, address, telephone, "普通用户", "0");
                db.ExecuteNonQuery(sql);
                return("1");
            }
            else
            {
                return("0");
            }
        }
コード例 #2
0
ファイル: orderService.cs プロジェクト: TouchLQL/BookStore
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="bookmodel">图书实体</param>
        /// <returns>"1"表示新增成功 "0"表示新增失败</returns>
        public string add(order ordermodel)
        {
            string sql_1   = "select * from [order] where bookID = '" + ordermodel.ID + "'";
            bool   isExist = db.YNExistData(sql_1);

            if (isExist == false)
            {
                string    sql1    = "select max(ID) as orderid from [order]";
                DataTable dt      = db.GetDataTable(sql1);
                int       orderid = int.Parse(dt.Rows[0][0].ToString());
                orderid = orderid + 1;

                string sql = "insert into [order](ID,ordertime, ordernum, bookid, userid, type, money) " +
                             "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')";
                sql = string.Format(sql, orderid, ordermodel.ordertime,
                                    ordermodel.ordernum, ordermodel.bookid, ordermodel.userid,
                                    ordermodel.type, ordermodel.money);
                db.ExecuteNonQuery(sql);
                return("1");
            }
            else
            {
                return("0");
            }
        }
コード例 #3
0
        /// <summary>
        /// 新增图书
        /// </summary>
        /// <param name="bookmodel">图书实体</param>
        /// <returns>"1"表示新增成功 "0"表示新增失败</returns>
        public string add(book bookmodel)
        {
            string sql_1   = "select * from [book] where bookID = '" + bookmodel.bookID + "'";
            bool   isExist = db.YNExistData(sql_1);

            if (isExist == false)
            {
                string    sql1   = "select max(bookID) as bookid from [book]";
                DataTable dt     = db.GetDataTable(sql1);
                int       bookid = int.Parse(dt.Rows[0][0].ToString());
                bookid = bookid + 1;

                string sql = "insert into [book](bookID,bookName, writer, price, " +
                             " press, stock, type ,synopsis) " +
                             "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
                sql = string.Format(sql, bookid, bookmodel.bookName,
                                    bookmodel.writer, bookmodel.price, bookmodel.press, bookmodel.stock,
                                    bookmodel.type, bookmodel.synopsis);
                db.ExecuteNonQuery(sql);
                return("1");
            }
            else
            {
                return("0");
            }
        }
コード例 #4
0
ファイル: CustomerDAO.cs プロジェクト: HarryGuo221/Warehouse
        public void DeleteRela(DataGridView ddv)
        {
            SqlDBConnect sqldb   = new SqlDBConnect();
            int          indexid = 0;

            indexid = ddv.CurrentRow.Index;
            string sqlcustid = "select CustID " +
                               "from T_CustomerInf where CustName='" + ddv.Rows[indexid].Cells[0].Value.ToString().Trim() + "'";
            string custid          = (new SqlDBConnect()).Ret_Single_val_Sql(sqlcustid);
            string sqlparentcustid = "select CustID " +
                                     "from T_CustomerInf where CustName='" + ddv.Rows[indexid].Cells[1].Value.ToString().Trim() + "'";
            string parentcustid = (new SqlDBConnect()).Ret_Single_val_Sql(sqlparentcustid);

            string sql = "delete from T_Customer_Rela where CustID='" + custid + "' and ParentID='" + parentcustid + "'";

            try
            {
                sqldb.ExecuteNonQuery(sql);
                MessageBox.Show("数据更新成功!");
                ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch
            { MessageBox.Show("数据更新失败!"); }

            finally
            {
            }
        }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region //验证
            if (this.s_MainMenu.Text.Trim() == "")
            {
                MessageBox.Show("主菜单项不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.n_OrderIndex.Text.Trim() != "" && !Util.IsNumberic(this.n_OrderIndex))
            {
                MessageBox.Show("主顺序号输入有误,请输入数值!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Util.LessOneNumber(this.n_OrderIndex, this.menuStripMain.Items.Count) == false)
            {
                MessageBox.Show("主顺序号只能输入小于等于" + this.menuStripMain.Items.Count + "的数字!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            SqlDBConnect db        = new SqlDBConnect();
            InitFuncs    initFuncs = new InitFuncs();
            DBUtil       dbUtil    = new DBUtil();

            string strSql  = "";
            string strSql_ = "";
            if (this.isAdd == true) //新增
            {
                strSql_ = "select * from T_MenuCfgMain where Ltrim(Rtrim(MainMenu))='{0}'";
                strSql_ = string.Format(strSql_, this.s_MainMenu.Text.Trim());
                //插入
                strSql = initFuncs.Build_Insert_Sql(this.panelMenuMain, "T_MenuCfgMain");
            }
            else //修改
            {
                //更新
                string strSqlWhere = "where Sysid='" + this.n_Sysid.Text.Trim() + "'";
                strSql = initFuncs.Build_Update_Sql(this.panelMenuMain, "T_MenuCfgMain", strSqlWhere);

                strSql_ = "select * from T_MenuCfgMain where Ltrim(Rtrim(Sysid)) != {0} and Ltrim(Rtrim(MainMenu))='{1}'";
                strSql_ = string.Format(strSql_, this.n_Sysid.Text.Trim(), this.s_MainMenu.Text.Trim());
            }
            if (dbUtil.yn_exist_data(strSql_))
            {
                MessageBox.Show("该主菜单项已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            db.ExecuteNonQuery(strSql);
            MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            InitDataGridView();
        }
コード例 #6
0
        /// <summary>
        /// 保存
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            //输入数据有效性验证
            if (s_AttachName.Text.Trim() == "")
            {
                MessageBox.Show("附件名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string       strSqlSel = "";
            string       strSql    = "";
            DBUtil       dbUtil    = new DBUtil();
            SqlDBConnect db        = new SqlDBConnect();

            if (this.Type == "add")
            {
                //判断该资料原件记录是否已存在
                strSqlSel = "select * from T_BargAttach where barsysid={0} and AttachName='{1}'";
                strSqlSel = string.Format(strSqlSel, this.barsysid, this.s_AttachName.Text.Trim());

                strSql = (new InitFuncs()).Build_Insert_Sql(this.panel1, "T_BargAttach");
            }
            else if (this.Type == "edit")
            {
                int SysId = Convert.ToInt32(this.dataGridView1.SelectedRows[0].Cells["附件编号"].Value.ToString().Trim());
                strSqlSel = "select * from T_BargAttach where BarSysId like {0} and Ltrim(Rtrim(AttachName)) like '{1}' and Ltrim(Rtrim(SysId)) not like {2}";
                strSqlSel = string.Format(strSqlSel, this.barsysid, this.s_AttachName.Text.Trim(), SysId);

                string strWhere = "where SysId=" + SysId;
                strSql = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_BargAttach", strWhere);
            }
            bool isExist = dbUtil.yn_exist_data(strSqlSel);

            if (isExist)
            {
                MessageBox.Show("当前合同已存在该附件名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            db.ExecuteNonQuery(strSql);

            //MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            initdataGridview();
        }
コード例 #7
0
        public void Delete(DataGridView ddv)
        {
            SqlDBConnect sqldb   = new SqlDBConnect();
            int          indexid = 0;

            indexid = ddv.CurrentRow.Index;
            string sql = "";

            sql = "delete from T_CustomerCall where BargId='" + ddv.Rows[indexid].Cells["合同编号"].Value.ToString() + "'";
            try
            {
                sqldb.ExecuteNonQuery(sql);
                //MessageBox.Show("数据更新成功!");
                ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch { MessageBox.Show("数据更新失败或存在外码约束!"); }

            finally
            {
            }
        }
コード例 #8
0
        public void Delete(DataGridView ddv)
        {
            SqlDBConnect sqldb = new SqlDBConnect();

            int indexid = 0;

            indexid = ddv.CurrentRow.Index;
            string sql = "";

            sql = "delete from T_CustContacts where CName='" + ddv.Rows[indexid].Cells["联系姓名"].Value.ToString().Trim() + "'";
            try
            {
                sqldb.ExecuteNonQuery(sql);
                MessageBox.Show("删除成功!");
                ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch { MessageBox.Show("更新失败!"); }

            finally
            {
            }
        }
コード例 #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证
            if (this.s_ReceiptId.Text.Trim() == "")
            {
                MessageBox.Show("请输入拆件单据编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (this.comboBoxMatName.SelectedIndex == 0 || this.comboBoxMatName.Text.Trim() == "")
            {
                MessageBox.Show("请选择被拆物料!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (this.comboBoxMatType.SelectedIndex == 0 || this.comboBoxMatType.Text.Trim() == "")
            {
                MessageBox.Show("请选择被拆物料类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            #endregion

            SqlDBConnect db        = new SqlDBConnect();
            InitFuncs    initFuncs = new InitFuncs();
            DBUtil       dbUtil    = new DBUtil();
            this.s_OccurTime.Format = DateTimePickerFormat.Short;
            this.s_OccurTime.Value  = DBUtil.getServerTime();

            if (this.type == "add")
            {
                //插入之前判断
                string strSqlSel = "select * from T_MatSplit_Main where ReceiptId='{0}'";
                strSqlSel = string.Format(strSqlSel, this.s_ReceiptId.Text.Trim());
                bool isExist = dbUtil.yn_exist_data(strSqlSel);

                if (isExist)
                {
                    MessageBox.Show("已存在该拆件单据!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    List <string> sqls = new List <string>();
                    //插入拆件管理主表
                    string strSqlInsert = initFuncs.Build_Insert_Sql(this.panel1, "T_MatSplit_Main");
                    sqls.Add(strSqlInsert);

                    db.Exec_Tansaction(sqls);
                    MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理
                    this.Close();
                }
            }
            else if (this.type == "edit")
            {
                //更新
                string strWhere = "where ReceiptId='{0}'";
                strWhere = string.Format(strWhere, this.s_ReceiptId.Text.Trim());
                string strSqlUpdate = initFuncs.Build_Update_Sql(this.panel1, "T_MatSplit_Main", strWhere);
                db.ExecuteNonQuery(strSqlUpdate);

                MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理
                this.Close();
            }
        }
コード例 #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region //验证
            if (Util.ControlTextIsNUll(this.s_RoleId))
            {
                MessageBox.Show("角色编号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!Util.IsContainCharNumber(this.s_RoleId, 4))
            {
                MessageBox.Show("角色编号不能大于4位!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Util.ControlTextIsNUll(this.s_RoleName))
            {
                MessageBox.Show("角色名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            InitFuncs initFuncs    = new InitFuncs();
            string    strSqlInsert = initFuncs.Build_Insert_Sql(this.panelRoles, "T_Roles");

            //插入之前首先判断是否存在该角色
            DBUtil dbUtil = new DBUtil();

            bool isExist = false;
            if (this.s_RoleId.Text.Trim() != "")
            {
                isExist = dbUtil.Is_Exist_Data("T_Roles", "RoleId", this.s_RoleId.Text.Trim());
            }

            SqlDBConnect db = new SqlDBConnect();
            if (isExist == true)
            {
                if (this.s_RoleId.ReadOnly == false)
                {
                    MessageBox.Show("已存在该角色!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                //更新
                List <string> sqls         = new List <string>();
                string        strSqlWhere  = "where RoleId='" + this.s_RoleId.Text.ToString().Trim() + "'";
                string        strSqlUpdate = initFuncs.Build_Update_Sql(this.panelRoles, "T_Roles", strSqlWhere);
                sqls.Add(strSqlUpdate);

                //更新权限
                string strRoleId = this.s_RoleId.Text.Trim();

                //先删除
                string strSqlDelete = "delete from T_Role_Rights where RoleId='{0}'";
                strSqlDelete = string.Format(strSqlDelete, strRoleId);
                sqls.Add(strSqlDelete);

                List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项
                UserPermission(this.treeViewMenus, checkedNodes);

                foreach (TreeNode treeNode in checkedNodes)
                {
                    string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')";
                    strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim());

                    sqls.Add(strSql);
                }

                db.Exec_Tansaction(sqls);

                MessageBox.Show("更新成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                InitDataGridView(this.curSelectRowIndex);
                //btnCancel_Click(null, null);
            }
            else
            {
                //插入
                string strSql_ = "select * from T_Roles where Ltrim(Rtrim(RoleName))='{0}'";
                strSql_ = string.Format(strSql_, this.s_RoleName.Text.Trim());
                if (dbUtil.yn_exist_data(strSql_))
                {
                    MessageBox.Show("该角色名已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                db.ExecuteNonQuery(strSqlInsert);

                //分配权限
                string strRoleId = this.s_RoleId.Text.Trim();
                if (strRoleId != "")
                {
                    List <string> sqls = new List <string>();

                    List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项
                    UserPermission(this.treeViewMenus, checkedNodes);

                    foreach (TreeNode treeNode in checkedNodes)
                    {
                        string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')";
                        strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim());

                        sqls.Add(strSql);
                    }

                    db.Exec_Tansaction(sqls);
                }

                MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                InitDataGridView(0);
                btnCancel_Click(null, null);
            }
        }
コード例 #11
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            #region 输入验证
            if (Util.ControlTextIsNUll(this.s_UserId))
            {
                MessageBox.Show("用户编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!Util.IsContainCharNumber(this.s_UserId, 10))
            {
                MessageBox.Show("用户编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Util.ControlTextIsNUll(this.s_UserName))
            {
                MessageBox.Show("用户名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //if (Util.ControlTextIsNUll(this.s_SmsTel))
            //{
            //    MessageBox.Show("接收短信电话号码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    return;
            //}
            //if (Util.IsPhoneNumber(this.s_SmsTel,11) == false)
            //{
            //    MessageBox.Show("接收短信电话号码输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    return;
            //}

            if (this.s_OfficeTel.Text.Trim() != "" && Util.IsNumberic(this.s_OfficeTel) == false)
            {
                MessageBox.Show("办公电话输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                s_OfficeTel.Focus();
                return;
            }
            if (this.s_MobileTel.Text.Trim() != "" && Util.IsNumberic(this.s_MobileTel) == false)
            {
                MessageBox.Show("移动电话输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                s_MobileTel.Focus();
                return;
            }
            if (this.s_Email.Text.Trim() != "" && Util.IsEmail(this.s_Email.Text.Trim()) == false)
            {
                MessageBox.Show("Email输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                s_Email.Focus();
                return;
            }
            if (this.s_PassWord.Text.Trim() != "" && this.s_PassWord.Text.Trim() != this.txtPasswordCheck.Text.Trim())
            {
                MessageBox.Show("您两次输入的密码不一致,请重新输入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                s_PassWord.Focus();
                return;
            }
            #endregion

            //数据处理
            SqlDBConnect db        = new SqlDBConnect();
            InitFuncs    initFuncs = new InitFuncs();
            DBUtil       dbUtil    = new DBUtil();

            string strSql  = "";
            string strSql_ = "";
            if (this.type == "add")
            {
                string strSqlInsert = initFuncs.Build_Insert_Sql(this.panelUser, "T_Users");

                //插入之前首先判断是否存在该用户
                bool isExist = dbUtil.Is_Exist_Data("T_Users", "UserId", this.s_UserId.Text.Trim());

                if (isExist == true) //该用户名已存在
                {
                    MessageBox.Show("该用户已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                strSql_ = "select * from T_Users where Ltrim(Rtrim(UserName))='{0}'";
                strSql_ = string.Format(strSql_, this.s_UserName.Text.Trim());

                //插入
                strSql = initFuncs.Build_Insert_Sql(this.panelUser, "T_Users");
            }
            else if (this.type == "edit")
            {
                //更新
                strSql_ = "select * from T_Users where Ltrim(Rtrim(UserId)) != '{0}' and Ltrim(Rtrim(UserName))='{1}'";
                strSql_ = string.Format(strSql_, this.s_UserId.Text.Trim(), this.s_UserName.Text.Trim());

                string strSqlWhere = "where UserId='" + this.s_UserId.Text.Trim() + "'";
                strSql = initFuncs.Build_Update_Sql(this.panelUser, "T_Users", strSqlWhere);
            }
            if (dbUtil.yn_exist_data(strSql_))
            {
                MessageBox.Show("该用户已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            db.ExecuteNonQuery(strSql);
            MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            userInfoFormChange(); //激活代理事件,在UserForm中处理
            this.Close();
        }