Beispiel #1
0
        public ActionResult Transfer(int id)
        {
            try
            {
                if (Session["UserName"] == null)
                {
                    return(RedirectToAction("Index", "Account"));
                }
                ViewBag.ReportTitle = "Transfer Fund To Landlord";

                OperationRecord model = OperationRecordManager.GetExpenseByRentID(id);
                model = OperationRecordManager.GetExpenseByID(model.ID);

                model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount);
                model.AllTenant      = GetSelectListItems((short)Helpers.Helpers.ListType.allTenantWithUnit);
                model.AllCategory    = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory);
                model.AllStatus      = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus);

                return(View(model));
            }
            catch (Exception ex)
            {
                LogException(ex.Message);
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult IncomeDetailReport(string categoryName)
        {
            DateTime startDate = DateTime.Parse((string)Session["startDate"]);
            DateTime endDate   = DateTime.Parse((string)Session["endDate"]);

            string[] companyIDs           = (Session["selectedCompanyIDs"] != null)? (string[])Session["selectedCompanyIDs"]:null;
            string[] propertyIDs          = (Session["selectedPropertyIDs"] != null) ? (string[])Session["selectedPropertyIDs"] : null;
            string[] unitIDs              = (Session["selectedUnitIDs"] != null) ? (string[])Session["selectedUnitIDs"] : null;
            string[] bankAccountIDs       = (Session["selectedAccountIDs"] != null) ? (string[])Session["selectedAccountIDs"] : null;
            string[] statusIDs            = (Session["selectedStatusIDs"] != null) ? (string[])Session["selectedStatusIDs"] : null;
            string[] contractorIDs        = (Session["selectedContractorIDs"] != null) ? (string[])Session["selectedContractorIDs"] : null;
            string[] categoryIDs          = (Session["selectedCategoryIDs"] != null) ? (string[])Session["selectedCategoryIDs"] : null;
            List <OperationRecord> result = OperationRecordManager.GetExpense(startDate.ToString(), endDate.ToString(), companyIDs, propertyIDs, unitIDs, bankAccountIDs, statusIDs, contractorIDs, categoryIDs, "", (int)Session["UserID"]);

            result = (from r in result
                      where r.CategoryName == categoryName
                      select r).ToList();
            bool isStartNull = startDate.Equals(DateTime.MinValue);
            bool isEndNull   = endDate.Equals(DateTime.MinValue);

            ViewBag.TableCaption = reporttitle + " Expense: ";
            if (!startDate.Equals(DateTime.MinValue))
            {
                ViewBag.TableCaption += " fromt " + startDate.ToString("g");
            }
            if (!endDate.Equals(DateTime.MinValue))
            {
                ViewBag.TableCaption += " thru " + endDate.ToString("g");
            }

            return(View("IncomeDetailReport", result));
        }
Beispiel #3
0
        public ActionResult Transfer(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            if (String.IsNullOrEmpty(model.TransferedFinancialBankAccountID))
            {
                return(ExecutionError("Please select either Tenant or Unit"));
            }
            model.UploadBy = Int32.Parse(Session["UserID"].ToString());
            Tenant tenant = TenantManager.GetByID(model.TenantID);

            model.ContractorID = tenant.UserID;
            model.UnitID       = tenant.UnitId;
            OperationRecordManager.Reimburse(model);

            //send email to end user
            if (model.IsEmailReceipt)
            {
                Email.EmailPayment(model.ID, model.ContractorID, model.UnitID, model.CompleteDate, model.FinancialBankAccountID, model.DueAmount, model.Payment, (int)Helpers.Helpers.EmailType.Invoice);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public PartialViewResult ReportView(string startDate, string endDate, string[] companyIDs, string[] propertyIDs, string[] unitIDs, string[] bankAccountIDs, string[] statusIDs, string[] contractorIDs, string[] categoryIDs, string expense)
        {
            Session["startDate"]             = startDate;
            Session["endDate"]               = endDate;
            Session["selectedCompanyIDs"]    = companyIDs;
            Session["selectedPropertyIDs"]   = propertyIDs;
            Session["selectedUnitIDs"]       = unitIDs;
            Session["selectedAccountIDs"]    = bankAccountIDs;
            Session["selectedStatusIDs"]     = statusIDs;
            Session["selectedContractorIDs"] = contractorIDs;
            Session["selectedCategoryIDs"]   = categoryIDs;
            Session["expenseValue"]          = expense;
            DateTime start = DateTime.Parse(startDate);
            DateTime end   = DateTime.Parse(endDate);

            List <OperationRecord> result = OperationRecordManager.GetExpense(startDate, endDate, companyIDs, propertyIDs, unitIDs, bankAccountIDs, statusIDs, contractorIDs, categoryIDs, expense, (int)Session["UserID"]);
            bool isStartNull = start.Equals(DateTime.MinValue);
            bool isEndNull   = end.Equals(DateTime.MinValue);

            ViewBag.TableCaption = reporttitle + " Expense: ";
            if (!start.Equals(DateTime.MinValue))
            {
                ViewBag.TableCaption += " fromt " + start.ToString("g");
            }
            if (!end.Equals(DateTime.MinValue))
            {
                ViewBag.TableCaption += " thru " + end.ToString("g");
            }

            ViewBag.TotalPayment = 0;
            ViewBag.TotalDeposit = 0;
            ViewBag.TotalBalace  = 0;
            return(PartialView("ReportView", result));
        }
Beispiel #5
0
 public ActionResult Delete(int id)
 {
     // Enable security to redirect to login page if user is not logged in or we are not running in the VS IDE
     if (Session["UserName"] == null)
     {
         return(RedirectToAction("Index", "Account"));
     }
     OperationRecordManager.Delete(id);
     return(RedirectToAction("Index"));
 }
Beispiel #6
0
        public ActionResult Remind(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            var record = OperationRecordManager.GetExpenseByID(id);

            Email.EmailInvoice(record.ID);
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult AddAndTransferFund(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Transfer Fund To Other Bank";

            OperationRecordManager.AddAndTransferFund(model);
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public ActionResult Edit(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Edit Bank Record";

            OperationRecordManager.Edit(model);
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
        public ActionResult Remind(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            var record = OperationRecordManager.GetExpenseByRentID(id);

            Email.EmailReminder(record.ID, record.ContractorID, record.UnitID, record.DueDate, record.DueAmount, (int)Helpers.Helpers.EmailType.RentReminder);
            return(RedirectToAction("Index"));
        }
Beispiel #10
0
        public ActionResult Add(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add new bank record";

            int invoiceID = OperationRecordManager.CreateOperationRecord(model);

            return(RedirectToAction("Index"));
        }
        public PartialViewResult DetailTableView(string tableid, string startdate, string enddate, string userID, string companyID)
        {
            string[] userIds = new string[1];
            userIds[0] = userID;
            string[] companyIDs = new string[1];
            companyIDs[0] = companyID;
            List <OperationRecord> result = OperationRecordManager.GetExpense(startdate, enddate, companyIDs, null, null, null, null, userIds, null, "", (int)Session ["UserID"]);


            ViewBag.tableid = tableid;
            return(PartialView("DetailTableView", result));
        }
Beispiel #12
0
        public ActionResult ReceiveRent(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }

            model.IsCredit = true;
            model.UploadBy = Int32.Parse(Session["UserID"].ToString());
            OperationRecordManager.ReceiveRent(model);

            //redirect
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
        public ActionResult Edit(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Edit Expense";
            if (String.IsNullOrEmpty(model.FinancialBankAccountID))
            {
                model.FinancialBankAccountID = "0";
            }
            OperationRecordManager.Edit(model);

            //send email to end user

            return(RedirectToAction("Index"));
        }
Beispiel #14
0
        public ActionResult Reimburse(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Reimburse Expense";

            OperationRecord model = OperationRecordManager.GetExpenseByID(id);

            model.AllUnits       = GetSelectListItems((short)Helpers.Helpers.ListType.unit);
            model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount);
            model.AllTenant      = GetSelectListItems((short)Helpers.Helpers.ListType.allUser);
            model.AllStatus      = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus);
            model.AllCategory    = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory);

            return(View(model));
        }
Beispiel #15
0
        public ActionResult Add(OperationRecord model, string actionName)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add new supply request";
            model.StatusID      = 3;
            model.UploadBy      = (int)Session["UserID"];
            model.CategoryID    = 18;

            SqlConnection  sqlConn        = new SqlConnection(ConfigurationManager.ConnectionStrings["SunriseConnectionString"].ConnectionString);
            SqlCommand     cmd            = sqlConn.CreateCommand();
            DataTable      dtSearchResult = new DataTable();
            SqlDataAdapter daSearchResult = new SqlDataAdapter();

            try
            {
                sqlConn.Open();
                if (model.CompleteDate == null)
                {
                    model.CompleteDate = model.DueDate;
                }
                int invoiceID = 0;
                foreach (int unitID in model.SelectedUnitIDs)
                {
                    model.UnitID = unitID;
                    invoiceID    = OperationRecordManager.CreateOperationRecord(model);
                }
                if (model.IsEmailReceipt)
                {
                    Email.EmailInvoice(invoiceID);
                }
            }
            catch (Exception ex)
            {
                LogException(ex.Message);
            }
            finally
            {
                sqlConn.Close();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #16
0
        public ActionResult Edit(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            OperationRecord oldOp = OperationRecordManager.GetExpenseByRentID(Int32.Parse(model.LinkedRentID));

            ViewBag.ReportTitle = "Edit Rent Record";
            model.UploadBy      = Int32.Parse(Session["UserID"].ToString());
            model.ID            = oldOp.ID;
            //the tenantid is stored in the contractorid
            Tenant tenant = TenantManager.GetByID(model.TenantID);

            model.ContractorID = tenant.UserID;
            model.UnitID       = tenant.UnitId;
            OperationRecordManager.EditRent(model);

            return(RedirectToAction("Index"));
        }
Beispiel #17
0
        public ActionResult ReceiveRent(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Receive Rent";

            OperationRecord model = OperationRecordManager.GetExpenseByRentID(id);

            model.CompleteDate   = DateTime.Now;
            model.UploadBy       = Int32.Parse(Session["UserID"].ToString());
            model.StatusID       = (int)Helpers.Helpers.StatusType.Close;
            model.AllUnits       = GetSelectListItems((short)Helpers.Helpers.ListType.unit);
            model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount);
            model.AllTenant      = GetSelectListItems((short)Helpers.Helpers.ListType.allUser);
            model.AllStatus      = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus);

            return(View(model));
        }
Beispiel #18
0
        public ActionResult Edit(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Edit Rent";

            var model = OperationRecordManager.GetExpenseByRentID(id);

            if (model.CategoryID == (int)Helpers.Helpers.EmailType.SecurityDeposit)
            {
                model.IsSecurityDeposit = true;
            }
            //stored the tenant id in the contractorid
            model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount);
            model.AllTenant      = GetSelectListItems((short)Helpers.Helpers.ListType.allTenantWithUnit);
            model.AllStatus      = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus);

            return(View(model));
        }
Beispiel #19
0
        public ActionResult Add(Tenant model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add Tenant Record";

            SqlConnection  sqlConn        = new SqlConnection(Helpers.Helpers.GetAppConnectionString());
            SqlCommand     cmd            = sqlConn.CreateCommand();
            DataTable      dtSearchResult = new DataTable();
            SqlDataAdapter daSearchResult = new SqlDataAdapter();

            model.StatusID = (int)Helpers.Helpers.StatusType.Open;

            try
            {
                sqlConn.Open();
                int DepositStatusID = (int)Helpers.Helpers.StatusType.Open;
                if (model.SecurityDeposit == model.PaidSecurityDeposit)
                {
                    DepositStatusID = (int)Helpers.Helpers.StatusType.Close;
                }
                if (model.SecurityDepositPaidDate == null)
                {
                    model.SecurityDepositPaidDate = DateTime.Now;
                }

                //add record of the tenant
                cmd.CommandText = "INSERT INTO  tblTenant (UserID, UnitID,  leaseterm,StartDate, monthlypayment,securitydeposit, StatusID, Note) VALUES ( "
                                  + model.UserID + "," + model.UnitId + "," + model.LeaseTerm + ",'" + model.StartDate.ToShortDateString() + "'," + model.MonthlyPayment + "," + model.SecurityDeposit + "," + model.StatusID + ",'" + model.Note + "'); SELECT SCOPE_IDENTITY();";
                int tenantID = int.Parse(cmd.ExecuteScalar().ToString());


                //add record of the security deposit payment
                cmd.CommandText = "INSERT INTO  tblRent (TenantID, RentAmount, PaidAmount, DueDate, IsRent, Note, StatusID, PaymentDate, FinancialAccountID) VALUES ( "
                                  + tenantID + "," + model.SecurityDeposit + "," + model.PaidSecurityDeposit + ",'" + model.StartDate.ToShortDateString() + "', 0 ,'" + model.Note + "'," + DepositStatusID + ",'" + model.SecurityDepositPaidDate.ToShortDateString() + "'," + model.FinancialBankAccountID + "); SELECT SCOPE_IDENTITY();";

                int             rentid    = int.Parse(cmd.ExecuteScalar().ToString());
                OperationRecord operation = new OperationRecord();
                operation.StatusID               = (short)DepositStatusID;
                operation.CategoryID             = (int)Helpers.Helpers.ExpenseCategory.SecurityDeposit;
                operation.IsCredit               = true;
                operation.ContractorID           = model.UserID;
                operation.UnitID                 = model.UnitId;
                operation.DueDate                = model.StartDate;
                operation.DueAmount              = model.SecurityDeposit;
                operation.Payment                = model.PaidSecurityDeposit;
                operation.Memo                   = model.Note;
                operation.LinkedRentID           = rentid.ToString();
                operation.CompleteDate           = model.SecurityDepositPaidDate;
                operation.FinancialBankAccountID = model.FinancialBankAccountID;
                operation.UploadBy               = (int)Session["UserID"];
                int opID = OperationRecordManager.CreateOperationRecord(operation);

                Email.EmailLease(tenantID, (int)Helpers.Helpers.EmailType.LeaseConfirmation);


                sqlConn.Close();
            }
            catch (SqlException ex)
            {
                ViewBag.MyExeption    = ex.Message;
                ViewBag.MyExeptionCSS = "errorMessage";
            }
            finally
            {
                sqlConn.Close();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #20
0
        public ActionResult Add(OperationRecord model, string actionName)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add Rent";

            SqlConnection  sqlConn        = new SqlConnection(ConfigurationManager.ConnectionStrings["SunriseConnectionString"].ConnectionString);
            SqlCommand     cmd            = sqlConn.CreateCommand();
            DataTable      dtSearchResult = new DataTable();
            SqlDataAdapter daSearchResult = new SqlDataAdapter();

            try
            {
                sqlConn.Open();
                if (string.IsNullOrEmpty(model.RentMonth))
                {
                    if (model.TenantID <= 0)
                    {
                        return(ExecutionError("Please select Tenant"));
                    }

                    //the tenant id was stored in the contractorid
                    Tenant tenant = TenantManager.GetByID(model.TenantID);

                    int isRent = 1;
                    if (model.IsSecurityDeposit)
                    {
                        model.CategoryID = 32;
                        isRent           = 0;
                    }
                    else
                    {
                        model.CategoryID = 36;
                    }
                    if (!model.IsCredit)
                    {
                        model.Payment = -model.Payment;
                    }
                    model.StatusID = (int)Helpers.Helpers.StatusType.Open;
                    if (model.DueAmount == model.Payment || model.DueAmount == 0)
                    {
                        model.StatusID = (int)Helpers.Helpers.StatusType.Close;
                    }
                    if (model.CompleteDate == null)
                    {
                        model.CompleteDate = model.DueDate;
                    }
                    model.ContractorID = tenant.UserID;
                    model.UnitID       = tenant.UnitId;
                    model.LinkedRentID = OperationRecordManager.CreateRent(model, tenant.TenantID).ToString();

                    model.ID = OperationRecordManager.CreateOperationRecord(model);

                    if (model.IsEmailReceipt)
                    {
                        Email.EmailPayment(model.ID, model.ContractorID, model.UnitID, model.CompleteDate, model.FinancialBankAccountID, model.DueAmount, model.Payment, model.CategoryID);
                    }
                }
                sqlConn.Close();
            }
            catch (SqlException ex)
            {
                ViewBag.MyExeption    = ex.Message;
                ViewBag.MyExeptionCSS = "errorMessage";
            }
            finally
            {
                sqlConn.Close();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #21
0
        public ActionResult AddMonthlyRent(OperationRecord model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add Rent";

            SqlConnection  sqlConn        = new SqlConnection(ConfigurationManager.ConnectionStrings["SunriseConnectionString"].ConnectionString);
            SqlCommand     cmd            = sqlConn.CreateCommand();
            DataTable      dtSearchResult = new DataTable();
            SqlDataAdapter daSearchResult = new SqlDataAdapter();

            try
            {
                sqlConn.Open();
                //create monthly rents
                cmd.CommandText = "Select [tblTenant].UserID, [tblTenant].MonthlyPayment, tblPropertyUnit.UnitID, [tblTenant].TenantID from [tblTenant], tblPropertyUnit, mCompanyProperty WHERE tblTenant.StartDate <'" + DateTime.Now + "' and tblTenant.TerminateDate is null and statusid=1 "
                                  + " and tblTenant.UnitID = tblPropertyUnit.UnitID and tblPropertyUnit.PropertyID = mCompanyProperty.PropertyID AND tblTenant.StatusID= 1 and mCompanyProperty.CompanyID in " + GetUserManagedCompanyString();

                daSearchResult.SelectCommand = cmd;
                daSearchResult.Fill(dtSearchResult);
                Int16   tenantID   = 0;
                Int16   userid     = 0;
                Int16   unitID     = 0;
                Decimal rentAmount = 0;

                //loop through all tenant to create rent record for this month
                foreach (DataRow row in dtSearchResult.Rows)
                {
                    if (row[0] != DBNull.Value)
                    {
                        userid             = Int16.Parse(row[0].ToString());
                        model.ContractorID = userid;
                    }
                    if (row[1] != DBNull.Value)
                    {
                        model.DueAmount = Double.Parse(row[1].ToString());
                    }
                    if (row[2] != DBNull.Value)
                    {
                        model.UnitID = Int16.Parse(row[2].ToString());
                    }
                    if (row[3] != DBNull.Value)
                    {
                        tenantID = Int16.Parse(row[3].ToString());
                    }
                    model.CategoryID             = (int)Helpers.Helpers.ExpenseCategory.Rent;
                    model.Memo                   = "auto generated rent for " + model.DueDate.ToShortDateString();
                    model.FinancialBankAccountID = "11";
                    model.StatusID               = (int)Helpers.Helpers.StatusType.Open;
                    model.LinkedRentID           = OperationRecordManager.CreateRent(model, tenantID).ToString();

                    OperationRecordManager.CreateOperationRecord(model);
                }
                sqlConn.Close();
            }
            catch (SqlException ex)
            {
                ViewBag.MyExeption    = ex.Message;
                ViewBag.MyExeptionCSS = "errorMessage";
            }
            finally
            {
                sqlConn.Close();
            }
            return(RedirectToAction("Index"));
        }