当前位置: 首页>>代码示例>>C#>>正文


C# finalContext.SaveChanges方法代码示例

本文整理汇总了C#中LoanManagement.Domain.finalContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# finalContext.SaveChanges方法的具体用法?C# finalContext.SaveChanges怎么用?C# finalContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LoanManagement.Domain.finalContext的用法示例。


在下文中一共展示了finalContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         using (var ctx = new finalContext())
         {
             var set = ctx.OnlineSettings.Find(1);
             lblVisitor.Text = set.Visitor.ToString();
         }
         lblTime.Text = DateTime.Now.ToString("MMM dd, yyyy | hh:mm tt");
         string tnum = Request.QueryString["id"];
         using (var ctx = new finalContext())
         {
             var clt = ctx.Clients.Where(x => x.TrackingNumber == tnum).First();
             if (clt.isRegistered == true)
             {
                 Response.Redirect("/Index.aspx");
             }
             else
             {
                 clt.isRegistered = true;
                 var exp = ctx.iClientExpirations.Find(clt.ClientID);
                 lblContent.Text = "Your currently registered account will be deleted if not confirmed on or before " + exp.ExpirationDate + "\n Please visit our office to confirm this account regarding the information. Thank You.";
                 Session["newID"] = null;
                 ctx.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         Response.Redirect("/Index.aspx");
     }
 }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:33,代码来源:Confirmation.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                lblTime.Text = DateTime.Now.ToString("MMM dd, yyyy | hh:mm tt");
                Session["Service"] = null;
                Session["UpdateChecker"] = null;
                Session["iService"] = null;

                if (Session["Visit"] == null)
                {
                    Session["Visit"] = "Visited";
                    using (var ctx = new finalContext())
                    {
                        var set = ctx.OnlineSettings.Find(1);
                        set.Visitor = set.Visitor + 1;
                        ctx.SaveChanges();
                    }

                }
                using (var ctx = new finalContext())
                {
                    var set = ctx.OnlineSettings.Find(1);
                    lblDesc.Text = set.HomeDescription.Replace("\n", "<br />"); ;
                    lblVisitor.Text = set.Visitor.ToString();
                }
            }
            catch (Exception)
            {
                Response.Redirect("/Index.aspx");
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:32,代码来源:Index.aspx.cs

示例3: btnContinue_Click

        private void btnContinue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MessageBoxResult mr = MessageBox.Show("Are you sure you want to proceed?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (mr == MessageBoxResult.Yes)
                {
                    if (rdDaif.IsChecked == true)
                    {
                        using (var ctx = new finalContext())
                        {
                            FPaymentInfo fp = ctx.FPaymentInfo.Find(fId);
                            ReturnedCheque rc = new ReturnedCheque { DateReturned = DateTime.Today.Date, Fee = DaifFee, FPaymentInfoID = fId, Remarks = "DAIF", isPaid = false };
                            fp.PaymentStatus = "Returned";
                            ctx.ReturnedCheques.Add(rc);

                            AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Processed returned cheque " + fp.ChequeInfo };
                            ctx.AuditTrails.Add(at);

                            ctx.SaveChanges();
                            MessageBox.Show("Okay", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            this.Close();
                        }
                    }
                    else
                    {
                        using (var ctx = new finalContext())
                        {
                            FPaymentInfo fp = ctx.FPaymentInfo.Find(fId);
                            ClosedAccount cc = new ClosedAccount { DateClosed = DateTime.Today.Date, Fee = ClosedFee, LoanID = fp.LoanID, isPaid = false };
                            //fp.PaymentStatus = "Returned";
                            fp.Loan.Status = "Closed Account";
                            ctx.ClosedAccounts.Add(cc);

                            var chq = from c in ctx.FPaymentInfo
                                      where c.PaymentStatus != "Cleared" && c.LoanID==fp.LoanID
                                      select c;

                            foreach (var item in chq)
                            {
                                item.PaymentStatus = "Void";
                            }
                            AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Processed returned cheque " + fp.ChequeInfo };
                            ctx.AuditTrails.Add(at);

                            ctx.SaveChanges();
                            MessageBox.Show("Transaction has been successfully processed", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:58,代码来源:wpfChequeReturning.xaml.cs

示例4: btnAdjust_Click

 private void btnAdjust_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (dtTo.SelectedDate.Value.Date < dtFrom.SelectedDate.Value.Date)
         {
             System.Windows.MessageBox.Show("TO date must be breater than or equal to FROM date", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         using (var ctx = new finalContext())
         {
             var py = from p in ctx.MPaymentInfoes
                      where (p.DueDate <= dtTo.SelectedDate.Value && p.DueDate >= dtFrom.SelectedDate.Value) && (p.PaymentStatus == "Unpaid" || p.PaymentStatus=="Pending")
                      select p;
             var ctr = ctx.MPaymentInfoes.Where(p=> (p.DueDate <= dtTo.SelectedDate.Value && p.DueDate >= dtFrom.SelectedDate.Value) && (p.PaymentStatus == "Unpaid" || p.PaymentStatus == "Pending")).Count();
             if (ctr > 0)
             {
                 var ps = ctx.MPaymentInfoes.Where(p=> (p.DueDate <= dtTo.SelectedDate.Value && p.DueDate >= dtFrom.SelectedDate.Value) && (p.PaymentStatus == "Unpaid" || p.PaymentStatus == "Pending")).First();
                 double rem = ps.RemainingLoanBalance;
                 foreach (var itm in py)
                 {
                     itm.TotalAmount = itm.Amount + itm.PreviousBalance;
                     itm.TotalBalance = itm.TotalBalance - itm.BalanceInterest;
                     itm.RemainingLoanBalance = rem;
                     //if (itm.BalanceInterest != 0)
                     //{
                     //itm.PreviousBalance = itm.PreviousBalance - itm.BalanceInterest;
                     //itm.TotalAmount = itm.Amount + itm.PreviousBalance;
                     //}
                     if (itm.PaymentStatus == "Unpaid")
                     {
                         itm.PaymentStatus = "Unpaid(No Interest)";
                     }
                 }
                 foreach (var itm in py)
                 {
                     itm.BalanceInterest = 0;
                 }
                 MicroAdjusment ma = new MicroAdjusment { ToDate = dtTo.SelectedDate.Value.Date, FromDate = dtFrom.SelectedDate.Value.Date, ReasonOfAdjustment = txtReason.Text };
                 ctx.MicroAdjusments.Add(ma);
                 ctx.SaveChanges();
                 System.Windows.MessageBox.Show("Transaction has been  successfully processed", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
 }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:52,代码来源:wpfMAdjustment.xaml.cs

示例5: btnLogIn_Click

 private void btnLogIn_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new finalContext())
     {
         if (txtUsername.Text == "" || txtPassword.Password == "")
         {
             MessageBox.Show("Please input username/password");
             return;
         }
         var ctr = ctx.Users.Where(x => x.Username == txtUsername.Text).Count();
         if (ctr > 0)
         {
             var usr = ctx.Users.Where(x => x.Username == txtUsername.Text).First();
             if (usr.Employee.Position.PositionName != "Administrator")
             {
                 MessageBox.Show("Only the administrator is allowed to activate the system.");
                 return;
             }
             else
             {
                 var c = ctx.Users.Where(x => x.Username == txtUsername.Text && x.Password == txtPassword.Password).Count();
                 if (c > 0)
                 {
                     var st = ctx.State.Find(1);
                     st.iState = 0;
                     ctx.SaveChanges();
                     MessageBox.Show("System has been successfuly activated.");
                     wpfLogin frm = new wpfLogin();
                     frm.ShowDialog();
                     this.Close();
                 }
             }
         }
         else
         {
             MessageBox.Show("Incorrect admin information.");
             return;
         }
     }
 }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:40,代码来源:wpfActivate.xaml.cs

示例6: btnRecord_Click

        private void btnRecord_Click(object sender, RoutedEventArgs e)
        {
            double amt = 0;
            try
            {
                amt = Convert.ToDouble(txtAmt.Text);
                amt = Convert.ToDouble(amt.ToString("N2"));
            }
            catch (Exception)
            {
                amt = 0;
            }
            if (amt > Convert.ToDouble(lblTotalLoan.Content))
            {
                System.Windows.MessageBox.Show("Amount must not be greater that the remaining amount", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (amt < 1)
            {
                System.Windows.MessageBox.Show("Amount must be greater that 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            int lID;
            try
            {
                lID = Convert.ToInt32(txtID.Text);
            }
            catch (Exception)
            {
                lID = 0;
            }

            using (var ctx = new finalContext())
            {
                CollectionInfo ci = new CollectionInfo { LoanID = lID, DateCollected = DateTime.Today.Date, TotalCollection = amt };
                var r = ctx.PassedToCollectors.Find(lID);
                double rBal = Convert.ToDouble((r.RemainingBalance - amt).ToString("N2"));
                r.RemainingBalance = rBal;
                ctx.CollectionInfoes.Add(ci);

                if (rBal <= 0)
                {
                    System.Windows.MessageBox.Show("The Loan has been successfully finished!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    var lon = ctx.Loans.Find(lID);
                    lon.Status = "Paid";
                    r.RemainingBalance = 0;
                    PaidLoan pl = new PaidLoan { LoanID = lID, DateFinished = DateTime.Today.Date };
                    ctx.PaidLoans.Add(pl);
                }

                ctx.SaveChanges();
                txtID.Text = "";
                txtID.Focus();
            }

        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:56,代码来源:wpfCPayments.xaml.cs

示例7: btnSave_Click

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //try
            //{
                if (lblName.Content == "?" || lblDesc.Content == "?"
                    || String.IsNullOrWhiteSpace(txtName.Text)|| dt.SelectedDate.Value == null)
                {
                    System.Windows.MessageBox.Show("Please input correct format and/or fill all required fields", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                if (status == "Add")
                {
                    using (var ctx = new finalContext())
                    {
                        //if (isYearly.IsChecked == true)
                        //{
                            var mC = ctx.MPaymentInfoes.Where(x => x.DueDate.Month == dt.SelectedDate.Value.Month && x.DueDate.Day == dt.SelectedDate.Value.Day).Count();
                            if (mC > 0)
                            {
                                System.Windows.MessageBox.Show("Payments on the given day will be automatically adjusted", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                                var ps = from x in ctx.MPaymentInfoes
                                         select x;

                                DateTime idt1 = dt.SelectedDate.Value;
                                DateTime idt = DateAndTime.DateAdd(DateInterval.Day, 1, idt1);

                                bool isHoliday = true;
                                while (isHoliday == true || idt.Date.DayOfWeek.ToString() == "Saturday" || idt.Date.DayOfWeek.ToString() == "Sunday")
                                {
                                    if (idt.Date.DayOfWeek.ToString() == "Saturday")
                                    {
                                        idt = DateAndTime.DateAdd(DateInterval.Day, 2, idt);
                                    }
                                    else if (idt.Date.DayOfWeek.ToString() == "Sunday")
                                    {
                                        idt = DateAndTime.DateAdd(DateInterval.Day, 1, idt);
                                    }
                                    var myC = ctx.Holidays.Where(x => x.Date.Month == idt.Date.Month && x.Date.Day == idt.Date.Day && x.isYearly == true).Count();
                                    if (myC > 0)
                                    {
                                        idt = DateAndTime.DateAdd(DateInterval.Day, 1, idt);
                                        isHoliday = true;
                                    }
                                    else
                                    {
                                        myC = ctx.Holidays.Where(x => x.Date.Month == idt.Date.Month && x.Date.Day == idt.Date.Day && x.Date.Year == idt.Date.Year && x.isYearly == !true).Count();
                                        if (myC > 0)
                                        {
                                            idt = DateAndTime.DateAdd(DateInterval.Day, 1, idt);
                                            isHoliday = true;
                                        }
                                        else
                                        {
                                            isHoliday = false;
                                        }
                                    }
                                }
                                foreach (var x in ps)
                                {
                                    if (isYearly.IsChecked == true)
                                    {
                                        if (x.DueDate.Month == idt1.Date.Month && x.DueDate.Day == idt1.Date.Day)
                                        {
                                            x.DueDate = idt;
                                        }
                                    }
                                    else
                                    {
                                        if (x.DueDate.Month == idt1.Date.Month && x.DueDate.Day == idt1.Date.Day && x.DueDate.Year == idt1.Date.Year)
                                        {
                                            x.DueDate = idt;
                                        }
                                    }
                                }
                            }
                       // }


                        var num = ctx.Holidays.Where(x => x.HolidayName == txtName.Text).Count();
                        if (num > 0)
                        {
                            System.Windows.MessageBox.Show("Holiday already exists", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }

                        num = ctx.Holidays.Where(x => x.Date == dt.SelectedDate.Value).Count();
                        if (num > 0)
                        {
                            System.Windows.MessageBox.Show("Holiday already exists", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }

                        Holiday h = new Holiday { HolidayName = txtName.Text, Date = dt.SelectedDate.Value, isYearly = Convert.ToBoolean(isYearly.IsChecked), Description = txtDesc.Text };

                        AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Added Holiday " + txtName.Text };
                        ctx.AuditTrails.Add(at);

                        ctx.Holidays.Add(h);
                        ctx.SaveChanges();
//.........这里部分代码省略.........
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:101,代码来源:wpfHolidayInfo.xaml.cs

示例8: btnAlert_Click

 protected void btnAlert_Click(object sender, EventArgs e)
 {
     try
     {
         using (var ctx = new finalContext())
         {
             int n = Convert.ToInt32(Session["ID"]);
             var lon = ctx.TemporaryLoanApplications.Where(x => x.ClientID == n).First();
             ctx.TemporaryLoanApplications.Remove(lon);
             ctx.SaveChanges();
             string myStringVariable = "Loan application has been successfuly cancelled";
             ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
         }
     }
     catch (Exception)
     {
         Response.Redirect("/Index.aspx");
     }
 }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:19,代码来源:MyAccount_Loans.aspx.cs

示例9: btnRegister_Click1


//.........这里部分代码省略.........
                DateTime bDay = Convert.ToDateTime(txtBirthday.Text);

                using (var ctx = new finalContext())
                {
                    var ctr = ctx.Clients.Where(x => x.FirstName == txtFirstName.Text && x.LastName == txtLastName.Text && x.MiddleName == txtMiddleName.Text && x.Suffix == txtSuffix.Text && x.Birthday == bDay).Count();
                    if (ctr > 0)
                    {
                        lblExists.Visible = true;
                        return;
                    }
                    else
                    {

                        string age = "0";
                        int years = DateTime.Now.Year - bDay.Year;
                        if (bDay.AddYears(years) > DateTime.Now) ;
                        years--;

                        age = years.ToString();
                        int iAge = Convert.ToInt32(age);
                        if (iAge < 18 || iAge > 65)
                        {
                            lblExists.Text = "Age must be between 18 an 65";
                            lblExists.Visible = true;
                            return;
                        }
                        if (txtPassword.Text != txtConfirm.Text)
                        {
                            lblExists.Text = "Passwords didn't match";
                            lblExists.Visible = true;
                            return;
                        }

                        if (txtPassword.Text.Length < 8)
                        {
                            lblExists.Text = "Password length must be at least 8";
                            lblExists.Visible = true;
                            return;
                        }

                        if (txtUsername.Text.Length < 8)
                        {
                            lblExists.Text = "Username length must be at least 8";
                            lblExists.Visible = true;
                            return;
                        }

                        if(txtBirthday.Text == "" || txtEmail.Text == "" || txtFirstName.Text == "" || txtLastName.Text == "" || txtUsername.Text == "")
                        {
                            lblExists.Text = "Please input all required fields";
                            lblExists.Visible = true;
                            return;
                        }

                        var c = ctx.Clients.Where(x => x.Username == txtUsername.Text).Count();
                        if (c > 0)
                        {
                            lblExists.Text = "Username has been already used";
                            lblExists.Visible = true;
                            return;
                        }

                        c = ctx.Clients.Where(x => x.Email == txtEmail.Text).Count();
                        if (c > 0)
                        {
                            lblExists.Text = "Email has been already used";
                            lblExists.Visible = true;
                            return;
                        }
                        var result = "asd";
                        do
                        {
                            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                            var random = new Random();
                            result = new string(
                                Enumerable.Repeat(chars, 15)
                                          .Select(s => s[random.Next(s.Length)])
                                          .ToArray());
                            c = ctx.Clients.Where(x => x.TrackingNumber == result).Count();
                        } while (c > 0);
                        Client clt = new Client { Active = true, Birthday = bDay, Email = txtEmail.Text, FirstName = txtFirstName.Text, isConfirmed = false, LastName = txtLastName.Text, MiddleName = txtMiddleName.Text, Password = txtPassword.Text, Sex = cmbGender.Text, SSS = txtSSS.Text, Username = txtUsername.Text, Status = cmbStatus.Text, Suffix = txtSuffix.Text, TIN = txtTIN.Text, isRegistered = false, TrackingNumber = result };
                        ClientContact con = new ClientContact { ContactNumber = 1, Primary = true, Contact = txtContact.Text };
                        iClientExpiration exp = new iClientExpiration { ExpirationDate = DateTime.Now.AddMonths(1) };

                        ctx.Clients.Add(clt);
                        ctx.ClientContacts.Add(con);
                        ctx.iClientExpirations.Add(exp);
                        ctx.SaveChanges();
                        Session["newID"] = clt.ClientID.ToString();
                        Response.Redirect("/RegistrationSuccess.aspx");

                    }
                }
            }
            catch (Exception)
            {
                //Response.Redirect("/Index.aspx");
            }
            
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:101,代码来源:RegisterClient.aspx.cs

示例10: btnRelease_Click

        private void btnRelease_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (status == "Releasing")
                {
                    double max = 0;
                    double min = 0;
                    using (var ctx = new finalContext())
                    {
                        var lon = ctx.Loans.Find(lId);
                        var ser = ctx.Services.Find(lon.ServiceID);
                        max = ser.MaxTerm;
                        min = ser.MinTerm;


                        if (Convert.ToDouble(txtTerm.Text) > max || Convert.ToDouble(txtTerm.Text) < min)
                        {
                            System.Windows.MessageBox.Show("Term must not be greater than the maximum term(" + ser.MaxTerm + " mo.) OR less than the minimum term(" + ser.MinTerm + " mo.)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        max = ser.MaxValue;
                        min = ser.MinValue;

                        if (Convert.ToDouble(txtAmt.Text) > max || Convert.ToDouble(txtAmt.Text) < min)
                        {
                            System.Windows.MessageBox.Show("Principal amount must not be greater than the maximum loanable amount OR less than the minimum loanable amount", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                    }

                    if (Convert.ToDouble(txtAmt.Text) > Convert.ToDouble(lblPrincipal.Content))
                    {
                        MessageBox.Show("Principal amount must not be greater than the maximum loanable amount", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if(ciId == 0)
                    {
                        MessageBox.Show("Please assign a collector for this loan", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    MessageBoxResult mr = MessageBox.Show("Are you sure you want to process this transaction?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (mr == MessageBoxResult.Yes)
                    {
                        using (var ctx = new finalContext())
                        {
                            int bId = 0;
                            var lon = ctx.Loans.Find(lId);
                            lon.Status = "Released";
                            lon.Mode = cmbMode.Text;
                            lon.Term = Convert.ToInt32(txtTerm.Text);
                            lon.CollectortID = ciId;
                            var cn = ctx.Services.Find(lon.ServiceID);
                            double co = cn.AgentCommission / 100;
                            double cm = Convert.ToDouble(txtAmt.Text) * co;
                            //MessageBox.Show(cm.ToString());
                            ReleasedLoan rl = new ReleasedLoan { AgentsCommission = cm, DateReleased = DateTime.Today.Date, LoanID = lId, MonthlyPayment = Convert.ToDouble(lblMonthly.Content), NetProceed = Convert.ToDouble(lblProceed.Content), Principal = Convert.ToDouble(txtAmt.Text), TotalLoan = Convert.ToDouble(lblInt.Content) };
                            lon.ReleasedLoan = rl;
                            var lo = ctx.GenSOA.Where(x => x.PaymentNumber == 1).First();
                            int y = 0;
                            MPaymentInfo py = new MPaymentInfo { Amount = Convert.ToDouble(lo.Amount), BalanceInterest = 0, DueDate = lo.PaymentDate, LoanID = lId, PaymentNumber = 1, PaymentStatus = "Pending", PreviousBalance = 0, RemainingLoanBalance = Convert.ToDouble(lo.RemainingBalance), TotalAmount = Convert.ToDouble(lo.Amount), TotalBalance = 0 };
                            ctx.MPaymentInfoes.Add(py);
                            AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Released loan (" + lon.Service.Name + ") for client " + lon.Client.FirstName + " " + lon.Client.MiddleName + " " + lon.Client.LastName + " " + lon.Client.Suffix };
                            ctx.AuditTrails.Add(at);
                            ctx.SaveChanges();
                            printSOA();
                            MessageBox.Show("Transaction has been successfully processed", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            this.Close();
                        }
                    }
                }
                else if (status == "UReleasing")
                {
                    
                    using (var ctx = new finalContext())
                    {
                        var lon = ctx.Loans.Find(lId);
                        lon.CollectortID = ciId;

                        AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Updated Released loan (" + lon.Service.Name + ") for client " + lon.Client.FirstName + " " + lon.Client.MiddleName + " " + lon.Client.LastName + " " + lon.Client.Suffix };
                        ctx.AuditTrails.Add(at);
                        ctx.SaveChanges();
                        MessageBox.Show("Transaction has been successfully updated", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Incorrect Format on some Fields / Incomplete Input(s)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:96,代码来源:wpfMReleasing.xaml.cs

示例11: checkDue


//.........这里部分代码省略.........
                                }
                                var myC = ctx.Holidays.Where(x => x.Date.Month == dt.Date.Month && x.Date.Day == dt.Date.Day && x.isYearly == true).Count();
                                if (myC > 0)
                                {
                                    dt = DateAndTime.DateAdd(DateInterval.Day, 1, dt);
                                    isHoliday = true;
                                }
                                else
                                {
                                    myC = ctx.Holidays.Where(x => x.Date.Month == dt.Date.Month && x.Date.Day == dt.Date.Day && x.Date.Year == dt.Date.Year && x.isYearly == !true).Count();
                                    if (myC > 0)
                                    {
                                        dt = DateAndTime.DateAdd(DateInterval.Day, 1, dt);
                                        isHoliday = true;
                                    }
                                    else
                                    {
                                        isHoliday = false;
                                    }
                                }
                            }

                            String str = "";

                            double tRate = ctRate;
                            str = tRate.ToString("N2");
                            tRate = Convert.ToDouble(str);
                            //System.Windows.MessageBox.Show(tRate.ToString());

                            double tBalance = ctBalance + tRate;
                            str = tBalance.ToString("N2");
                            tBalance = Convert.ToDouble(str);

                            double tAmount = itm.Amount + tBalance;
                            str = tAmount.ToString("N2");
                            tAmount = Convert.ToDouble(str);

                            ctBalance = tAmount;
                            ctRate = ctBalance * ciRate;



                            double tRem = cRem + tRate;
                            str = tRem.ToString("N2");
                            tRem = Convert.ToDouble(str);

                            cRem = tRem;

                            dt2 = DateAndTime.DateAdd(dInt, Interval, dt);
                            String st = "Unpaid";
                            if (dt2 > DateTime.Today.Date)
                                st = "Pending";
                            MPaymentInfo mpi = null;
                            if (tAmount <= tRem)
                            {
                                mpi = new MPaymentInfo { PaymentNumber = n + 1, Amount = itm.Amount, TotalBalance = tBalance, BalanceInterest = tRate, DueDate = dt, ExcessBalance = 0, LoanID = itm.LoanID, PaymentStatus = st, TotalAmount = tAmount, RemainingLoanBalance = tRem, PreviousBalance = iAmt };
                                ctx.MPaymentInfoes.Add(mpi);
                            }
                            else
                            {
                                if (itm.PaymentStatus == "Unpaid")
                                {
                                    double tPaid = 0;
                                    var m1 = from m in ctx.MPaymentInfoes
                                             where m.LoanID == itm.LoanID && m.PaymentStatus == "Paid"
                                             select m;
                                    foreach (var i in m1)
                                    {
                                        tPaid = tPaid + i.TotalPayment;
                                    }
                                    var c = ctx.PassedToCollectors.Where(x => x.LoanID == itm.LoanID).Count();
                                    if (c < 1)
                                    {
                                        using (var ctx2 = new finalContext())
                                        {
                                            PassedToCollector pc = new PassedToCollector { DatePassed = DateTime.Today.Date, LoanID = itm.LoanID, RemainingBalance = tRem, TotalPassedBalance = tRem, TotalPaidBeforePassing = tPaid };
                                            var l1 = ctx2.Loans.Find(itm.LoanID);
                                            l1.Status = "Under Collection";
                                            ctx2.PassedToCollectors.Add(pc);
                                            ctx2.SaveChanges();
                                        }
                                    }
                                }
                            }
                            iAmt = tAmount;
                            n++;
                        }

                    }


                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:101,代码来源:wpfReleasedLoanInfo.xaml.cs

示例12: btnSave_Click

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtPosition.Text == "Administrator")
                {
                    System.Windows.MessageBox.Show("Administrator cannot be used as position name", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }


                if (status == "Add")
                {
                    using (var ctx = new finalContext())
                    {
                        var ctr = ctx.Positions.Where(x => x.PositionName == txtPosition.Text).Count();
                        if (ctr > 0)
                        {
                            System.Windows.MessageBox.Show("Position already exists.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                        Domain.Position pos = new Domain.Position { PositionName = txtPosition.Text, Description = txtDesc.Text };
                        PositionScope scp = new PositionScope { MAgent = false, MClient = false, MHoliday = false, MBank = false, MEmployee = false, MPosition = false, MRegistration = false, MService = false, TApplication = false, TApproval = false, TCollection = false, TManageClosed = false, TOnlineConfirmation = false, TPaymentAdjustment = false, TPayments = false, TReleasing = false, TResturcture = false, UArchive = false, UBackUp = false, UOnlineSettings = false, UReports = false, UScopes = false, UStatistics = false, UUserAccounts = false };
                        ctx.Positions.Add(pos);


                        AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Added new Position " + txtPosition.Text };
                        ctx.AuditTrails.Add(at);

                        ctx.SaveChanges();
                        scp.PositionID = pos.PositionID;
                        ctx.PositionScopes.Add(scp);
                        ctx.SaveChanges();
                        System.Windows.MessageBox.Show("Record has been successfully added", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                }
                else
                {
                    using (var ctx = new finalContext())
                    {
                        Domain.Position pos = ctx.Positions.Find(pID);
                        pos.PositionName = txtPosition.Text;
                        pos.Description = txtDesc.Text;
                        AuditTrail at = new AuditTrail { EmployeeID = UserID, DateAndTime = DateTime.Now, Action = "Updated Position " + txtPosition.Text };
                        ctx.AuditTrails.Add(at);
                        ctx.SaveChanges();
                        System.Windows.MessageBox.Show("Record has been successfully updated", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:58,代码来源:wpfPositionInfo.xaml.cs

示例13: btnContinue_Click

        private void btnContinue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtCat.Text == "Non Collateral")
                {
                    using (var ctx = new finalContext())
                    {
                        var ictr = ctx.Loans.Where(x => x.ClientID == cId && x.Status == "Released" && x.Service.Type == "Non Collateral" && x.Service.Department == iDept).Count();
                        if (ictr > 0)
                        {
                            System.Windows.MessageBox.Show("Client has an existing Non-Collateral loan. The client can only apply for collateral loan.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                    }
                    if (string.IsNullOrWhiteSpace(txtID.Text))
                    {
                        System.Windows.MessageBox.Show("Client Must have co-borrower", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                }
                if (cmbServices.Text == "" || cmbMode.Text == "" || txtAmt.Text == "" || txtTerm.Text == "")
                {
                    System.Windows.MessageBox.Show("Please complete the required information", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                if (cboxAgent.IsChecked == true && txtAgent.Text == "")
                {
                    System.Windows.MessageBox.Show("Please select the agent");
                    return;
                }

                using (var ctx = new finalContext())
                {
                    var ser = ctx.Services.Find(servId);
                    if (ser.Type == "Non Collateral" && txtID.Text == "")
                    {
                        System.Windows.MessageBox.Show("Please select the Co-Borrower", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                    double val = Convert.ToDouble(txtAmt.Text);
                    if (val > ser.MaxValue || val < ser.MinValue)
                    {
                        System.Windows.MessageBox.Show("Invalid loan ammount", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                    var lon = ctx.Loans.Find(lId);
                    if (status == "Renewal")
                    {
                        if (val < lon.ReleasedLoan.TotalLoan)
                        {
                            System.Windows.MessageBox.Show("Amount must be greater than or equal the Total Loan Amount of Previous loan(" + lon.ReleasedLoan.TotalLoan.ToString("N2") + ")", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                    }
                    val = Convert.ToDouble(txtTerm.Text);
                    if (val > ser.MaxTerm || val < ser.MinTerm)
                    {
                        System.Windows.MessageBox.Show("Invalid desired term", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }

                }


                using (var ctx = new finalContext())
                {
                    var ser = ctx.Services.Find(servId);
                    double deduction = 0;
                    var ded = from de in ctx.Deductions
                              where de.ServiceID == servId
                              select de;
                    foreach (var item in ded)
                    {
                        deduction = deduction + item.Percentage;
                    }
                    deduction = deduction + ser.AgentCommission;
                    if (ser.Type == "Collateral")
                    {
                        cbId = 0;
                    }

                    if (status == "Add" || status == "Confirmation" || status=="Renewal")
                    {
                        if (status == "Confirmation")
                        {
                            Loan loan = new Loan { };

                            LoanApplication la = new LoanApplication { AmountApplied = Convert.ToDouble(txtAmt.Text), DateApplied = DateTime.Now.Date };
                            if (cboxAgent.IsChecked == true)
                            {
                                loan = new Loan { CI = ciId, AgentID = agentId, ClientID = cId, CoBorrower = cbId, ServiceID = servId, Status = "Applied", Term = Convert.ToInt32(txtTerm.Text), LoanApplication = la, Mode = cmbMode.Text, ApplicationType = "Online" };
                            }
                            else
                            {
                                string str = "Applied";
                                loan = new Loan { CI = ciId, AgentID = 0, ClientID = cId, CoBorrower = cbId, ServiceID = servId, Status = str, Term = Convert.ToInt32(txtTerm.Text), LoanApplication = la, Mode = cmbMode.Text , ApplicationType = "Online"};
                            }
                            ctx.Loans.Add(loan);
                            ctx.SaveChanges();
//.........这里部分代码省略.........
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:101,代码来源:wpfLoanApplication.xaml.cs

示例14: btnRecord_Click


//.........这里部分代码省略.........
                        double total = Convert.ToDouble((totalBal + py.Amount).ToString("N2"));
                        double re = Convert.ToDouble(lblTotalLoan.Content);
                        double rem = Convert.ToDouble((re - payment).ToString("N2"));

                        if (rem < total)
                        {
                            rem = 0;
                            total = totalBal;
                        }

                        py.TotalPayment = amt;
                        py.PaymentDate = DateTime.Now.Date;
                        py.PaymentStatus = "Paid";

                        int n = py.PaymentNumber + 1;

                        
                        if ((amt == Convert.ToDouble(lblTotal.Content) && rem <= py.Amount) || rem < 0)
                        {
                            System.Windows.MessageBox.Show("The Loan has been successfully finished!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            var lon = ctx.Loans.Find(lID);
                            lon.Status = "Paid";
                            py.TotalPayment = amt;
                            py.PaymentDate = DateTime.Now.Date;
                            py.PaymentStatus = "Paid";
                            py.RemainingLoanBalance = 0;
                            PaidLoan pl = new PaidLoan { LoanID = lID, DateFinished = DateTime.Today.Date };
                            ctx.PaidLoans.Add(pl);
                            goto here;
                        }
                        MPaymentInfo mp = new MPaymentInfo { Amount = py.Amount, BalanceInterest = balInt, DueDate = dt, ExcessBalance = 0, LoanID = lID, PaymentNumber = n, PaymentStatus = "Pending", PreviousBalance = pbal, RemainingLoanBalance = rem, TotalAmount = total, TotalBalance = totalBal };
                        ctx.MPaymentInfoes.Add(mp);
                    here:
                        ctx.SaveChanges();
                        
                        txtID.Text = "";
                        txtID.Focus();

                    }
                }
                else
                {
                    using (var ctx = new finalContext())
                    {
                        int lID = Convert.ToInt32(txtID.Text);
                        var py = ctx.MPaymentInfoes.Where(x => x.LoanID == lID && x.PaymentStatus == "Pending").First();
                        DateInterval dInt = new DateInterval();

                        double ex = amt - py.TotalAmount;

                        while (ex > 0)
                        {

                            int Interval = 0;

                            String value = py.Loan.Mode;
                            if (value == "Semi-Monthly")
                            {
                                Interval = 15;
                                dInt = DateInterval.Day;
                            }
                            else if (value == "Weekly")
                            {
                                Interval = 7;
                                dInt = DateInterval.Day;
                            }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:67,代码来源:wpfMPayment.xaml.cs

示例15: btnDecline_Click

        private void btnDecline_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (status == "Approval" || status == "Renewal Approval")
                {
                    wpfLoanDeclining frm = new wpfLoanDeclining();
                    frm.lId = lId;
                    frm.status = "Renewal";
                    if (status == "Approval")
                        frm.status = status;
                    frm.UserID = UserID;
                    this.Close();
                    frm.ShowDialog();
                }
                else if (status == "UApproval")
                {
                    System.Windows.MessageBoxResult mr = System.Windows.MessageBox.Show("Are you sure you want to update this loan?", "Question", MessageBoxButton.YesNo);
                    if (mr == System.Windows.MessageBoxResult.Yes)
                    {
                        using (var ctx = new finalContext())
                        {
                            var lon = ctx.Loans.Find(lId);
                            var ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && (x.Status == "Applied" || x.Status == "Released" || x.Status == "Approved") && x.LoanID != lon.LoanID).Count();
                            if (lon.Status == "Declined")
                            {
                                if (ctr > 0)
                                {
                                    System.Windows.MessageBox.Show("Client cannot have more than one(1) Loan application/Loan", "Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                    return;
                                }

                                ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && (x.Status == "Closed Account" || x.Status == "Under Collection")).Count();
                                if (ctr > 0)
                                {
                                    System.Windows.MessageBox.Show("Client has bad record due to Closed Account/Unpaid Balance. Unable to process loan.", "Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                                    return;
                                }

                                ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && x.Status == "Released" && x.Service.Department != lon.Service.Department).Count();
                                if (ctr > 0)
                                {
                                    System.Windows.MessageBox.Show("Client has an existing loan on other department", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                    return;
                                }

                                ctr = ctx.TemporaryLoanApplications.Where(x => x.ClientID == lon.ClientID).Count();
                                if (ctr > 0)
                                {
                                    System.Windows.MessageBox.Show("Client cannot have another application while having an online application. Please confirm the loan first", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                    return;
                                }

                                var c = ctx.Loans.Where(x => (x.Status == "Applied" || x.Status == "Approved" ||
                                x.Status == "Released" || x.Status == "Under Collection" || x.Status == "Closed Account") && (x.CoBorrower == lon.ClientID)).Count();
                                if (c > 0)
                                {
                                    System.Windows.MessageBox.Show("Selected Client cannot become a co-borrower since it has an existing loan taht is not yet finished", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                    return;
                                }
                            }

                            if (lon.Status == "Approved")
                            {
                                ctx.ApprovedLoans.Remove(lon.ApprovedLoan);
                            }
                            else
                            {
                                ctx.DeclinedLoans.Remove(lon.DeclinedLoan);
                            }
                            lon.Status = "Applied";
                            ctx.SaveChanges();
                            System.Windows.MessageBox.Show("Transaction has been voided","Information",MessageBoxButton.OK,MessageBoxImage.Information);
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
开发者ID:stisf-g1,项目名称:LoanManagement,代码行数:84,代码来源:wpfAppliedLoanInfo.xaml.cs


注:本文中的LoanManagement.Domain.finalContext.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。