using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using House.Model;
namespace House.DAL
{
public class BuildingAccessor
{
public BuildingAccessor()
{ }
/// <summary>
/// 插入一条楼书记录
/// </summary>
/// <param name="buildingData">楼书实体</param>
/// <returns>插入成功后返回当前楼书编号,失败返回0</returns>
public static int InsertBuilding(BuildingData buildingData)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("Building_InsertUpdateDelete");
db.AddInParameter(command, "@DataTable_Action_", DbType.String, buildingData.DataTable_Action_);
db.AddInParameter(command, "@BuildingCode", DbType.String, buildingData.BuildingCode);
db.AddInParameter(command,"@BuildingName",DbType.String,buildingData.BuildingName);
db.AddInParameter(command,"@BuildingAddress",DbType.String,buildingData.BuildingAddress);
db.AddInParameter(command,"@BuildingLocation",DbType.Int32,buildingData.BuildingLocation);
db.AddInParameter(command, "@BuildingRegional", DbType.Int32, buildingData.BuildingRegional);
db.AddInParameter(command, "@BuildingLevel", DbType.Int32, buildingData.BuildingLevel);
db.AddInParameter(command, "@BuildingProperty", DbType.Int32, buildingData.BuildingProperty);
db.AddInParameter(command, "@BuildingYear", DbType.Int32, buildingData.BuildingYear);
db.AddInParameter(command, "@BuildingOwensType", DbType.Int32, buildingData.BuildingOwensType);
db.AddInParameter(command,"@BuildingArea",DbType.Decimal,buildingData.BuildingArea);
db.AddInParameter(command,"@BuildingMinOffice",DbType.Decimal,buildingData.BuildingMinOffice);
db.AddInParameter(command,"@BuildingMaxOffice", DbType.Decimal,buildingData.BuildingMaxOffice);
db.AddInParameter(command,"@BuildingMinRent", DbType.Decimal,buildingData.BuildingMinRent);
db.AddInParameter(command,"@BuildingMaxRent", DbType.Decimal,buildingData.BuildingMaxRent);
db.AddInParameter(command,"@BuildingMinSale", DbType.Decimal,buildingData.BuildingMinSale);
db.AddInParameter(command,"@BuildingMaxSale", DbType.Decimal,buildingData.BuildingMaxSale);
db.AddInParameter(command,"@BuildingMinProperty", DbType.Decimal,buildingData.BuildingMinProperty);
db.AddInParameter(command,"@BuildingMaxProperty", DbType.Decimal,buildingData.BuildingMaxProperty);
db.AddInParameter(command,"@BuildingOverFloors",DbType.Int32,buildingData.BuildingOverFloors);
db.AddInParameter(command,"@BuildingBelowFloors", DbType.Int32,buildingData.BuildingBelowFloors);
db.AddInParameter(command,"@BuildingParkingSpaces", DbType.Int32,buildingData.BuildingParkingSpaces);
db.AddInParameter(command,"@BuildingAir", DbType.Int32,buildingData.BuildingAir);
db.AddInParameter(command,"@BuildingAirConditioning", DbType.String,buildingData.BuildingAirConditioning);
db.AddInParameter(command,"@BuildingElevator",DbType.String,buildingData.BuildingElevator);
db.AddInParameter(command,"@BuildingPower",DbType.String,buildingData.BuildingPower);
db.AddInParameter(command,"@BuildingCommunications",DbType.String,buildingData.BuildingCommunications);
db.AddInParameter(command,"@BuildingSecurity",DbType.String,buildingData.BuildingSecurity);
db.AddInParameter(command,"@BuildingFire",DbType.String,buildingData.BuildingFire);
db.AddInParameter(command,"@BuildingFacilities",DbType.String,buildingData.BuildingFacilities);
db.AddInParameter(command,"@BuildingTraffic",DbType.String,buildingData.BuildingTraffic);
db.AddInParameter(command,"@BuildingFinancial",DbType.String,buildingData.BuildingFinancial);
db.AddInParameter(command,"@BuildingHotels",DbType.String,buildingData.BuildingHotels);
db.AddInParameter(command,"@BuildingFun",DbType.String,buildingData.BuildingFun);
db.AddInParameter(command,"@BuildingCustomers",DbType.String,buildingData.BuildingCustomers);
db.AddInParameter(command,"@BuildingDescription",DbType.String,buildingData.BuildingDescription);
db.AddInParameter(command,"@BuildingDevelopers", DbType.String,buildingData.BuildingDevelopers);
db.AddInParameter(command,"@BuildingPropertyCompany", DbType.String,buildingData.BuildingPropertyCompany);
db.AddInParameter(command, "@BuildingHallAddress", DbType.String, buildingData.BuildingHallAddress);
db.AddInParameter(command,"@BuildingFax", DbType.String,buildingData.BuildingFax);
db.AddInParameter(command,"@BuildingContact", DbType.String,buildingData.BuildingContact);
db.AddInParameter(command,"@BuildingPhone", DbType.String,buildingData.BuildingPhone);
db.AddInParameter(command,"@BuildingMobile", DbType.String,buildingData.BuildingMobile);
db.AddInParameter(command,"@BuildingEmail", DbType.String,buildingData.BuildingEmail);
db.AddInParameter(command,"@BuildingStandbyContact", DbType.String,buildingData.BuildingStandbyContact);
db.AddInParameter(command,"@BuildingAltPhone", DbType.String,buildingData.BuildingAltPhone);
db.AddInParameter(command,"@BuildingStandbyMobile", DbType.String,buildingData.BuildingStandbyMobile);
db.AddInParameter(command,"@BuildingStandEmail", DbType.String,buildingData.BuildingStandEmail);
db.AddInParameter(command,"@BuildingCooType", DbType.Int32,buildingData.BuildingCooType);
db.AddInParameter(command,"@BuildingRentPercent",DbType.String,buildingData.BuildingRentPercent);
db.AddInParameter(command, "@BuildingIntermediary", DbType.String, buildingData.BuildingIntermediary);
db.AddInParameter(command,"@CreatorId", DbType.Int32,buildingData.CreatorId);
db.AddInParameter(command,"@CreateTime",DbType.DateTime,buildingData.CreateTime);
db.AddInParameter(command,"@OwnerId", DbType.Int32,buildingData.OwnerId);
db.AddInParameter(command,"@UpdateTime",DbType.DateTime,buildingData.UpdateTime);
db.AddInParameter(command,"@BuildingIntroduction", DbType.String,buildingData.BuildingIntroduction);
db.AddInParameter(command,"@BuildingPhotos",DbType.String,buildingData.BuildingPhotos);
db.AddInParameter(command,"@Id",DbType.Int32,buildingData.Id);
try
{
return Convert.ToInt32(db.ExecuteScalar(command));
//Id = int.Parse(db.GetParameterValue(command, "@Id").ToString());
//return Id;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 根据表名查询出对应表主键字段最大ID
/// </summary>
/// <param name="tableName">表名</param>
/// <returns>最大ID</returns>
public static string MaxCode(string tableName)
{
string rCode = "0";
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
DateTime dTime = DateTime.Now;
sb.AppendFormat("SELECT MAX(Id) AS ID FROM {0}", tableName);
try
{
DataSet ds = db.ExecuteDataSet(CommandType.Text, sb.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0][0].ToString() != "")
rCode = (Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
}
return dTime.ToString("yyyyMMdd") + rCode;
}
catch (Exception ex)
{
throw ex;
}
}
//public static bool BuildingOwner(string strBuildingId,Int32 EmployeeId)
//{
// Database db = DatabaseFactory.CreateDatabase();
// string strSql = "UPDATE Building SET OwnerId = "
//}
/// <summary>
/// 分配楼书、房源、客户,并插入到记录表
/// </summary>
/// <param name="infoId">房源或楼书、或客户ID</param>
/// <param name="acquisitionId">获得人ID</param>
/// <param name="OwnerId">当前拥有人ID</param>
/// <param name="infoType">类型,building,office,customer</param>
/// <returns></returns>
public static Int32 ShareInfo(Int32 infoId, Int32 acquisitionId, Int32 OwnerId, string infoType)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand("ShareInfo");
db.AddInParameter(command, "@infoId", DbType.Int32, infoId);
db.AddInParameter(command, "@acquisitionId", DbType.Int32, acquisitionId);
db.AddInParameter(command, "@OwnerId", DbType.Int32, OwnerId);
db.AddInParameter(command, "@infoType", DbType.String, infoType);
try
{
return db.ExecuteNonQuery(command);
}
catch (Exception e)
{
throw e;
}
}
/// <summary>
/// 将记录集转为BuildingEntity实体类 (Building)
/// </summary>
/// <param name="dt.Rows[0]">记录集</param>
/// <param name="Fileds">字段名列表</param>
/// <returns>BuildingEntity</returns>
public static BuildingData BuildingEntity(DataTable dt)
{
BuildingData nc = new BuildingData();
if (dt.Rows[0]["Id"].ToString() != "") nc.Id = Convert.ToInt32(dt.Rows[0]["Id"]); // Id
if (!Convert.IsDBNull(dt.Rows[0]["BuildingCode"])) nc.BuildingCode = Convert.ToString(dt.Rows[0]["BuildingCode"]).Trim(); // 楼书编号
if (!Convert.IsDBNull(dt.Rows[0]["BuildingName"])) nc.BuildingName = Convert.ToString(dt.Rows[0]["BuildingName"]).Trim(); // BuildingName
if (!Convert.IsDBNull(dt.Rows[0]["BuildingAddress"])) nc.BuildingAddress = Convert.ToString(dt.Rows[0]["BuildingAddress"]).Trim(); // BuildingAddt.Rows[0]ess
if (!Convert.IsDBNull(dt.Rows[0]["BuildingLocation"])) nc.BuildingLocation = Convert.ToInt32(dt.Rows[0]["BuildingLocation"]); // 区位
if (!Convert.IsDBNull(dt.Rows[0]["BuildingRegional"])) nc.BuildingRegional = Convert.ToInt32(dt.Rows[0]["BuildingRegional"]); // 行政区域
if (!Convert.IsDBNull(dt.Rows[0]["BuildingLevel"])) nc.BuildingLevel = Convert.ToInt32(dt.Rows[0]["BuildingLevel"]); // 楼盘等级
if (!Convert.IsDBNull(dt.Rows[0]["BuildingProperty"])) nc.BuildingProperty = Convert.ToInt32(dt.Rows[0]["BuildingProperty"]); // 楼盘性质
if (!Convert.IsDBNull(dt.Rows[0]["BuildingYear"])) nc.BuildingYear = Convert.ToInt32(dt.Rows[0]["BuildingYear"]); // 建成年份
if (!Convert.IsDBNull(dt.Rows[0]["BuildingOwensType"])) nc.BuildingOwensType = Convert.ToInt32(dt.Rows[0]["BuildingOwensType"]); // 业主类型
if (!Convert.IsDBNull(dt.Rows[0]["BuildingArea"])) nc.BuildingArea = Convert.ToDouble(dt.Rows[0]["BuildingArea"]); // 建筑面积
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMinOffice"])) nc.BuildingMinOffice = Convert.ToDouble(dt.Rows[0]["BuildingMinOffice"]); // 面积划分开始
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMaxOffice"])) nc.BuildingMaxOffice = Convert.ToDouble(dt.Rows[0]["BuildingMaxOffice"]); // 面积划分结束
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMinRent"])) nc.BuildingMinRent = Convert.ToDouble(dt.Rows[0]["BuildingMinRent"]); // 参考租价开始
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMaxRent"])) nc.BuildingMaxRent = Convert.ToDouble(dt.Rows[0]["BuildingMaxRent"]); // 参考租价最大
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMinSale"])) nc.BuildingMinSale = Convert.ToDouble(dt.Rows[0]["BuildingMinSale"]); // 参考售价最小
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMaxSale"])) nc.BuildingMaxSale = Convert.ToDouble(dt.Rows[0]["BuildingMaxSale"]); // 最大
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMinProperty"])) nc.BuildingMinProperty = Convert.ToDouble(dt.Rows[0]["BuildingMinProperty"]); // 物管费最少
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMaxProperty"])) nc.BuildingMaxProperty = Convert.ToDouble(dt.Rows[0]["BuildingMaxProperty"]); // 物管费最多
if (!Convert.IsDBNull(dt.Rows[0]["BuildingOverFloors"])) nc.BuildingOverFloors = Convert.ToInt32(dt.Rows[0]["BuildingOverFloors"]); // 地面层数
if (!Convert.IsDBNull(dt.Rows[0]["BuildingBelowFloors"])) nc.BuildingBelowFloors = Convert.ToInt32(dt.Rows[0]["BuildingBelowFloors"]); // 地下层数
if (!Convert.IsDBNull(dt.Rows[0]["BuildingParkingSpaces"])) nc.BuildingParkingSpaces = Convert.ToInt32(dt.Rows[0]["BuildingParkingSpaces"]); // 车位数
if (!Convert.IsDBNull(dt.Rows[0]["BuildingAir"])) nc.BuildingAir = Convert.ToInt32(dt.Rows[0]["BuildingAir"]); // 1、中央空调2、分体中央空调3、无中央空调4、待定
if (!Convert.IsDBNull(dt.Rows[0]["BuildingAirConditioning"])) nc.BuildingAirConditioning = Convert.ToString(dt.Rows[0]["BuildingAirConditioning"]).Trim(); // 空调描述
if (!Convert.IsDBNull(dt.Rows[0]["BuildingElevator"])) nc.BuildingElevator = Convert.ToString(dt.Rows[0]["BuildingElevator"]).Trim(); // 电梯
if (!Convert.IsDBNull(dt.Rows[0]["BuildingPower"])) nc.BuildingPower = Convert.ToString(dt.Rows[0]["BuildingPower"]).Trim(); // 水电
if (!Convert.IsDBNull(dt.Rows[0]["BuildingCommunications"])) nc.BuildingCommunications = Convert.ToString(dt.Rows[0]["BuildingCommunications"]).Trim(); // BuildingCommunications
if (!Convert.IsDBNull(dt.Rows[0]["BuildingSecurity"])) nc.BuildingSecurity = Convert.ToString(dt.Rows[0]["BuildingSecurity"]).Trim(); // 安保
if (!Convert.IsDBNull(dt.Rows[0]["BuildingFire"])) nc.BuildingFire = Convert.ToString(dt.Rows[0]["BuildingFire"]).Trim(); // 消防
if (!Convert.IsDBNull(dt.Rows[0]["BuildingFacilities"])) nc.BuildingFacilities = Convert.ToString(dt.Rows[0]["BuildingFacilities"]).Trim(); // 配套设施
if (!Convert.IsDBNull(dt.Rows[0]["BuildingTraffic"])) nc.BuildingTraffic = Convert.ToString(dt.Rows[0]["BuildingTraffic"]).Trim(); // 周边交通
if (!Convert.IsDBNull(dt.Rows[0]["BuildingFinancial"])) nc.BuildingFinancial = Convert.ToString(dt.Rows[0]["BuildingFinancial"]).Trim(); // 周边金融
if (!Convert.IsDBNull(dt.Rows[0]["BuildingHotels"])) nc.BuildingHotels = Convert.ToString(dt.Rows[0]["BuildingHotels"]).Trim(); // 周边酒店
if (!Convert.IsDBNull(dt.Rows[0]["BuildingFun"])) nc.BuildingFun = Convert.ToString(dt.Rows[0]["BuildingFun"]).Trim(); // 餐饮娱乐
if (!Convert.IsDBNull(dt.Rows[0]["BuildingCustomers"])) nc.BuildingCustomers = Convert.ToString(dt.Rows[0]["BuildingCustomers"]).Trim(); // 入驻企业
if (!Convert.IsDBNull(dt.Rows[0]["BuildingDescription"])) nc.BuildingDescription = Convert.ToString(dt.Rows[0]["BuildingDescription"]).Trim(); // 大楼介绍
if (!Convert.IsDBNull(dt.Rows[0]["BuildingDevelopers"])) nc.BuildingDevelopers = Convert.ToString(dt.Rows[0]["BuildingDevelopers"]).Trim(); // 发展商
if (!Convert.IsDBNull(dt.Rows[0]["BuildingPropertyCompany"])) nc.BuildingPropertyCompany = Convert.ToString(dt.Rows[0]["BuildingPropertyCompany"]).Trim(); // 物管公司
if (!Convert.IsDBNull(dt.Rows[0]["BuildingHallAddress"])) nc.BuildingHallAddress = Convert.ToString(dt.Rows[0]["BuildingHallAddress"]).Trim(); // 租售办公地址
if (!Convert.IsDBNull(dt.Rows[0]["BuildingFax"])) nc.BuildingFax = Convert.ToString(dt.Rows[0]["BuildingFax"]).Trim(); // BuildingFax
if (!Convert.IsDBNull(dt.Rows[0]["BuildingContact"])) nc.BuildingContact = Convert.ToString(dt.Rows[0]["BuildingContact"]).Trim(); // 联系人1/职务
if (!Convert.IsDBNull(dt.Rows[0]["BuildingPhone"])) nc.BuildingPhone = Convert.ToString(dt.Rows[0]["BuildingPhone"]).Trim(); // 联系电话
if (!Convert.IsDBNull(dt.Rows[0]["BuildingMobile"])) nc.BuildingMobile = Convert.ToString(dt.Rows[0]["BuildingMobile"]).Trim(); // 手机
if (!Convert.IsDBNull(dt.Rows[0]["BuildingEmail"])) nc.BuildingEmail = Convert.ToString(dt.Rows[0]["BuildingEmail"]).Trim(); // E-Mail
if (!Convert.IsDBNull(dt.Rows[0]["BuildingStandbyContact"])) nc.BuildingStandbyContact = Convert.ToString(dt.Rows[0]["BuildingStandbyContact"]).Trim(); // 联系人2/职务
if (!Convert.IsDBNull(dt.Rows[0]["BuildingAltPhone"])) nc.BuildingAltPhone = Convert.ToString(dt.Rows[0]["BuildingAltPhone"]).Trim(); // 电话
if (!Convert.IsDBNull(dt.Rows[0]["BuildingStandbyMobile"])) nc.BuildingStandbyMobile = Convert.ToString(dt.Rows[0]["BuildingStandbyMobile"]).Trim(); // 手机
if (!Convert.IsDBNull(dt.Rows[0]["BuildingStandEmail"])) nc.BuildingStandEmail = Convert.ToString(dt.Rows[0]["BuildingStandEmail"]).Trim(); // E-Mail
if (!Convert.IsDBNull(dt.Rows[0]["BuildingCooType"])) nc.BuildingCooType = Convert.ToInt32(dt.Rows[0]["BuildingCooType"]); // 0请选择,1待定,2合作,3合作
if (!Convert.IsDBNull(dt.Rows[0]["BuildingRentPercent"])) nc.BuildingRentPercent = Convert.ToString(dt.Rows[0]["BuildingRentPercent"]).Trim(); // 物业合作描述
if (!Convert.IsDBNull(dt.Rows[0]["BuildingIntermediary"])) nc.BuildingIntermediary = Convert.ToString(dt.Rows[0]["BuildingIntermediary"]).Trim(); // BuildingIntermediary
if (!Convert.IsDBNull(dt.Rows[0]["CreatorId"])) nc.CreatorId = Convert.ToInt32(dt.Rows[0]["CreatorId"]); // 创建人ID
if (!Convert.IsDBNull(dt.Rows[0]["CreateTime"])) nc.CreateTime = Convert.ToDateTime(dt.Rows[0]["CreateTime"]); // 创建时间
if (!Convert.IsDBNull(dt.Rows[0]["OwnerId"])) nc.OwnerId = Convert.ToInt32(dt.Rows[0]["OwnerId"]); // 归属人ID
if (!Convert.IsDBNull(dt.Rows[0]["UpdateTime"])) nc.UpdateTime = Convert.ToDateTime(dt.Rows[0]["UpdateTime"]); // 更新时间
if (!Convert.IsDBNull(dt.Rows[0]["BuildingIntroduction"])) nc.BuildingIntroduction = Convert.ToString(dt.Rows[0]["BuildingIntroduction"]).Trim(); // 备注信息
if (!Convert.IsDBNull(dt.Rows[0]["BuildingPhotos"])) nc.BuildingPhotos = Convert.ToString(dt.Rows[0]["BuildingPhotos"]).Trim(); // 照片信息
return nc;
}
public static string GetTaskName(string TableName,Int32 Id,string filed)
{
string taskName = "";
Database db = DatabaseFactory.CreateDatabase();
StringBuilder sb = new StringBuilder();
if (TableName == "Office")
{
sb.AppendFormat("SELECT BuildingName AS Filed FROM Building WHERE Id = (SELECT OfficeBuildingId FROM Office WHERE Id = {0})", Id);
}
else
{
sb.AppendFormat("SELECT {0} AS Filed FROM {1} WHERE Id = {2}", filed, TableName,Id);
}
try
{
DataSet ds = db.ExecuteDataSet(CommandType.Text, sb.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0][0].ToString() != "")
taskName = ds.Tables[0].Rows[0][0].ToString();
}
return taskName;
}
catch (Exception ex)
{
throw ex;
}
}
public static int Application(string ShareId, string ShareType, Int32 ApplicationId, string AuditId)
{
Int32 result = -1;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "";
string[] arrayId;
string[] arrayOwener;
arrayOwener = AuditId.Split(',');
arrayId = ShareId.Split(',');
for (int i = 0; i < arrayId.Length; i++)
{
strSql = "INSERT INTO ShareList(ShareId,ShareType,ApplicationId,AuditId,ApplicationDate,AuditDate,status) VALUES(" + Convert.ToInt32(arrayId[i]) + ",'" + ShareType + "'," + ApplicationId + "," + Convert.ToInt32(arrayOwener[i]) + ",GETDATE(),GETDATE(),3)";
result = db.ExecuteNonQuery(CommandType.Text, strSql);
}
return result;
}
public static string BuildingName(Int32 BuildingId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT BuildingName FROM Building WHERE Id = " + BuildingId + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables[0].Rows.Count > 0)
{
return ds.Tables[0].Rows[0]["BuildingName"].ToString();
}
else
{
return "";
}
}
public static string BuildingCode(Int32 BuildingId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "SELECT BuildingCode FROM Building WHERE Id = " + BuildingId + "";
DataSet ds = db.ExecuteDataSet(CommandType.Text, strSql);
if (ds.Tables[0].Rows.Count > 0)
{
return ds.Tables[0].Rows[0]["BuildingCode"].ToString();
}
else
{
return "";
}
}
public static int SetBuildingEmployee(string id,string ShareId,string ApplicationId,Int32 stat)
{
Int32 result = -1;
Database db = DatabaseFactory.CreateDatabase();
string strSql = "";
string[] arrayShareId;
string[] arrayId;
string[] arrayApp;
arrayApp = ApplicationId.Split(','); //申请人ID
arrayId = id.Split(','); //申请记录ID
arrayShareId = ShareId.Split(',');
for (int i = 0; i < arrayId.Length; i++)
{
strSql = "UPDATE ShareList SET status = " + stat + " WHERE Id = " + Convert.ToInt32(arrayId[i]) + "";
result = db.ExecuteNonQuery(CommandType.Text, strSql);
if (stat == 1)
UpdateBuilding(Convert.ToInt32(arrayShareId[i]), Convert.ToInt32(arrayApp[i]));
}
return result;
}
public static void UpdateBuilding(Int32 BuildingId,Int32 OwnerId)
{
Database db = DatabaseFactory.CreateDatabase();
string strSql = "UPDATE Building SET OwnerId = "+OwnerId+" WHERE Id = "+ BuildingId +"";
db.ExecuteNonQuery(CommandType.Text,strSql);
}
}
}
public partial class office : System.Web.UI.Page
{
Int32 id = (Int32)Common.sink("id", Common.MethodType.Get, 10, 0, Common.DataType.Int);
string CMD = (string)Common.sink("CMD", Common.MethodType.Get, 10, 1, Common.DataType.Str);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OnStartData();
if (CMD == "Edit")
{
OnStart(id);
}
}
}
protected void OnStart(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where a.Id= " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = OfficeSystem.GetOfficeList(qp, out RecordCount);
OnStartData(OfficeSystem.PopulateOfficeEntity(ds.Tables[0]));
Int32 BuildingId = 0;
BuildingId = Convert.ToInt32(ds.Tables[0].Rows[0]["OfficeBuildingId"].ToString());
OnStart2(BuildingId);
}
protected void OnStart2(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where Id= " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = BuildingSystem.GetBuildingList(qp, out RecordCount);
BuildingData bd = BuildingSystem.BuildingEntity(ds.Tables[0]);
BuildingID.Value = bd.Id.ToString();
BuildingName.Value = bd.BuildingName;
BuildingAddress.Value = bd.BuildingAddress;
BuildingLocation.Value = GetBuildingLocation(bd.BuildingLocation);
BuildingRegional.Value = GetBuildingRegional(bd.BuildingRegional);
OfficeAirConditioning.Value = GetBuildingAir(bd.BuildingAir);
OfficeElevator.Value = bd.BuildingElevator;
BuildingProperty.Value = GetBuildingProperty(bd.BuildingProperty);
BuildingMinProperty.Value = bd.BuildingMinProperty.ToString();
BuildingMaxProperty.Value = bd.BuildingMaxProperty.ToString();
}
protected void OnStartData(OfficeData ut)
{
//OfficeBuildingId= OfficeBuildingId_Disp.Text = ut.OfficeBuildingId.ToString();
OfficeCode.Value = ut.OfficeCode.ToString();
OfficeBuildings.Value = ut.OfficeBuildings.ToString();
OfficeMinFloor.Value = ut.OfficeMinFloor.ToString();
OfficeMaxFloor.Value = ut.OfficeMaxFloor.ToString();
OfficeNumbers.Value = ut.OfficeNumbers.ToString();
OfficeRights.Value = ut.OfficeRights.ToString();
OfficeUseFor.Value = ut.OfficeUseFor.ToString();
OfficeMinArea.Value = ut.OfficeMinArea.ToString();
OfficeMaxArea.Value = ut.OfficeMaxArea.ToString();
OfficeMinRentPrice.Value = ut.OfficeMinRentPrice.ToString();
OfficeMaxRentPrice.Value = ut.OfficeMaxRentPrice.ToString();
OfficePayWay.Value = ut.OfficePayWay.ToString();
OfficeMinSalePrice.Value = ut.OfficeMinSalePrice.ToString();
OfficeMaxSalePrice.Value =ut.OfficeMaxSalePrice.ToString();
OfficeEntrance.Value = ut.OfficeEntrance.ToString();
OfficeEnSaw.Value = ut.OfficeEnSaw.ToString();
OfficeDoors.Value = ut.OfficeDoors.ToString();
OfficeDoors1.Value = ut.OfficeDoors1.ToString();
OfficeLighting.Value = ut.OfficeLighting.ToString();
OfficeDecoration.Value = ut.OfficeDecoration.ToString();
OfficeFace.Value = ut.OfficeFace.ToString();
OfficeWC.Value = ut.OfficeWC.ToString();
OfficeLayout.Value = ut.OfficeLayout.ToString();
OfficeParkingSpaces.Value = ut.OfficeParkingSpaces.ToString();
OfficeVisitWay.Value = ut.OfficeVisitWay.ToString();
OfficeVision.Value = ut.OfficeVision.ToString();
OfficeRentSaleStatus.Value =ut.OfficeRentSaleStatus.ToString();
OfficeInfoSource.Value = ut.OfficeInfoSource.ToString();
OfficeSource.Value = ut.OfficeSource.ToString();
OfficeOwensType.Value = ut.OfficeOwensType.ToString();
OfficeRentPercent.Value = ut.OfficeRentPercent.ToString();
OfficeRentDescription.Value = ut.OfficeRentDescription.ToString();
OfficeContact.Value = ut.OfficeContact.ToString();
OfficePhone.Value = ut.OfficePhone.ToString();
OfficeMobile.Value = ut.OfficeMobile.ToString();
OfficeEmail.Value = ut.OfficeEmail.ToString();
OfficeCustomer.Value = ut.OfficeCustomer.ToString();
OfficeContractBeginDate.Value = ut.OfficeContractBeginDate.ToString();
OfficeContractEndDate.Value = ut.OfficeContractEndDate.ToString();
OfficeRentChannels.Value = ut.OfficeRentChannels.ToString();
OfficeIntermediary.Value =ut.OfficeIntermediary.ToString();
OfficeDescription.Value = ut.OfficeDescription.ToString();
OfficePhotos.Value = ut.OfficePhotos.ToString();
Creator.Value = EmployeeSystem.GetEmployee(ut.CreatorId).EmployeeName;
CreateTime.Value = ut.CreateTime.ToString();
Owner.Value = EmployeeSystem.GetEmployee(ut.OwnerId).EmployeeName;
UpdateTime.Value = ut.UpDateTimeTime.ToString();
OnStart2(ut.OfficeBuildingId);
}
protected OfficeData VisittaskDisp(Int32 id)
{
QueryParam qp = new QueryParam();
qp.Where = "Where a.Id = " + id + "";
qp.PageIndex = 1;
qp.PageSize = 1;
int RecordCount = 0;
DataSet ds = OfficeSystem.GetOfficeList(qp, out RecordCount);
return OfficeSystem.PopulateOfficeEntity(ds.Tables[0]);
}
private string UpPhoto()
{
FileUpLoadCommon fc = new FileUpLoadCommon(Common.UpLoadDir + "Picture/", false);
fc.SaveFile(FileUpload1, true);
return fc.newFileName;
}
protected void btnOK_Click(object sender, EventArgs e)
{
string OfficeCode_Value = (string)Common.sink(OfficeCode.UniqueID, Common.MethodType.Post, 50, 1, Common.DataType.Str);
//string OfficeAirConditioning_Value = (string)Common.sink(OfficeAirConditioning.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//string OfficeElevator_Value = (string)Common.sink(OfficeElevator.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//string OfficeOverFloors_Value = (string)Common.sink(OfficeOverFloors.UniqueID, Common.MethodType.Post, 500, 1, Common.DataType.Str);
//double BuildingMinProperty_Value = (double)Common.sink(BuildingMinProperty.UniqueID, Common.MethodType.Post, 18, 1, Common.DataType.Double);
//double BuildingMaxProperty_Value = (double)Common.sink(BuildingMaxProperty.UniqueID, Common.MethodType.Post, 18, 1, Common.DataType.Double);
int OfficeBuildingId_Value = (int)Common.sink(BuildingID.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
string OfficeBuildings_Value = (string)Common.sink(OfficeBuildings.UniqueID, Common.MethodType.Post, 30, 1, Common.DataType.Str);
int OfficeMinFloor_Value = (int)Common.sink(OfficeMinFloor.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
int OfficeMaxFloor_Value = (int)Common.sink(OfficeMaxFloor.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
string OfficeNumbers_Value = (string)Common.sink(OfficeNumbers.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
int OfficeRights_Value = (int)Common.sink(OfficeRights.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeUseFor_Value = (int)Common.sink(OfficeUseFor.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
double OfficeMinArea_Value = (double)Common.sink(OfficeMinArea.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Double);
double OfficeMaxArea_Value = (double)Common.sink(OfficeMaxArea.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Double);
double OfficeMinRentPrice_Value = (double)Common.sink(OfficeMinRentPrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
double OfficeMaxRentPrice_Value = (double)Common.sink(OfficeMaxRentPrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficePayWay_Value = (string)Common.sink(OfficePayWay.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
double OfficeMinSalePrice_Value = (double)Common.sink(OfficeMinSalePrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
double OfficeMaxSalePrice_Value = (double)Common.sink(OfficeMaxSalePrice.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficeEntrance_Value = (string)Common.sink(OfficeEntrance.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeEnSaw_Value = (string)Common.sink(OfficeEnSaw.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeDoors_Value = (string)Common.sink(OfficeDoors.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficeDoors1_Value = (string)Common.sink(OfficeDoors1.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
int OfficeLighting_Value = (int)Common.sink(OfficeLighting.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeDecoration_Value = (int)Common.sink(OfficeDecoration.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeFace_Value = (int)Common.sink(OfficeFace.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeWC_Value = (int)Common.sink(OfficeWC.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeLayout_Value = (string)Common.sink(OfficeLayout.UniqueID, Common.MethodType.Post, 500, 0, Common.DataType.Str);
string OfficeParkingSpaces_Value = (string)Common.sink(OfficeParkingSpaces.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
int OfficeVisitWay_Value = (int)Common.sink(OfficeVisitWay.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeVision_Value = (string)Common.sink(OfficeVision.UniqueID, Common.MethodType.Post, 5000, 0, Common.DataType.Str);
int OfficeRentSaleStatus_Value = (int)Common.sink(OfficeRentSaleStatus.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
int OfficeInfoSource_Value = (int)Common.sink(OfficeInfoSource.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeSource_Value = (string)Common.sink(OfficeSource.UniqueID, Common.MethodType.Post, 5000, 0, Common.DataType.Str);
int OfficeOwensType_Value = (int)Common.sink(OfficeOwensType.UniqueID, Common.MethodType.Post, 10, 1, Common.DataType.Int);
double OfficeRentPercent_Value = (double)Common.sink(OfficeRentPercent.UniqueID, Common.MethodType.Post, 18, 0, Common.DataType.Double);
string OfficeRentDescription_Value = (string)Common.sink(OfficeRentDescription.UniqueID, Common.MethodType.Post, 80, 0, Common.DataType.Str);
string OfficeContact_Value = (string)Common.sink(OfficeContact.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficePhone_Value = (string)Common.sink(OfficePhone.UniqueID, Common.MethodType.Post, 30, 0, Common.DataType.Str);
string OfficeMobile_Value = (string)Common.sink(OfficeMobile.UniqueID, Common.MethodType.Post, 20, 0, Common.DataType.Str);
string OfficeEmail_Value = (string)Common.sink(OfficeEmail.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Str);
string OfficeCustomer_Value = (string)Common.sink(OfficeCustomer.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
DateTime? OfficeContractBeginDate_Value = (DateTime?)Common.sink(OfficeContractBeginDate.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Dat);
DateTime? OfficeContractEndDate_Value = (DateTime?)Common.sink(OfficeContractEndDate.UniqueID, Common.MethodType.Post, 50, 0, Common.DataType.Dat);
int OfficeRentChannels_Value = (int)Common.sink(OfficeRentChannels.UniqueID, Common.MethodType.Post, 10, 0, Common.DataType.Int);
string OfficeIntermediary_Value = (string)Common.sink(OfficeIntermediary.UniqueID, Common.MethodType.Post, 200, 0, Common.DataType.Str);
string OfficeDescription_Value = (string)Common.sink(OfficeDescription.UniqueID, Common.MethodType.Post, 4000, 0, Common.DataType.Str);
string OfficePhotos_Value = (string)Common.sink(OfficePhotos.UniqueID, Common.MethodType.Post, 100, 0, Common.DataType.Str);
int CreatorId_Value = Common.Get_UserID;
DateTime? CreateTime_Value = DateTime.Now;
int OwnerId_Value = Common.Get_UserID;
DateTime? UpdateTime_Value = DateTime.Now;
OfficeData ut = new OfficeData();
if (CMD == "New")
{
ut.OfficeCode = "FY" + BuildingSystem.MaxCode("dbo.Office");
ut.CreateTime = DateTime.Now;
ut.DataTable_Action_ = "Insert";
ut.OfficePhotos = UpPhoto();
ut.CreatorId = CreatorId_Value;
ut.OwnerId = OwnerId_Value;
}
else if (CMD == "Edit")
{
ut = VisittaskDisp(id);
if (ut.OwnerId == Common.Get_UserID || OfficeLoginSystem.EmpolyeeRole(Common.Get_UserID) == 0)
{
ut.DataTable_Action_ = "Update";
string strPic = UpPhoto();
if (strPic != "" && strPic != null)
{
ut.OfficePhotos = strPic;
}
}
else
{
Common.MsgBox("对不起,你没有编辑该项的权限!", "officelist.aspx");
}
}
ut.Id = id;
ut.OfficeCode = OfficeCode_Value;
//ut.OfficeAirConditioning = OfficeAirConditioning_Value;
//ut.OfficeElevator = OfficeElevator_Value;
//ut.OfficeOverFloors = OfficeOverFloors_Value;
//ut.BuildingMinProperty = (decimal)BuildingMinProperty_Value;
//ut.BuildingMaxProperty = (decimal)BuildingMaxProperty_Value;
ut.OfficeBuildingId = OfficeBuildingId_Value;
ut.OfficeBuildings = OfficeBuildings_Value;
ut.OfficeMinFloor = OfficeMinFloor_Value;
ut.OfficeMaxFloor = OfficeMaxFloor_Value;
ut.OfficeNumbers = OfficeNumbers_Value;
ut.OfficeRights = OfficeRights_Value;
ut.OfficeUseFor = OfficeUseFor_Value;
ut.OfficeMinArea = OfficeMinArea_Value;
ut.OfficeMaxArea = OfficeMaxArea_Value;
ut.OfficeMinRentPrice = OfficeMinRentPrice_Value;
ut.OfficeMaxRentPrice = OfficeMaxRentPrice_Value;
ut.OfficePayWay = OfficePayWay_Value;
ut.OfficeMinSalePrice = OfficeMinSalePrice_Value;
ut.OfficeMaxSalePrice = OfficeMaxSalePrice_Value;
ut.OfficeEntrance = OfficeEntrance_Value;
ut.OfficeEnSaw = OfficeEnSaw_Value;
ut.OfficeDoors = OfficeDoors_Value;
ut.OfficeDoors1 = OfficeDoors1_Value;
ut.OfficeLighting = OfficeLighting_Value;
ut.OfficeDecoration = OfficeDecoration_Value;
ut.OfficeFace = OfficeFace_Value;
ut.OfficeWC = OfficeWC_Value;
ut.OfficeLayout = OfficeLayout_Value;
ut.OfficeParkingSpaces = OfficeParkingSpaces_Value;
ut.OfficeVisitWay = OfficeVisitWay_Value;
ut.OfficeVision = OfficeVision_Value;
ut.OfficeRentSaleStatus = OfficeRentSaleStatus_Value;
ut.OfficeInfoSource = OfficeInfoSource_Value;
ut.OfficeSource = OfficeSource_Value;
ut.OfficeOwensType = OfficeOwensType_Value;
ut.OfficeRentPercent = (decimal)OfficeRentPercent_Value;
ut.OfficeRentDescription = OfficeRentDescription_Value;
ut.OfficeContact = OfficeContact_Value;
ut.OfficePhone = OfficePhone_Value;
ut.OfficeMobile = OfficeMobile_Value;
ut.OfficeEmail = OfficeEmail_Value;
ut.OfficeCustomer = OfficeCustomer_Value;
ut.OfficeContractBeginDate = OfficeContractBeginDate_Value;
ut.OfficeContractEndDate = OfficeContractEndDate_Value;
ut.OfficeRentChannels = OfficeRentChannels_Value;
ut.OfficeIntermediary = OfficeIntermediary_Value;
ut.OfficeDescription = OfficeDescription_Value;
ut.UpDateTimeTime = UpdateTime_Value;
Int32 rResult = OfficeSystem.OfficeInsertUpdateDelete(ut);
if (rResult > 0)
Common.MsgBox("操作成功!");
else if (rResult == -1)
Common.MsgBox("操作失败,存在相同的记录");
else
Common.MsgBox("操作失败,请稍后再试!");
}
protected void OnStartData()
{
CreateTime.Value = UpdateTime.Value = DateTime.Now.ToString();
EmployeeData _EmployeeData = EmployeeSystem.GetEmployee(Common.Get_UserID);
Creator.Value = _EmployeeData.EmployeeName;
Owner.Value = _EmployeeData.EmployeeName;
}
public string GetBuildingLocation(int BuildingLocationId)
{
switch (BuildingLocationId)
{
case 5:
return "内环内 - 西北";
case 6:
return "内环内 - 东北";
case 7:
return "内环内 - 东南";
case 8:
return "内环内 - 西南";
case 9:
return "内一环 - 西北";
case 10:
return "内一环 - 东北";
case 11:
return "内一环 - 东南";
case 12:
return "内一环 - 西南";
case 13:
return "一二环 - 西北";
case 14:
return "一二环 - 东北";
case 15:
return "一二环 - 东南";
case 16:
return "一二环 - 西南";
case 17:
return "二三环 - 西北";
case 18:
return "二三环 - 东北";
case 19:
return "二三环 - 东南";
case 20:
return "二三环 - 西南";
case 22:
return "三环外 - 西北";
case 23:
return "三环外 - 东北";
case 24:
return "三环外 - 东南";
case 25:
return "三环外 - 西南";
default:
return "待定";
}
}
public string GetBuildingProperty(int BuildingPropertyId)
{
switch (BuildingPropertyId)
{
case 1:
return "专业写字楼";
case 2:
return "商住纯写";
case 3:
return "商住混用";
case 4:
return "营业用房";
case 5:
return "厂房";
case 6:
return "酒店";
case 7:
return "待定";
default:
return "待定";
}
}
public string GetBuildingRegional(int BuildingRegionalId)
{
switch (BuildingRegionalId)
{
case 1:
return "锦江区";
case 2:
return "青羊区";
case 3:
return "金牛区";
case 4:
return "武侯区";
case 5:
return "成华区";
case 6:
return "高新区";
case 7:
return "高新(西区)";
case 8:
return "高新(南区)";
default:
return "待定";
}
}
public string GetBuildingAir(int BuildingAirId)
{
switch (BuildingAirId)
{
case 1:
return "中央空调";
case 2:
return "分体中央空调";
case 3:
return "无中央空调";
case 4:
return "待定";
default:
return "待定";
}
}
}
|