Esempio n. 1
0
 private void AddItem_Click(object sender, RoutedEventArgs e)
 {
     totPrice = Convert.ToInt64(SinglePrice.Text.ToString());
     quan     = Convert.ToInt32(Quantity.Text);
     totPrice = quan * totPrice;
     if (edir.Capital >= totPrice)
     {
         item.Name          = ItName.Text.Trim();
         item.PurchasedDate = Convert.ToDateTime(PurchasedDate.Text.ToString());
         item.DamageFee     = Convert.ToDouble(DamageFee.Text);
         item.Quantity      = Convert.ToInt32(quan);
         item.DailyPayment  = Convert.ToDouble(DayPayment.Text);
         edir.Capital      -= totPrice;
         _context.Items.Add(item);
         _context.SaveChanges();
         _context.Entry(edir).State = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
         SucessMessage sm = new SucessMessage();
         sm.MessageText.Text = "Registered Successfully";
         sm.Show();
     }
     else
     {
         ErrorMessage er = new ErrorMessage();
         er.MessageText.Text = "No Balance For This Amount";
         er.Show();
     }
 }
Esempio n. 2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (Account.Password == PasswordBox.Password)
     {
         if (NewPass.Password == Confirm.Password)
         {
             Account.Password = NewPass.Password;
             _context.Entry(Account).State = System.Data.Entity.EntityState.Modified;
             _context.SaveChanges();
             SucessMessage sm = new SucessMessage();
             sm.MessageText.Text = "Password Changed";
             sm.Show();
         }
     }
 }
Esempio n. 3
0
        private void ReportBtn_Click(object sender, RoutedEventArgs e)
        {
            long   SelMemId  = Convert.ToInt64(MemId.Text);
            long   SelRuleId = 0;
            double First     = Edir.DefaultFirstFin;
            double Second    = Edir.DefaultSecondFin;
            double Debit     = 0;
            double Last      = Edir.DefaultFinalFin;

            if (!Fundamental.IsChecked.GetValueOrDefault())
            {
                var  SelectedRule = ViolatedRuleId.SelectedItem;
                Rule SelRule      = ((Rule)SelectedRule);
                SelRuleId = SelRule.Id;
                rule      = _context.Rules.FirstOrDefault(r => r.Id == SelRuleId);
                First     = Convert.ToDouble(rule.FirstFin);
                Second    = Convert.ToDouble(rule.SecondFin);
                Last      = Convert.ToDouble(rule.LastFin);
            }
            int PreRec = _context.Violations.Where(v => v.MemberId == SelMemId).Count();

            if (PreRec < 2)
            {
                Debit = First;
            }
            else if (PreRec < 3)
            {
                Debit = Second;
            }
            else if (PreRec > 3)
            {
                Debit = Last;
            }
            Member Mem = ((Member)_context.Members.FirstOrDefault(m => m.Id == SelMemId));

            Mem.Debit                += Debit;
            violation.Description     = Description.Text.ToLower();
            violation.MemberId        = SelMemId;
            violation.RuleId          = SelRuleId;
            violation.ReportDate      = DateTime.Now.Date;
            _context.Entry(Mem).State = System.Data.Entity.EntityState.Modified;
            _context.Violations.Add(violation);
            _context.SaveChanges();
            SucessMessage sm = new SucessMessage();

            sm.MessageText.Text = "Reported Successfully";
            sm.Show();
        }
Esempio n. 4
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            rule.Name                 = RuleName.Text.Trim();
            rule.Description          = Description.Text.ToString();
            rule.FirstFin             = Convert.ToDouble(FirstFin.Text);
            rule.SecondFin            = Convert.ToDouble(SecondFin.Text);
            rule.LastFin              = Convert.ToDouble(FinalFin.Text);
            rule.RuleRegistrationDate = DateTime.Now.Date;

            _context.Rules.Add(rule);
            _context.SaveChanges();
            SucessMessage sm = new SucessMessage();

            sm.MessageText.Text = "Registered Successfully";
            sm.Show();
        }
Esempio n. 5
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            Eve.Name  = EventName.Text.Trim();
            Eve.Place = EventPlace.Text.Trim();
            Eve.Fin   = Convert.ToDouble(EventFin.Text);
            Eve.date  = Convert.ToDateTime(EventDate.Text);
            //Eve.time = Convert.ToDateTime(EventTime.Text);
            Eve.Description = Description.Text.Trim();

            _context.EdirEvents.Add(Eve);
            _context.SaveChanges();
            SucessMessage sm = new SucessMessage();

            sm.MessageText.Text = "Registered Successfully";
            sm.Show();
        }
Esempio n. 6
0
        private void EditBtn_Click(object sender, RoutedEventArgs e)
        {
            Item Selected = ((Item)ItemGrid.SelectedItem);

            if (Selected != null)
            {
                Selected.Name                  = ItName.Text.Trim();
                Selected.PurchasedDate         = Convert.ToDateTime(PurchasedDate.Text);
                Selected.DamageFee             = Convert.ToDouble(DamageFee.Text);
                _context.Entry(Selected).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            SucessMessage sm = new SucessMessage();

            sm.MessageText.Text = "Updated Successfully";
            sm.Show();
        }
Esempio n. 7
0
        private void EditBtn_Click(object sender, RoutedEventArgs e)
        {
            Rule Selected = ((Rule)RulesGrid.SelectedItem);

            if (Selected != null)
            {
                Selected.Name        = RuleName.Text.Trim();
                Selected.Description = Description.Text.ToString();
                Selected.FirstFin    = Convert.ToDouble(FirstFin.Text);
                Selected.SecondFin   = Convert.ToDouble(SecondFin.Text);
                Selected.LastFin     = Convert.ToDouble(FinalFin.Text);

                _context.Entry(Selected).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
                SucessMessage sm = new SucessMessage();
                sm.MessageText.Text = "Updated Successfully";
                sm.Show();
            }
        }
Esempio n. 8
0
        private void EditBtn_Click(object sender, RoutedEventArgs e)
        {
            EdirEvent Selected = ((EdirEvent)EventGrid.SelectedItem);

            if (Selected != null)
            {
                Selected.Name        = EventName.Text.Trim();
                Selected.Place       = EventPlace.Text.Trim();
                Selected.Fin         = Convert.ToDouble(EventFin.Text);
                Selected.date        = Convert.ToDateTime(EventDate.Text);
                Selected.Description = Description.Text.Trim();

                _context.Entry(Selected).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
                SucessMessage sm = new SucessMessage();
                sm.MessageText.Text = "Updated Successfully";
                sm.Show();
            }
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (AccountRole == 2)
     {
         admins.RoleId           = Convert.ToInt64(RoleId.SelectedIndex);
         admins.Username         = Username.Text.Trim();
         admins.Password         = PasswordBox.ToString();
         admins.AdminUpgradeDate = DateTime.Now.Date;
         _context.UserAccounts.Add(admins);
         _context.SaveChanges();
         SucessMessage Sm = new SucessMessage();
         Sm.MessageText.Text = "Admin Added Successfully";
         Sm.Show();
     }
     else
     {
         ErrorMessage Sm = new ErrorMessage();
         Sm.MessageText.Text = "Access Denied";
         Sm.Show();
     }
 }
Esempio n. 10
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            Mem.FirstName  = MemName.Text.Trim();
            Mem.LastName   = MemLastName.Text.Trim();
            Mem.MotherName = MemMotherName.Text.Trim();
            Mem.SubCity    = Subcity.Text;

            if (GenderBtn.IsChecked.GetValueOrDefault())
            {
                Mem.Gender = "Female";
            }
            else
            {
                Mem.Gender = "Male";
            }
            if (MarriageStat.IsChecked.GetValueOrDefault())
            {
                Mem.MariageStatus = true;
            }
            else
            {
                Mem.MariageStatus = false;
            }
            SelectedSubcity = Subcity.SelectedIndex;

            if (SelectedSubcity == 0)
            {
                Mem.SubCity = "Arada";
            }
            else if (SelectedSubcity == 1)
            {
                Mem.SubCity = "Akaki/Kality";
            }
            else if (SelectedSubcity == 2)
            {
                Mem.SubCity = "Bole";
            }
            else if (SelectedSubcity == 3)
            {
                Mem.SubCity = "Kolfe Keraniyo";
            }
            else if (SelectedSubcity == 4)
            {
                Mem.SubCity = "Yeka";
            }
            else if (SelectedSubcity == 5)
            {
                Mem.SubCity = "Gulele";
            }
            else if (SelectedSubcity == 6)
            {
                Mem.SubCity = "Ledeta";
            }
            else if (SelectedSubcity == 7)
            {
                Mem.SubCity = "Nefas Silk";
            }
            else if (SelectedSubcity == 8)
            {
                Mem.SubCity = "Kirkos";
            }
            else if (SelectedSubcity == 9)
            {
                Mem.SubCity = "Addis Ketema";
            }

            Mem.Woreda         = Convert.ToInt64(Woreda.Text);
            Mem.Kebele         = Convert.ToInt64(Kebele.Text);
            Mem.HouseNummber   = HouseNum.Text.Trim();
            Mem.PhoneNumber    = Convert.ToInt64(Phone.Text);
            Mem.RegisteredDate = DateTime.Now.Date;

            _context.Members.Add(Mem);
            _context.SaveChanges();
            SucessMessage sm = new SucessMessage();

            sm.MessageText.Text = "Registered Successfully";
            sm.Show();
            Clear();
        }
Esempio n. 11
0
        private void ReturnBtn_Click(object sender, RoutedEventArgs e)
        {
            var    OneIte            = RetQuantity.SelectedItem;
            Rental OneRent           = ((Rental)OneIte);
            Item   OneItem           = OneRent.Item;
            int    RequestedQuantity = Convert.ToInt32(OneRent.Quantity);

            if (OneItem != null)
            {
                int Quantity = OneItem.RentedQuantity;
                Quantity -= RequestedQuantity;
                if (Quantity >= 0)
                {
                    OneItem.RentedQuantity        = Quantity;
                    OneRent.ReturnDate            = DateTime.Now.Date;
                    _context.Entry(OneRent).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    OneRent.Returned = true;
                    TimeSpan timespan   = OneRent.ReturnDate - OneRent.RentedDate;
                    double   daysRented = timespan.TotalDays;
                    double   RentMoney  = 0;
                    if (daysRented == 0)
                    {
                        RentMoney = (daysRented) * OneItem.DailyPayment;
                        if (Damaged.IsChecked.GetValueOrDefault())
                        {
                            damageFee = 0;
                            int type = DamageType.SelectedIndex;
                            if (type == 0)
                            {
                                damageFee = OneItem.SmallDamageFee;
                                DamagedGood damagedGood = new DamagedGood();
                                damagedGood.ItemId      = OneItem.Id;
                                damagedGood.RepairType  = "Slight damage";
                                damagedGood.Quantity    = RequestedQuantity;
                                damagedGood.Description = Description.Text.ToString();
                                _context.DamagedGoods.Add(damagedGood);
                                _context.SaveChanges();
                            }
                            else if (type == 1)
                            {
                                damageFee = OneItem.DamageFee;
                                DamagedGood damagedGood = new DamagedGood();
                                damagedGood.ItemId      = OneItem.Id;
                                damagedGood.RepairType  = "Moderate damage";
                                damagedGood.Quantity    = RequestedQuantity;
                                damagedGood.Description = Description.Text.ToString();
                                _context.DamagedGoods.Add(damagedGood);
                                _context.SaveChanges();
                            }
                            else if (type == 2)
                            {
                                DamagedGood damagedGood = new DamagedGood();
                                damagedGood.ItemId      = OneItem.Id;
                                damagedGood.RepairType  = "strong damage";
                                OneItem.Quantity       -= RequestedQuantity;
                                damagedGood.Quantity    = RequestedQuantity;
                                damagedGood.IsRepaired  = false;
                                damagedGood.Description = Description.Text.ToString();
                                _context.DamagedGoods.Add(damagedGood);
                                _context.SaveChanges();

                                _context.Entry(OneItem).State = System.Data.Entity.EntityState.Modified;
                                _context.SaveChanges();
                            }

                            RentMoney += damageFee;
                        }
                    }
                    else
                    {
                        RentMoney = 0;
                    }
                    _context.Entry(OneRent).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    _context.Entry(OneItem).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    SucessMessage sm = new SucessMessage();
                    sm.MessageText.Text = "Total Price: " + RentMoney;
                    sm.Show();
                }
                else
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Quantity unavailable";
                    er.Show();
                }
            }
        }