Exemple #1
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"));
        }
Exemple #2
0
        public ActionResult Remind(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            Tenant model = TenantManager.GetByID(id);

            Email.EmailLease(model.TenantID, (int)Helpers.Helpers.EmailType.LeaseConfirmation);
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult Edit(int id)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Edit Lease Terms";

            Tenant tenant = TenantManager.GetByID(id);

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

            return(View(tenant));
        }
Exemple #4
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"));
        }
Exemple #5
0
        public ActionResult Operation(int id)
        {
            // add new user
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Tenant Operation";
            // Get the users from the DB for the drop-down listbox
            var allUsers = GetList((short)Helpers.Helpers.ListType.allUser);

            var allBankAccount = GetList((short)Helpers.Helpers.ListType.bankaccount);

            var allUnits = GetList((short)Helpers.Helpers.ListType.unit);

            Tenant model = TenantManager.GetByID(id);

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

            return(View(model));
        }
Exemple #6
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"));
        }