コード例 #1
0
        public static LastLoanGeneralInfo  GetLoanDetails(LastLoanGeneralInfo loan)
        {
            var       loanIdCommand = string.Format("SELECT  sUM(Receipt.Amount) AS SumAmount, MAX(Receipt.ReceiptDate) AS MaxReceipt FROM Receipt where LoanId = {0}", loan.LoanId);
            string    dataBase      = Helper.GetConnectionString();
            DataTable dataTable     = new DataTable();

            try
            {
                using (OleDbConnection connection = new OleDbConnection(dataBase))
                {
                    OleDbCommand selectCommand = new OleDbCommand(loanIdCommand, connection);
                    connection.Open();
                    using (OleDbDataReader reader = selectCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            loan.LastPayment   = Transform.ConvertFromDBVal <string>(reader["MaxReceipt"]);
                            loan.PaymentAmount = Convert.ToInt32(Transform.ConvertFromDBVal <double>(reader["SumAmount"]));
                        }
                    }
                    connection.Close();
                }
                return(loan);
            }
            catch (Exception x)
            {
                var s = x.Message;
                return(null);
            }
        }
コード例 #2
0
        public static PersonelGeneralInfo GetPersonelGeneralInfo(Personel personel, ref string message)
        {
            var personelGeneralInfo = new PersonelGeneralInfo(personel);
            var loanIdCommand       = string.Format("SELECT  * FROM Loan where personelId ={0} and  expired<>true", personel.Id);

            try
            {
                string    dataBase  = Helper.GetConnectionString();
                DataTable dataTable = new DataTable();
                using (OleDbConnection connection = new OleDbConnection(dataBase))
                {
                    OleDbCommand selectCommand = new OleDbCommand(loanIdCommand, connection);
                    connection.Open();
                    using (OleDbDataReader reader = selectCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            personelGeneralInfo.LoanId          = (int)reader["Id"];
                            personelGeneralInfo.LoanReceiptDate = (string)reader["ReceiptDate"];
                            personelGeneralInfo.LoanAmount      = (Int32)reader["Amount"];
                        }
                    }
                    connection.Close();
                }
                if (personelGeneralInfo.LoanId >= 0)
                {
                    //get sabeghe pardakht
                    var lastLoan = new LastLoanGeneralInfo(personelGeneralInfo.LoanId, personelGeneralInfo.LoanAmount);

                    lastLoan = GetLoanDetails(lastLoan);
                    personelGeneralInfo.LoanDebtAmount = lastLoan.DebtAmount.ToString();
                    if (!string.IsNullOrEmpty(lastLoan.LastPayment))
                    {
                        personelGeneralInfo.LasPayment = lastLoan.LastPayment.ToString();
                    }
                }

                return(personelGeneralInfo);
            }
            catch (Exception ex)
            {
                message = ex.ToString();
                return(null);
            }
        }