Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientNumber"></param>
 /// <returns></returns>
 public LoanStruct?getLoanInfoByClientNumber(string clientNumber)
 {
     try
     {
         Dl         dataLayer = new Dl();
         DataTable  loanTable = dataLayer.fillLoanInfoByClientNum(clientNumber);
         LoanStruct result    = new LoanStruct();
         if (loanTable.Rows.Count != 0)
         {
             result.loanNumber        = (int?)loanTable.Rows[0]["Loan.ID"];
             result.installmentAmount = (decimal)loanTable.Rows[0]["Installment_Amount"];
             result.loanStatus        = int.Parse(loanTable.Rows[0]["Loan_status"].ToString());
             result.grantDate         = (DateTime)loanTable.Rows[0]["Grant_Date"];
             result.amount            = (decimal)loanTable.Rows[0]["Loan_amount"];
             return(result);
         }
         return(null);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// اعطای وام
        /// </summary>
        /// <param name="clientNumber">شماره مشتری</param>
        /// <param name="grantDate">تاریخ اعطای تسهیلات</param>
        /// <param name="longTime">زمان تسهیلات</param>
        /// <param name="loanAmount">مبلغ تسهیلات</param>
        /// <param name="clientid"></param>
        /// <param name="calcFlag"></param>
        /// <returns></returns>
        public LoanStruct grantLoan(string clientNumber, DateTime grantDate, int longTime, Decimal loanAmount, int clientid, bool calcFlag)
        {
            loanResualt.clientNumber = clientNumber;
            loanResualt.clientId     = clientid;
            loanResualt.grantDate    = grantDate;
            loanResualt.amount       = loanAmount;
            loanResualt.longTimeLoan = longTime;
            loanResualt.expDate      = loanResualt.grantDate.AddMonths(loanResualt.longTimeLoan);
            calcInstallmentAmount();
            loanResualt.installmentFirstDate = loanResualt.grantDate.AddMonths(1);

            //            decimal installmentAmount = amountLoan / timeLoan;
            //            _lblinstallmentAmount.Text = installmentAmount.ToString("0,0.00");
            InstallmentTableStruct installmentRow = new InstallmentTableStruct();

            installmentRow.installmentNumber = 1;
            installmentRow.installmentAmount = loanResualt.installmentFirstAmount;
            installmentRow.dueDate           = loanResualt.installmentFirstDate;
            installmentRow.installmentStatus = 0;
            loanResualt.installmentTable     = new List <InstallmentTableStruct>();
            loanResualt.installmentTable.Add(installmentRow);
            for (int i = 1; i < longTime; i++)
            {
                InstallmentTableStruct installmentRow1 = new InstallmentTableStruct();
                installmentRow1.installmentNumber = i + 1;
                installmentRow1.installmentAmount = loanResualt.installmentAmount;
                installmentRow1.dueDate           = loanResualt.installmentFirstDate.AddMonths(i);
                installmentRow1.installmentStatus = 0;
                loanResualt.installmentTable.Add(installmentRow1);
            }
            if (!calcFlag)
            {
                Dl dataLayer = new Dl();
                loanResualt.loanNumber = dataLayer.insertLoan(loanResualt);
            }
            return(loanResualt);
        }
Esempio n. 3
0
        public Boolean startOverNight(DateTime nowDate)
        {
            Dl        dataClass = new Dl();
            DataTable loanList  = dataClass.fillLoanListForOverNighte(nowDate);

            try
            {
                foreach (DataRow loanRow in loanList.Rows)
                {
                    #region connection
                    OleDbConnection conn;
                    try
                    {
                        conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.10.0;Data Source=" + dataClass.dbPathm);
                        conn.Open();
                    }
                    catch
                    {
                        try
                        {
                            conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dataClass.dbPathm);
                            conn.Open();
                        }
                        catch
                        {
                            try
                            {
                                conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.14.0;Data Source=" + dataClass.dbPathm);
                                conn.Open();
                            }
                            catch
                            {
                                conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.15.0;Data Source=" + dataClass.dbPathm);
                                conn.Open();
                            }
                        }
                    }
                    #endregion
                    var transaction = conn.BeginTransaction();
                    try
                    {
                        DataTable installmenList =
                            dataClass.fillInstallmentForOverNighte(int.Parse(loanRow["id"].ToString()), nowDate);
                        foreach (DataRow installmenRow in installmenList.Rows)
                        {
                            int installmentStatus;
                            //Todo: add Too parametter Table
                            int longTimeDueDate = 1;
                            if ((DateTime.Parse(installmenRow["DUE_DATE"].ToString()).AddMonths(longTimeDueDate)) > nowDate)
                            {
                                installmentStatus = (int)Loan.InstallmentStatus.DueDate;
                            }
                            else
                            {
                                installmentStatus = (int)Loan.InstallmentStatus.PassDue;
                            }
                            string strSqlInstallmen =
                                "UPDATE InstallmentTable SET InstallmentTable.Installment_Status = " + installmentStatus + " WHERE (((InstallmentTable.id)=" +
                                int.Parse(installmenRow["id"].ToString()) + "))";
                            OleDbDataAdapter oledbAdapterInstallmentTable = new OleDbDataAdapter();
                            oledbAdapterInstallmentTable.InsertCommand = new OleDbCommand(strSqlInstallmen, conn, transaction);
                            oledbAdapterInstallmentTable.InsertCommand.ExecuteNonQuery();
                        }
                        string strSqlLoan;
                        if (installmenList.Rows.Count != 0)
                        {
                            strSqlLoan = "UPDATE Loan SET Loan.Loan_status =" + (int)Loan.LoanStatus.PassDue +
                                         ", Loan.calc_date = '" + nowDate + "' WHERE (((Loan.ID)=" +
                                         loanRow["id"] + " ))";
                        }
                        else
                        {
                            strSqlLoan = "UPDATE Loan SET Loan.calc_date = '" + nowDate + "' WHERE (((Loan.ID)=" +
                                         loanRow["id"] + " ))";
                        }
                        OleDbDataAdapter oledbAdapterLoanTable = new OleDbDataAdapter();
                        oledbAdapterLoanTable.InsertCommand = new OleDbCommand(strSqlLoan, conn, transaction);
                        oledbAdapterLoanTable.InsertCommand.ExecuteNonQuery();
                        transaction.Commit();
                        conn.Close();
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        conn.Close();
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                throw;
            }
        }