Esempio n. 1
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(TBRankNo.Text) <= RankID)
                {
                    if (TBRankDesc.Text != null && TBRankNo.Text != null)
                    {
                        //Apply Data To EmployeeRank
                        if (CBRankDesc.Visibility == Visibility.Hidden)
                        {
                            //set new rank
                            TBikeDAL MyDAL = new TBikeDAL();
                            MyDAL.AddNewEmployeeRank(TBRankDesc.Text, Convert.ToInt32(TBRankNo.Text), username);
                            var res = await this.ShowMessageAsync("ADD NEW", "Employee Rank " + TBRankDesc.Text + " Has Been Added.", MessageDialogStyle.AffirmativeAndNegative);
                        }
                        else
                        {
                            TBikeDAL MyDAL = new TBikeDAL();
                            MyDAL.UpdateEmployeeRank(CBRankDesc.SelectedValue.ToString().Trim(), TBRankDescModify.Text, Convert.ToInt32(TBRankNo.Text), username);
                            var res = await this.ShowMessageAsync("MODIFY", "Employee Rank " + TBRankDesc.Text + " Has Been Modified.", MessageDialogStyle.AffirmativeAndNegative);
                        }
                    }
                    else
                    {
                        var res = await this.ShowMessageAsync("Error", "Please Fill in all texts");
                    }
                }
                else
                {
                    var res = await this.ShowMessageAsync("Error", "Rank same or higher than self cannot be created!!");
                }

                //EmployeeRank ret = new EmployeeRank();
                //this.Close();
                //ret.PopulateDataFromLogin(username);
                //ret.Show();
            }
            catch (Exception ex)
            {
                var res = await this.ShowMessageAsync("Error", Convert.ToString(ex), MessageDialogStyle.AffirmativeAndNegative);
            }
        }