Beispiel #1
0
        public bool DeleteOwnerToTenant(DeleteOwnerToTenant deleteOwnerToTenant)
        {
            var selSql = "select * from contract where userId=" + deleteOwnerToTenant.Id;

            string[] sqlT = new string[2];
            int      i    = 0;

            sqlT[i++] = "update house set houseStatus = 'unactivated' where userId=" + deleteOwnerToTenant.Id;
            sqlT[i]   = "update user SET type = 'tenant' where id= " + deleteOwnerToTenant.Id;
            DataSet allContract = DataOperate.FindAll(selSql);

            if (allContract.Tables.Count == 1 && allContract.Tables[0].Rows.Count == 0)
            {
                DataOperate.Update(sqlT[i]);
                return(true);
            }
            else if (GetContractBool(allContract))
            {
                return(DataOperate.ExecTransaction(sqlT));
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public JsonResult GetHouseListToTable(GetHouseListToTable getHouseListToTable)
        {
            var     selSql1  = "select * from house ";
            DataSet allHouse = DataOperate.FindAll(selSql1);


            string[] signed = { "activated", "empty" };
            // 检查房主合同状态 修改房源状态
            foreach (DataRow row in allHouse.Tables[0].Rows)
            {
                if (signed.Contains(row["rentStatus"].ToString()))
                {
                    var     selSql2          = "select * from contract where type='withOwner' and contractStatus = 'undue' and houseId=" + row["id"].ToString();
                    DataSet allHouseContract = DataOperate.FindAll(selSql2);
                    if (allHouseContract.Tables.Count == 1 && allHouseContract.Tables[0].Rows.Count == 0)
                    {
                        DataOperate.Update("update house set rentStatus='invalid' where id=" + row["id"]);
                    }
                }
            }

            var countSql = "select count(*) from house";
            var sql      = "select * from house";

            if (getHouseListToTable.Status.Length > 0)
            {
                countSql += " where rentStatus in ('" + string.Join("','", getHouseListToTable.Status) + "')";
                sql      += " where rentStatus in ('" + string.Join("','", getHouseListToTable.Status) + "')";
            }

            sql += " order by id desc limit " + (getHouseListToTable.PageNum - 1) * getHouseListToTable.PageSize + "," + getHouseListToTable.PageSize;

            return(Success(new { totalCount = DataOperate.Sele(countSql), data = DataOperate.FindAll(sql) }));
        }
Beispiel #3
0
        public JsonResult PassHouseCommission(PassHouseCommission passHouseCommission)
        {
            var sql = "UPDATE house SET rentStatus = 'unactivated', adminId = " + GetAdminId() +
                      " WHERE id = " + passHouseCommission.Id;

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #4
0
        public JsonResult RejectHouseCommission(RejectHouseCommission rejectHouseCommission)
        {
            var sql = "UPDATE house SET rentStatus = 'reject', adminId = " + GetAdminId() +
                      " WHERE id = " + rejectHouseCommission.Id;

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #5
0
        public JsonResult PassHouseOrder(PassHouseOrder passHouseOrder)
        {
            var sql = "UPDATE houseOrdered SET orderStatus = 'done', adminId = " + GetAdminId() +
                      " WHERE id = " + passHouseOrder.Id;

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #6
0
        public JsonResult RejectHouseOrder(RejectHouseOrder rejectHouseOrder)
        {
            var sql = "UPDATE houseOrdered SET orderStatus = 'reject', adminId = " + GetAdminId() +
                      " WHERE id = " + rejectHouseOrder.Id;

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #7
0
        public JsonResult RemoveCollect(RemoveCollect removeCollect)
        {
            string sql = "delete from houseCollected where houseId=" + removeCollect.HouseId + " and userId=" +
                         GetUserId();

            return(Success(DataOperate.Update(sql)));
        }
        public JsonResult RejectOwnerRenewalApply(RejectOwnerRenewalApply rejectOwnerRenewalApply)
        {
            var sql = "update renewalContractApply set applyStatus='reject', adminId=" + GetAdminId() + " where id=" +
                      rejectOwnerRenewalApply.Id;

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #9
0
        public JsonResult PerfectInfo(CurrentAdmin currentAdmin)
        {
            string sql = "update admin set name='" + currentAdmin.Name + "', sex='" + currentAdmin.Sex +
                         "', cardNum='" + currentAdmin.CardNum + "', phone='" + currentAdmin.Phone + "', native='" +
                         currentAdmin.Native + "', major='" + currentAdmin.Major + "', avatar='" + currentAdmin.Avatar +
                         "' where id= " + GetAdminId();

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #10
0
        public JsonResult PerfectInfo(CurrentUser currentUser)
        {
            string sql = "update user set name='" + currentUser.Name + "', sex='" + currentUser.Sex + "', cardNum='" +
                         currentUser.CardNum + "', phone='" + currentUser.Phone + "', native='" + currentUser.Native +
                         "', job='" + currentUser.Job +
                         "', avatar='" + currentUser.Avatar + "' where id= " + GetUserId();

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #11
0
        public bool DeleteTenant(TenantToDelete tenantToDelete)
        {
            string  selSql      = "select * from contract where userId=" + tenantToDelete.Id;
            string  delSql      = "update user set type='cancelled' where id=" + tenantToDelete.Id;
            DataSet allContract = DataOperate.FindAll(selSql);

            if ((allContract.Tables.Count == 1 && allContract.Tables[0].Rows.Count == 0) ||
                GetContractBool(allContract))
            {
                DataOperate.Update(delSql);
                return(true);
            }

            return(false);
        }
Beispiel #12
0
        public JsonResult UpdatePwd(UpdatePwd updatePwd)
        {
            string sql1 = "select * from admin where id=" + GetAdminId();
            var    r    = DataOperate.FindOne(sql1);

            if (r == null)
            {
                return(Fail(false, 2001));
            }
            else
            {
                if (r["pwd"].ToString() == updatePwd.Pwd)
                {
                    string sql2 = "update admin set pwd='" + updatePwd.NewPwd + "' where id=" + GetAdminId();
                    return(Success(DataOperate.Update(sql2)));
                }
                else
                {
                    return(Fail(false, 2002));
                }
            }
        }
        public JsonResult GetOwnerContractList()
        {
            var     sql         = "select * from contract where type='withOwner' and contractStatus != 'invalid'";
            DataSet allContract = DataOperate.FindAll(sql);

            // 检查合同状态并修改
            foreach (DataRow row in allContract.Tables[0].Rows)
            {
                var expired = (DateTime.Parse(row["endAt"].ToString()) <
                               DateTime.Parse(DateTime.Now.ToString()));
                var contractStatus = expired ? "fallDue" : "undue";
                var newSql         = "update contract set contractStatus='" + contractStatus + "' where id=" +
                                     row["id"].ToString();
                DataOperate.Update(newSql);
            }

            var sqlParent   = "select * from contract where type = 'withOwner' and parentNum is null and contractStatus != 'invalid'";
            var sqlChildren = "select * from contract where type = 'withOwner' and parentNum is not null and contractStatus != 'invalid'";

            var parentList = new List <OwnerContract>();

            DataSet parentRows   = DataOperate.FindAll(sqlParent);
            DataSet childrenRows = DataOperate.FindAll(sqlChildren);

            foreach (DataRow row in parentRows.Tables[0].Rows)
            {
                var ownerContract = new OwnerContract();
                foreach (var dataColumn in row.Table.Columns)
                {
                    ownerContract.SetAttribute(dataColumn.ToString(), row[dataColumn.ToString()].ToString());
                }

                ownerContract.Children = GetChildrenByParentId(childrenRows, ownerContract.Id.ToString());

                parentList.Add(ownerContract);
            }

            return(Success(parentList));
        }
Beispiel #14
0
 public JsonResult ChangePayStatus(ChangePayStatus changePayStatus)
 {
     return(Success(DataOperate.Update("update transactions set tranStatus = 'paid', tranDate = '" + changePayStatus.CurrentTime +
                                       "' where id=" + changePayStatus.id)));
 }
Beispiel #15
0
        public JsonResult RejectTobeOwnerApply(RejectTobeOwnerApply rejectTobeOwnerApply)
        {
            string sql = "update applyTobeowner set applyStatus = 'reject', adminId = " + GetAdminId() + " where id = " + rejectTobeOwnerApply.Id + ";";

            return(Success(DataOperate.Update(sql)));
        }
Beispiel #16
0
        public JsonResult RemoveOrder(RemoveOrder removeOrder)
        {
            string sql = "delete from houseOrdered where houseId=" + removeOrder.HouseId + " and userId=" + GetUserId();

            return(Success(DataOperate.Update(sql)));
        }