public void DataBinding_dbGridView(int ACurrRowIndex)
 {
     try
     {
         if (!AppServer.WcfService_Open())
         {
             return;
         }
         //
         var dtm = new Ref_WS_STK.DataType_User();
         dtm.ExAction  = "List";
         dtm.UserState = this.cbxUserState.SelectedIndex - 1;
         this.dbGridView.DataSource = AppServer.wcfClient.Sys_User_List(dtm).Tables[0];
         this.dbGridView.GoToRowByIndex(ACurrRowIndex);
         int count = this.dbGridView.Rows.Count;
     }
     catch (Exception ex)
     {
         AppServer.ShowMsg_ExceptError(ex.Message);
         return;
     }
     finally
     {
         AppServer.WcfService_Close();
     }
 }
Beispiel #2
0
        private void DataBinding_cbx仓管员()
        {
            var model = new Ref_WS_STK.DataType_User();

            model.ExAction  = "List";
            model.UserState = 0;
            AppServer.UsingWcf(() =>
            {
                this.cbx仓管员.ValueMember   = "UserCode";
                this.cbx仓管员.DisplayMember = "UserName";
                this.cbx仓管员.DataSource    = AppServer.wcfClient.Sys_User_List(model).Tables[0];
            });
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.None;

            if (this.txt新设密码.Text != this.txt确认密码.Text)
            {
                AppServer.ShowMsg_Warn("新设密码与确认密码不一致,请重新输入!", "密码对比");
                this.txt新设密码.Focus();
                return;
            }

            base.Cursor = Cursors.WaitCursor;
            try
            {
                if (!AppServer.WcfService_Open())
                {
                    return;
                }
                //
                var dtm = new Ref_WS_STK.DataType_User();
                dtm.ExAction    = "ModPswd";
                dtm.UserCode    = AppServer.LoginUserCode;
                dtm.UserPswd    = this.txt当前密码.Text;
                dtm.NewUserPswd = this.txt新设密码.Text;

                AppServer.wcfClient.Sys_User_Edit(ref dtm);

                if (dtm.ExResult != 0)
                {
                    AppServer.ShowMsg_SubmitError(dtm.ErrorMsg);
                    if (dtm.ExResult == 1)
                    {
                        this.txt当前密码.Focus();
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_ExceptError(ex.Message);
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }
            //提交成功了
            this.DialogResult = DialogResult.OK;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.None;

            string sRoleList = "";

            foreach (ListViewItem lvi in this.listView.Items)
            {
                if (lvi.Checked)
                {
                    sRoleList += (String.IsNullOrEmpty(sRoleList) ? "" : ",") + lvi.SubItems[2].Text;
                }
            }

            base.Cursor = Cursors.WaitCursor;
            try
            {
                if (!AppServer.WcfService_Open())
                {
                    return;
                }

                var dtm = new Ref_WS_STK.DataType_User();
                dtm.UserCode = FUserCode;
                dtm.RoleList = sRoleList;
                dtm.ExAction = "ModRole";

                AppServer.wcfClient.Sys_User_Edit(ref dtm);

                if (dtm.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(dtm.ErrorMsg);
                    return;
                }
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_ExceptError(ex.Message);
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }
            //
            this.DialogResult = DialogResult.OK;
        }
        private void btnDelUser_Click(object sender, EventArgs e)
        {
            if ((dbGridView.Rows.Count == 0) || (dbGridView.SelectedRows.Count == 0))
            {
                return;
            }
            if (!AppServer.DialogMsg("确认要删除当前用户吗?", "删除确认"))
            {
                return;
            }

            string sUserCode = this.dbGridView.CurrentRow.Cells["UserCode"].Value.ToString().Trim();

            //开始删除
            base.Cursor = Cursors.WaitCursor;
            try
            {
                var dmt = new Ref_WS_STK.DataType_User();
                dmt.UserCode = sUserCode;
                dmt.ExAction = "Del";

                if (!AppServer.WcfService_Open())
                {
                    return;
                }
                //
                AppServer.wcfClient.Sys_User_Edit(ref dmt);

                if (dmt.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(dmt.ErrorMsg);
                    return;
                }
                this.DataBinding_dbGridView(this.dbGridView.CurrentRow.Index - 1);
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_SubmitError(ex.Message);
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }
        }
Beispiel #6
0
        private void TfmMan_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = false;
            if (!FLoginSuccess)
            {
                return;
            }
            //退出提示
#if !DEBUG
            if (AppServer.DialogMsg("感谢您的使用,确认要退出系统吗?", "退出提示"))
            {
                //开始验证登录
                base.Cursor = Cursors.WaitCursor;
                try
                {
                    if (!AppServer.WcfService_Open())
                    {
                        return;
                    }
                    //
                    var model = new Ref_WS_STK.DataType_User();
                    model.LoginID = AppServer.LoginID;
                    AppServer.wcfClient.SYS_Logout(model);
                    if (model.ExResult != 0)
                    {
                        AppServer.ShowMsg_Error(model.ErrorMsg, "退出登录注册失败了!");
                        return;
                    }
                }
                catch
                {
                    return;
                }
                finally
                {
                    AppServer.WcfService_Close();
                    base.Cursor = Cursors.Arrow;
                }
            }
            else
            {
                e.Cancel = true;
            }
#endif
        }
Beispiel #7
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.None;

            if (this.txtLoginName.Text.Trim().Length == 0)
            {
                AppServer.ShowMsg("请输入要登录的用户账号!");
                this.txtLoginName.Focus();
                this.DialogResult = DialogResult.None;
                return;
            }
            //开始验证登录
            base.Cursor = Cursors.WaitCursor;
            try
            {
                if (!AppServer.WcfService_Open())
                {
                    return;
                }
                //
                var model = new Ref_WS_STK.DataType_User();
                model.LoginName = this.txtLoginName.Text;
                model.LoginPswd = this.txtLoginPswd.Text;
                model.LoginDate = this.dtpLoginDate.Value;
                model.LoginAddr = TY.Common.NetWork.GetLocalIP();
                model.LoginID   = AppServer.LoginID; //重新登录时会用于注册退出使用

                AppServer.wcfClient.SYS_Login(ref model);

                if (model.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(model.ErrorMsg, "登录失败了!");
                    switch (model.ExResult)
                    {
                    case 1: this.txtLoginName.Focus(); break;

                    case 2: this.txtLoginPswd.Focus(); break;

                    case 3: this.dtpLoginDate.Focus(); break;
                    }
                    return;
                }
                AppServer.LoginUserCode = model.UserCode;
                AppServer.LoginUserName = model.UserName;
                AppServer.LoginWorkDate = this.dtpLoginDate.Value;
                AppServer.LoginID       = model.LoginID;
                //获取用户菜单列表
                DataSet tdb = AppServer.wcfClient.SYS_Login_Menu(ref model);
                if (model.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(model.ErrorMsg, "登录失败了!");
                    return;
                }
                if (AppServer.UserQxMenuList != null)
                {
                    AppServer.UserQxMenuList.Dispose();
                }
                AppServer.UserQxMenuList            = tdb.Tables[0].Copy();
                AppServer.UserQxMenuList.PrimaryKey = new DataColumn[1] {
                    AppServer.UserQxMenuList.Columns["MenuCode"]
                };
                //获取系统参数
                AppServer.wcfClient.SYS_Param_Get(ref AppServer.Sys_Param);
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_Error("系统登录时出现异常,请确认您的网络连接是否有问题!\n错误信息:" + ex.Message, "登录失败了!");
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }

            //登录成功了
            if (this.chkRemember.Checked)
            {
                Properties.Settings.Default.LoginName = this.txtLoginName.Text;
                Properties.Settings.Default.LoginPswd = Cmn_DataProtection.ProtectData(txtLoginPswd.Text, "GLG_STK_Password");
                Properties.Settings.Default.LoginRemb = this.chkRemember.Checked;
            }
            else
            {
                Properties.Settings.Default.LoginName = string.Empty;
                Properties.Settings.Default.LoginPswd = string.Empty;
                Properties.Settings.Default.LoginRemb = this.chkRemember.Checked;
            }
            Properties.Settings.Default.Save();

            this.DialogResult = DialogResult.OK;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.txtUserCode.Text.Trim() == "")
            {
                AppServer.ShowMsg_Warn("用户账号不能为空  ", "数据验证");
                this.txtUserCode.Focus();
                return;
            }
            if (this.txtUserName.Text.Trim() == "")
            {
                AppServer.ShowMsg_Warn("用户名称不能为空  ", "数据验证");
                this.txtUserName.Focus();
                return;
            }
            //
            this.DialogResult = DialogResult.None;
            try
            {
                var model = new Ref_WS_STK.DataType_User();
                TY.Helper.FormHelper.DataBinding_DataSourceToModel(this, model);
                model.ExAction  = this.Tag.ToString();
                model.UserState = this.cbxUserState.SelectedIndex;
                if (model.ExAction == "Mod")
                {
                    model.UserCode    = this.txtUserCode.Tag.ToString();
                    model.NewUserCode = this.txtUserCode.Text;
                }
                //组合生成工作岗位
                StringBuilder sb = new StringBuilder();
                if (this.chk采购员.Checked)
                {
                    sb.Append("采购员");
                }
                if (this.chk销售员.Checked)
                {
                    if (sb.Length > 1)
                    {
                        sb.Append(",");
                    }
                    sb.Append("销售员");
                }
                model.工作岗位 = sb.ToString();

                if (!AppServer.WcfService_Open())
                {
                    return;
                }

                AppServer.wcfClient.Sys_User_Edit(ref model);

                if (model.ExResult != 0)
                {
                    AppServer.ShowMsg_SubmitError(model.ErrorMsg);
                    switch (model.ExResult)
                    {
                    case 1: this.txtUserCode.Focus(); break;
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_ExceptError(ex.Message);
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }
            //提交成功了
            this.DialogResult = DialogResult.OK;
        }
Beispiel #9
0
        public Boolean Login(Boolean AFirst = false)
        {
            bool bLogined = false;

            if (!string.IsNullOrWhiteSpace(AppServer.LoginUserCode) && AFirst)
            {
                var model = new Ref_WS_STK.DataType_User();
                model.ExAction  = "OA";
                model.LoginName = AppServer.LoginUserCode;
                AppServer.UsingWcf(() =>
                {
                    AppServer.wcfClient.SYS_Login(ref model);
                });
                if (model.ExResult == 0)
                {
                    AppServer.LoginUserCode = model.UserCode;
                    AppServer.LoginUserName = model.UserName;
                    AppServer.LoginWorkDate = DateTime.Now;
                    AppServer.LoginID       = model.LoginID;
                    //获取用户菜单列表
                    AppServer.UsingWcf(() =>
                    {
                        DataSet tdb = AppServer.wcfClient.SYS_Login_Menu(ref model);

                        if (model.ExResult != 0)
                        {
                            bLogined = false;
                        }
                        else
                        {
                            if (AppServer.UserQxMenuList != null)
                            {
                                AppServer.UserQxMenuList.Dispose();
                            }
                            AppServer.UserQxMenuList            = tdb.Tables[0].Copy();
                            AppServer.UserQxMenuList.PrimaryKey = new DataColumn[1] {
                                AppServer.UserQxMenuList.Columns["MenuCode"]
                            };
                            //获取系统参数
                            AppServer.wcfClient.SYS_Param_Get(ref AppServer.Sys_Param);
                            bLogined = true;
                        }
                    });
                }
            }
            //
            if (!bLogined)
            {
                using (var fLogin = new Man_Login())
                {
                    fLogin.Visible = false;
                    fLogin.LoginType(AFirst);
                    if (fLogin.ShowDialog() != DialogResult.OK)
                    {
                        //登录失败了,直接返回
                        return(false);
                    }
                    //登录成功了
                    base.Cursor = Cursors.WaitCursor;
                }
            }
            //
            try
            {
                //更新界面属性
                this.Text = string.Format("{0} {1}", AppServer.Sys_Param.AppName, Man_About.AssemblyAppVer);
                this.toolStripLabelTitle.Text = string.Format("『{0}』的功能树", AppServer.LoginUserName);
                this.tsslAppHost.Text         = string.Format("应用服务器:{0}", AppServer.wcfClient.Endpoint.Address.Uri.Host.ToString());
                this.tsslWorkDate.Text        = string.Format("业务日期:{0:yyyy-MM-dd}", AppServer.LoginWorkDate);
                this.tsslLoginUser.Text       = string.Format("  操作员:({0}){1}  ", AppServer.LoginUserCode, AppServer.LoginUserName);
                this.tsslAppUnit.Text         = string.Format("  公司名称:{0}", AppServer.Sys_Param.公司名称);

                //创建用户功能树
                if (AppServer.UserQxMenuList != null)
                {
                    //DataView dv = new DataView(AppServer.UserQxMenuList);
                    //dv.RowFilter = "MenuType=0 or MenuType=1";
                    DataTable dt = AppServer.UserQxMenuList.Clone();
                    foreach (DataRow row in AppServer.UserQxMenuList.Select("MenuType=0 or MenuType=1", "MenuPCode, MenuOrder, MenuCode"))
                    {
                        dt.Rows.Add(row.ItemArray);
                    }
                    this.dbTreeView.DataSource = dt; // AppServer.UserQxMenuList;
                    this.dbTreeView.BuildTrees();
                }
                //重新登录后要把子窗口全部关闭
                if (!AFirst)
                {
                    foreach (Form fMDI in this.MdiChildren)
                    {
                        fMDI.Close();
                    }
                }
                //返回成功登录了
                return(true);
            }
            finally
            {
                base.Cursor = Cursors.Arrow;
            }
        }