Beispiel #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                splashScreenManager1.ShowWaitForm();
                splashScreenManager1.SetWaitFormCaption("请稍等....");
                splashScreenManager1.SetWaitFormDescription("正在验证用户信息");
                //SplashScreenManager.ShowForm(typeof (SplashScreen1));
                StaticInfoHelper.IsOpen = 1;
                if (txtUserName.Text.Trim() == string.Empty)
                {
                    MessageBox.Show(@"账号不能为空!");
                    txtUserName.Focus();
                    return;
                }

                if (txtPassword.Text.Trim() == string.Empty)
                {
                    MessageBox.Show(@"密码不能为空!");
                    txtPassword.Focus();
                    return;
                }

                Bse_UserDAL dal = new Bse_UserDAL();
                DataTable   dt  =
                    dal.GetList("Number='" + txtUserName.Text.Trim() + "' and Password='******' ").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    UserInfoHelper.CreateUserId = dt.Rows[0]["User_Id"].ToString();
                    UserInfoHelper.UserName     = dt.Rows[0]["UserName"].ToString();
                    UserInfoHelper.CreateName   = dt.Rows[0]["Realname"].ToString();
                    UserInfoHelper.Number       = dt.Rows[0]["Number"].ToString();
                    UserInfoHelper.Password     = dt.Rows[0]["Password"].ToString();
                    UserInfoHelper.Dept_Id      = dt.Rows[0]["Dept_Id"].ToString();
                    UserInfoHelper.Company_Id   = dt.Rows[0]["Company_Id"].ToString();
                    UserInfoHelper.CompanyName  = dt.Rows[0]["CompanyName"].ToString();
                    UserInfoHelper.DeptName     = dt.Rows[0]["DeptName"].ToString();
                    UserInfoHelper.Bloc_Id      = dt.Rows[0]["Bloc_Id"].ToString();
                    UserInfoHelper.BlocName     = dt.Rows[0]["BlocName"].ToString();
                    UserInfoHelper.SystemId     = dt.Rows[0]["SystemId"].ToString();
                    DialogResult = DialogResult.OK;

                    //异步加载窗体
                    Bse_MenuDALExtend menus   = new Bse_MenuDALExtend();
                    DataSet           dsMenus = menus.GetMenusRibbon();
                    GlobalHelp.DataSetMenus = dsMenus;
                    bckWorker.RunWorkerAsync(dsMenus);
                }
                else
                {
                    MessageDxUtilHelper.ShowTips("用户名或者密码错误,登录失败!");
                    txtPassword.SelectAll();
                }
            }
            finally
            {
                splashScreenManager1.CloseWaitForm();
            }
        }
Beispiel #2
0
        private void DoSave()
        {
            var dataRowView = TreeListMain.GetDataRecordByNode(TreeListMain.FocusedNode) as DataRowView;

            if (dataRowView != null)
            {
                DataRow dr = dataRowView.Row;
                if (dr == null)
                {
                    return;
                }

                if (CheckSave(this.layoutControl1, CtrlSaveArray, CtrlSaveArrayTxt) == false)
                {
                    return;
                }

                btnSave.Enabled = false;
                bool blChgState = false;

                try
                {
                    if (dr["Organize_Id"].ToString() == string.Empty || _organizeId == "-1")
                    {
                        if (organizeDal.GetList("  Number='" + txtNumber.Text + "'  and SystemId=" + _systemId + " ").Tables[0].Rows.Count > 0)
                        {
                            MessageBox.Show(@"输入的编码已经存在");
                            btnSave.Enabled = true;
                            return;
                        }
                        Bse_Organize organize = new Bse_Organize();
                        organize.Name         = txtName.Text.Trim();
                        organize.Number       = txtNumber.Text.Trim();
                        organize.Sort         = int.Parse(txtSort.Text.Trim());
                        organize.Category     = lueCategory.EditValue.ToString();
                        organize.OuterPhone   = txtOuterPhone.Text.Trim();
                        organize.InnerPhone   = txtInnerPhone.Text.Trim();
                        organize.Address      = txtAddress.Text.Trim();
                        organize.Remark       = txtRemark.Text.Trim();
                        organize.CreateName   = txtCreateUserId.Text.Trim();
                        organize.CreateUserId = int.Parse(UserInfoHelper.CreateUserId);
                        organize.Dept_Id      = int.Parse(UserInfoHelper.Dept_Id);
                        organize.SystemId     = int.Parse(UserInfoHelper.SystemId);
                        organize.Bloc_Id      = int.Parse(UserInfoHelper.Bloc_Id);
                        organize.Company_Id   = int.Parse(UserInfoHelper.Company_Id);
                        organize.Layer        = int.Parse(dr["Layer"].ToString());
                        organize.ParentId     = int.Parse(dr["ParentId"].ToString());
                        organize.State        = 1;
                        int flag = organizeDal.Add(organize);
                        if (flag > 0)
                        {
                            MessageDxUtilHelper.ShowWarning("操作成功");
                            //DataRow drNew = ds.Tables[0].Rows[0];
                            dr["Organize_Id"] = flag;
                        }
                        btnSave.Enabled = true;
                    }
                    else
                    {
                        if (organizeDal.GetList("Organize_Id!=" + _organizeId + " and Number='" + txtNumber.Text + "' ").Tables[0].Rows.Count > 0)
                        {
                            MessageBox.Show(@"输入的编码已经存在");
                            btnSave.Enabled = true;
                            return;
                        }

                        List <Bse_Organize> roleModel = ModelHandler <Bse_Organize> .FillModel(organizeDal.GetList("Organize_Id=" + _organizeId + "").Tables[0]);

                        Bse_Organize organize = roleModel[0];
                        organize.Organize_Id  = int.Parse(_organizeId);
                        organize.Name         = txtName.Text.Trim();
                        organize.Number       = txtNumber.Text.Trim();
                        organize.Sort         = int.Parse(txtSort.Text.Trim());
                        organize.Category     = lueCategory.EditValue.ToString();
                        organize.OuterPhone   = txtOuterPhone.Text.Trim();
                        organize.InnerPhone   = txtInnerPhone.Text.Trim();
                        organize.Address      = txtAddress.Text.Trim();
                        organize.Remark       = txtRemark.Text.Trim();
                        organize.CreateName   = txtCreateUserId.Text.Trim();
                        organize.CreateUserId = int.Parse(UserInfoHelper.CreateUserId);
                        organize.Dept_Id      = int.Parse(UserInfoHelper.Dept_Id);
                        organize.SystemId     = int.Parse(UserInfoHelper.SystemId);
                        organize.Bloc_Id      = int.Parse(UserInfoHelper.Bloc_Id);
                        organize.Company_Id   = int.Parse(UserInfoHelper.Company_Id);
                        organize.Layer        = int.Parse(dr["Layer"].ToString());
                        organize.ParentId     = int.Parse(dr["ParentId"].ToString());
                        bool flag = organizeDal.Update(organize);
                        EntityCovert.SetDataRowByEntity <Bse_Organize>(dr, organize);
                        //dr["Number"] = organize.Number;
                        if (flag)
                        {
                            MessageDxUtilHelper.ShowWarning("操作成功");
                            if (dr.Table.Columns.Contains("State") && dr["State"].ToString() != dr["State", DataRowVersion.Original].ToString())
                            {
                                blChgState = true;
                            }
                        }
                        btnSave.Enabled = true;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                dr.AcceptChanges();
                SetMode("VIEW");
                if (blChgState)
                {
                    SetFocRowstyleFormat(dr);
                }
            }
        }