Пример #1
0
        private void InsertUpdateAccount()
        {
            dhAccount objInsert = new dhAccount();

            objInsert = (dhAccount)this.AccountDt.DataContext;



            dhAccountValidator validator = new dhAccountValidator();

            FluentValidation.Results.ValidationResult results = validator.Validate(objInsert);

            bool validationSucceeded           = results.IsValid;
            IList <ValidationFailure> failures = results.Errors;

            if (validationSucceeded)
            {
                if (this.vAccountType.SelectedValue != null)
                {
                    objInsert.IFinaceType = Convert.ToInt32(this.vAccountType.SelectedValue.ToString());
                }
                else
                {
                    throw new ApplicationException("Please Select Account Type.");
                }
                DataSet ds = iFacede.InsertUpdateAccount(Globalized.ObjDbName, objInsert);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (objInsert.IUpdate == 1)
                    {
                        string msg = "Account  '" + objInsert.AccountName + "' information is updated successfully.";
                        Globalized.setException(msg, lblErrorMsg, DataHolders.MsgType.Info);
                        //Globalized.SetMsg(msg, DataHolders.MsgType.Info);
                        //Globalized.ShowMsg(lblErrorMsg);
                    }
                    else
                    {
                        System.Media.SystemSounds.Beep.Play();
                        lblErrorMsg.Visibility = Visibility.Hidden;
                        Globalized.SetMsg("New Acount '" + objInsert.AccountName + "' is added successfully.", DataHolders.MsgType.Info);
                        objTodisplay.IUpdate = 1;
                        this.DataContext     = objTodisplay;
                        Globalized.ShowMsg(lblErrorMsg);
                    }
                }
                Globalized.AccountListOptimizated();
            }
            else
            {
                throw new ApplicationException(failures.First().ErrorMessage);
            }
        }
Пример #2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            dhUsers objUser = new dhUsers();

            try
            {
                if (String.IsNullOrEmpty(UserName.Text.Trim()))
                {
                    throw new ApplicationException("Please Enter User Name.");
                }
                if (String.IsNullOrEmpty(Password.Password.Trim()))
                {
                    throw new ApplicationException("Please Enter Password.");
                }
                objUser.VLogin    = UserName.Text.Trim();
                objUser.VPassword = Password.Password.Trim();
                objUser           = iFacede.Authentication(Globalized.ObjDbName, objUser);
                if (objUser.LoginStatus == true)
                {
                    LoadComponent();
                    if ((objUser.BIsActive != true) && (objUser.VUserType != "Super"))
                    {
                        throw new ApplicationException("Your account status is inactive, contact to administrator/ Support.");
                    }
                    // set the current user
                    Globalized.ObjCurrentUser = objUser;
                    // ModernWindow Obj = (ModernWindow)Application.Current.MainWindow;
                    dhPreference GlobalObjPreference      = new dhPreference();
                    dsGeneral.dtPosPreferenceDataTable dt = iFacede.GetPreference(Globalized.ObjDbName, GlobalObjPreference);
                    // intialize object
                    if (dt.Rows.Count > 0)
                    {
                        ObservableCollection <dhPreference> listItem = ReflectionUtility.DataTableToObservableCollection <dhPreference>(dt);
                        if (listItem.Count > 0)
                        {
                            GlobalObjPreference = listItem.Cast <dhPreference>().SingleOrDefault();
                        }
                    }
                    else
                    {
                        GlobalObjPreference = new dhPreference();
                    }
                    Globalized.ObjPrefernce = GlobalObjPreference;
                    //iFacede.GetUserMenu(Globalized.ObjDbName, Obj, objAppPreference, objUser);
                    myMenu = new SublimeMenu(Globalized.ObjCurrentUser);
                    if (myMenu.MenuItems.Count > 0)
                    {
                        this.ListViewMenu.ItemsSource = myMenu.MenuItems;
                        // this.SideMenu.ItemsSource = myMenu.MenuItems;
                        // this.SideMenu.Visibility = System.Windows.Visibility.Visible;
                        this.MainGrid.Visibility = System.Windows.Visibility.Hidden;
                        this.DocLogin.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        // this.SideMenu.Visibility = System.Windows.Visibility.Hidden;
                        this.MainGrid.Visibility = System.Windows.Visibility.Visible;
                        this.DocLogin.Visibility = Visibility.Hidden;
                    }
                    //Obj.ContentSource
                    Globalized.AccountListOptimizated();
                }
                else
                {
                    throw new ApplicationException("Invalid Username/Password");
                }
            }
            catch (Exception ex)
            {
                lblErrorMsg.Visibility = System.Windows.Visibility.Visible;
                lblErrorMsg.Foreground = Brushes.Red;
                lblErrorMsg.Content    = ex.Message;
            }
        }