1.指定客戶查詢
從上邊界面上可以看到我們這裏用到的控件有
控件名稱 |
說明 |
標註(Label) |
控件可以在工具箱直接拖動至窗體,拖至窗體後右擊屬性可以修改控件的樣式和各種屬性,還可以編輯事件。 |
選項卡(TabControl) |
|
下拉框(ComboBox) |
|
文本(TextBox) |
|
按鈕(Button) |
|
菜單(ToolStripMenuItem) |
|
工具欄(ToolStrip) |
|
組容器(GroupBox) |
|
表格(DataGridView) |
功能實現:
第一步:數據庫
1、表與關係
表1: 房間資源表(dbo.SYS_RoomResource)
Primary Key(主鍵): RoomResourcesID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
RoomResourcesID |
int - Identity |
|
No |
房間資源ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
TheCodeModelID |
int |
|
Yes |
屬性明細表,代碼模式ID
|
Number |
nchar (10) |
|
Yes |
編號
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
FloorStotey |
nchar (10) |
|
Yes |
樓層
|
RoomCategoryID |
int |
|
Yes |
屬性明細表,房間類別ID
|
TowardID |
int |
|
Yes |
屬性明細表,朝向ID
|
DoorModelID |
int |
|
Yes |
屬性明細表,戶型ID
|
RoomTypeID |
int |
|
Yes |
屬性明細表,房間類型ID
|
RoomLandScapeID |
int |
|
Yes |
屬性明細表,房間景觀ID
|
RoomSpecialID |
int |
|
Yes |
屬性明細表,房間特殊ID
|
ConstructionArea |
decimal (18, 2) |
|
Yes |
建築面積
|
PricateArea |
decimal (18, 2) |
|
Yes |
私有面積
|
PublicArea |
decimal (18, 2) |
|
Yes |
公攤面積
|
Usage |
decimal (18, 2) |
|
Yes |
使用率
|
TheUnitPrice |
decimal (18, 2) |
|
Yes |
標價單價
|
BidPrice |
decimal (18, 2) |
|
Yes |
標價總價
|
NumberOfPrice |
nchar (10) |
|
Yes |
價格次數
|
SalesStatusID |
int |
((102)) |
Yes |
屬性明細表,銷售狀態ID
|
BriefNote |
nchar (30) |
|
Yes |
簡要備註
|
SchematicDiagram |
image |
|
Yes |
示意圖
|
Chart |
image |
|
Yes |
效果圖
|
表2: 樓棟信息表(dbo.SYS_FloorInformation)
Primary Key(主鍵): FloorID
非主鍵ID值均是外鍵
(這裏因爲在這個表裏邊沒有設置有默認值,所以沒有默認值的那一列)
列名 |
數據類型 |
Nulls? |
說明 |
FloorID |
int - Identity |
No |
樓棟ID
|
ProjectID |
int |
Yes |
項目信息表,項目ID
|
FloorStructureID |
int |
Yes |
屬性明細表,樓棟結構ID
|
OpenBatchID |
int |
Yes |
屬性明細表,開盤批次ID
|
LaunchSituationID |
int |
Yes |
屬性明細表,推出情況ID
|
OpeningSituationID |
int |
Yes |
屬性明細表,開盤情況ID
|
FloorLevelID |
int |
Yes |
樓棟級別ID
|
SortNumber |
nchar (10) |
Yes |
序號
|
FloorName |
nchar (20) |
Yes |
樓棟名稱
|
PropertyRightFloorName |
nchar (20) |
Yes |
產權樓棟名稱
|
FloorStorey |
nchar (10) |
Yes |
樓棟層數
|
LaunchDate |
datetime |
Yes |
推出日期
|
DoMortgageDate |
datetime |
Yes |
具備辦按揭日期
|
CapsDate |
datetime |
Yes |
封頂日期
|
AccumulationFundDate |
datetime |
Yes |
具備辦公積金日期
|
ExpectedPayDate |
datetime |
Yes |
預計交房日期
|
PropertyRightDate |
datetime |
Yes |
具備辦產權日期
|
MakingRoomDate |
datetime |
Yes |
交房日期 |
表3: 項目信息表(dbo.SYS_ProjectInformation)
Primary Key(主鍵): ProjectID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ProjectID |
int - Identity |
|
No |
項目ID
|
SortNumber |
int |
|
Yes |
排序號
|
ProjectAreaID |
int |
|
Yes |
屬性明細表,項目區域ID
|
Project_FatherlID |
int |
|
Yes |
項目信息表,項目級別ID
|
ProjectName |
nchar (20) |
|
Yes |
項目名稱
|
PropertyRightProjectName |
nchar (20) |
|
Yes |
產權項目名稱
|
ProjectCompanyName |
nchar (20) |
|
Yes |
項目公司名稱
|
ProjectAddress |
nchar (50) |
|
Yes |
項目座落地址
|
CaseWhether |
bit |
|
Yes |
是否結案
|
CancelWhether |
bit |
((0)) |
Yes |
有效否
|
表4: 房源保留表(dbo.PW_RoomSelect_Keep)
Primary Key(主鍵): KeepID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
KeepID |
int - Identity |
|
No |
保留ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
RoomResourcesID |
int |
|
Yes |
房間資源ID,房間ID
|
UnitPrice |
decimal (18, 2) |
|
Yes |
單價
|
Price |
decimal (18, 2) |
|
Yes |
售價
|
KeepPeople |
int |
|
Yes |
保留人
|
Note |
nchar (300) |
|
Yes |
說明
|
StartDate |
datetime |
|
Yes |
開始時間
|
KeepTime |
nchar (10) |
|
Yes |
保留時長
|
KeepDate |
nchar (10) |
|
Yes |
保留天數
|
OperatingPerson |
int |
|
Yes |
經辦人員
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表5: 客戶信息 (dbo.PW_ClientInformation)
Primary Key(主鍵): ClientID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientID |
int - Identity |
|
No |
客戶ID
|
ProjectID |
int |
|
Yes |
項目信息表,項目ID
|
ClientNumber |
nchar (10) |
|
Yes |
客戶編號
|
ClientName |
nchar (10) |
|
Yes |
客戶名稱
|
EarlyVisitIntention |
nchar (10) |
|
Yes |
初訪意向
|
Gender |
nchar (10) |
|
Yes |
性別
|
MaritalStatus |
nchar (10) |
|
Yes |
婚否
|
ClientRegistrationWayID |
int |
|
Yes |
屬性明細表,客戶登記方式ID
|
RelationPhone |
nchar (15) |
|
Yes |
聯繫電話
|
ElectronMail |
nchar (30) |
|
Yes |
電子郵箱
|
HomeBuyerConsultantID |
int |
|
Yes |
員工表,置業顧問ID
|
DateOfVisit |
datetime |
|
Yes |
來訪日期
|
CommunicationAddress |
nchar (50) |
|
Yes |
通訊地址
|
Postcode |
nchar (10) |
|
Yes |
郵編
|
IDentityCard |
nchar (30) |
|
Yes |
身份證號
|
BirthDay |
date |
|
Yes |
出生日期
|
Age |
nchar (20) |
|
Yes |
年齡
|
Professional |
nchar (20) |
|
Yes |
職業
|
NowLivingArea |
nchar (20) |
|
Yes |
現居住區域
|
LearnTheWayToTheCase |
nchar (20) |
|
Yes |
獲取本案途徑
|
VisitConstitute |
nchar (20) |
|
Yes |
來客構成
|
Traffic |
nchar (20) |
|
Yes |
交通
|
RealEstateSituation |
nchar (20) |
|
Yes |
置業狀況
|
ResidentialMortgageLoans |
nchar (20) |
|
Yes |
住宅按揭貸款
|
HomesBuyersPurpose |
nchar (20) |
|
Yes |
置業目的
|
PlanTorealEstatePrice |
nchar (20) |
|
Yes |
計劃置業價格
|
DemandArea |
nchar (20) |
|
Yes |
需求面積
|
PaymentWay |
nchar (20) |
|
Yes |
付款方式ID
|
BuyingConsideration |
nchar (20) |
|
Yes |
買房考慮因素
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表6: 客戶事件記錄表 (dbo.PW_ClientEventRecord)
Primary Key(主鍵): EventRecordID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
EventRecordID |
int - Identity |
No |
事件記錄ID
|
ClientID |
int |
Yes |
客戶信息表,客戶ID
|
RecordDate |
datetime |
Yes |
記錄日期
|
Characteristic |
nchar (200) |
Yes |
特徵
|
explain |
nchar (200) |
Yes |
說明
|
表7: 客戶交往明細表 (dbo.PW_ClientContractDetails)
Primary Key(主鍵): ClientContractDetailsID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
ClientContractDetailsID |
int - Identity |
No |
客戶交往明細ID
|
ProjectID |
int |
Yes |
項目信息表,項目ID
|
ClientID |
int |
Yes |
客戶表,客戶ID
|
ContractTime |
datetime |
Yes |
交往時間
|
DegreeOfInterest |
char (10) |
Yes |
意向程度
|
InteractionsID |
int |
Yes |
屬性明細表,交往方式ID
|
VisitFormID |
int |
Yes |
屬性明細表,來訪形態ID
|
HomeBuyerConsultantID |
int |
Yes |
員工表,置業顧問ID
|
RecommendedHousingID |
int |
Yes |
房間資源表,推薦房源ID
|
CommunicationContent |
nchar (30) |
Yes |
交往內容
|
表8: 預定表 (dbo.PW_ReserveUnit)
Primary Key(主鍵): ReserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ReserveUnitID |
int - Identity |
|
No |
預訂單元ID
|
ClientID |
int |
|
Yes |
客戶表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
nchar (10) |
|
Yes |
預售面積
|
ReservationPrice |
money |
|
Yes |
預收單價
|
BookingReservationPrice |
money |
|
Yes |
預定總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
BookingDate |
datetime |
|
Yes |
預定日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
AuditDate |
date |
|
Yes |
審覈日期
|
NewReserveUnitID |
int |
|
Yes |
預定表,新預定ID
|
ChangeReason |
int |
|
Yes |
屬性明細表,變更原因ID
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表9: 保留表 (dbo. PW_RoomSelect_Keep)
Primary Key(主鍵): KeepID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
KeepID |
int - Identity |
|
No |
保留ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
RoomResourcesID |
int |
|
Yes |
房間資源表,房間ID
|
UnitPrice |
decimal (18, 2) |
|
Yes |
單價
|
Price |
decimal (18, 2) |
|
Yes |
售價
|
KeepPeople |
int |
|
Yes |
保留人
|
Note |
nchar (300) |
|
Yes |
說明
|
StartDate |
datetime |
|
Yes |
開始時間
|
KeepTime |
nchar (10) |
|
Yes |
保留時長
|
KeepDate |
nchar (10) |
|
Yes |
保留天數
|
OperatingPerson |
int |
|
Yes |
經辦人員
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表10: 預留表 (dbo. PW_SeserveUnit)
Primary Key(主鍵): SeserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SeserveUnitID |
int - Identity |
|
No |
預留單元ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
房間資源表,房間單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
decimal (18, 2) |
|
Yes |
預售面積
|
SeservationUnitPrice |
decimal (18, 2) |
|
Yes |
預留單價
|
BookingSeservationPrice |
decimal (18, 2) |
|
Yes |
預留總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
SeservatingDate |
datetime |
|
Yes |
預留日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (100) |
|
Yes |
簡要備註
|
AuditDate |
datetime |
|
Yes |
審覈日期
|
NewSeserveUnitID |
int |
|
Yes |
預留表,新的預留ID
|
ChangeReason |
int |
|
Yes |
變更原因
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表11: 認購表 (dbo. PW_SubscribeUnit)
Primary Key(主鍵): SubscribeUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SubscribeUnitID |
int - Identity |
|
No |
認購單元ID
|
SalesChangeID |
int |
|
Yes |
銷售便更表,銷售變更ID
|
SubscriptioNumber |
nchar (20) |
|
Yes |
認購單編號
|
SubscribeToDate |
datetime |
|
Yes |
認購日期
|
AnticipatedDateSigned |
datetime |
|
Yes |
預計簽約日期
|
ContractArea |
nchar (10) |
|
Yes |
合同面積
|
TypeOfPanymentID |
int |
|
Yes |
付款方式表,付款方式ID
|
PaymentDetailsOfNameID |
int |
|
Yes |
付款方式明細表,付款名稱細目ID
|
SalesAreaOfWayID |
int |
|
Yes |
屬性明細表,銷售面積方式ID
|
FsvorableDiscount |
decimal (18, 2) |
|
Yes |
優惠折扣
|
ClinchADealUnitPrice |
money |
|
Yes |
成交單價
|
ClinchADealThePrice |
money |
|
Yes |
成交總價
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
AgentID |
int |
|
Yes |
員工表,經辦人ID
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
ReviewWhether |
bit |
((0)) |
Yes |
審覈否
|
CancelWhether |
bit |
((0)) |
Yes |
作廢否
|
ChangeOfAuditStatusID |
int |
|
Yes |
屬性明細表,變更審覈狀態ID
|
RoomResourcesID |
int |
|
Yes |
房間資源表,房源ID
|
AfterUpdateID |
int |
|
Yes |
認購表,修改後的認購ID
|
表12: 認籌表 (dbo. PW_ClientConfessToRaise)
Primary Key(主鍵): ClientConfessToRaiseID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientConfessToRaiseID |
int - Identity |
|
No |
客戶認籌ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
RaiseNumeralRecognition |
nchar (10) |
|
Yes |
認籌排號
|
TheOrderNumber |
nchar (10) |
|
Yes |
訂單號
|
ConfessToRaiseClassificationID |
int |
|
Yes |
屬性明細表,籌卡分類ID
|
AccountsReceivableAppointmentGold |
money |
|
Yes |
應收預約金
|
ConfesstoraiseDate |
datetime |
|
Yes |
認籌日期
|
EffectiveDate |
datetime |
|
Yes |
有效日期
|
IntentionUnitInstructions |
nchar (10) |
|
Yes |
意向單元說明
|
Note |
nchar (30) |
|
Yes |
備註
|
ToSeserve |
bit |
((0)) |
Yes |
轉預留否
|
SeserveID |
int |
|
Yes |
預留表,預留ID
|
AuditWhether |
bit |
((0)) |
Yes |
審覈否
|
IncalidWhether |
bit |
((0)) |
Yes |
作廢否
|
AfterUpdateID |
int |
|
Yes |
認籌表,修改後ID
|
2、具體代碼實現
第一步:數據庫存儲過程
if @Type='CustomerQuery_Load_BindingdgvProject'--查詢項目信息用來綁定dgv
begin
SELECT ProjectID, rtrim(SortNumber) as SortNumber, rtrim(ProjectName) as ProjectName
FROM SYS_ProjectInformation
end
if @Type='btnSelect_Click_SelectAppointCustomer'--條件查詢客戶
begin
with CTE as (--with用的是臨時表,CTE是臨時表的名字
SELECT PW_ClientInformation.ClientName, PW_ClientInformation.ClientID, PW_ClientInformation.RelationPhone,
PW_ClientInformation.HomeBuyerConsultantID, SYS_Staff.StaffName
FROM PW_ClientInformation INNER JOIN
SYS_Staff ON PW_ClientInformation.HomeBuyerConsultantID = SYS_Staff.StaffID
where (PW_ClientInformation.ClientID in(SELECT ClientID
FROM PW_ClientConfessToRaise where PW_ClientConfessToRaise.IncalidWhether=0)
or PW_ClientInformation.ClientID in(SELECT ClientID
FROM PW_ReserveUnit where PW_ReserveUnit.IncalidOr=0 )
or PW_ClientInformation.ClientID in(SELECT ClientID
FROM PW_SeserveUnit where PW_SeserveUnit.IncalidOr=0 )
or PW_ClientInformation.ClientID in(SELECT KeepPeople
FROM PW_RoomSelect_Keep
where PW_RoomSelect_Keep.IncalidOr=0)) and PW_ClientInformation.IncalidOr=0 )
select rtrim(ClientName) ClientName, ClientID, rtrim(RelationPhone) RelationPhone,HomeBuyerConsultantID,RTRIM(StaffName) as HomeBuyerConsultantName
from CTE --在臨時表裏邊查詢相關的信息
where ClientName like '%' + rtrim(ltrim(@Condition)) + '%' or RelationPhone like '%' + rtrim(ltrim(@Condition)) + '%'--條件
end
if @Type='dgvProject_CellMouseDoubleClick_BindingcboFloor'--根據選定的項目,來綁定cbo樓棟
begin
SELECT FloorID, rtrim(FloorName) as FloorName
FROM SYS_FloorInformation
where SYS_FloorInformation.ProjectID=@ProjectID
end
if @Type='cboBuildingNumber_SelectionChangeCommitted_BindingcboRoomResource'
begin
SELECT RoomResourcesID, rtrim(Number) as Number
FROM SYS_RoomResources
where RoomResourcesID in (SELECT UnitNumberID
FROM PW_ReserveUnit where PW_ReserveUnit.IncalidOr=0) and SYS_RoomResources.FloorID=@FloorID
union --union是聯合表的標誌
SELECT RoomResourcesID, rtrim(Number) as Number
FROM SYS_RoomResources
where RoomResourcesID in (SELECT RoomResourcesID
FROM PW_RoomSelect_Keep where PW_RoomSelect_Keep.IncalidOr=0) and SYS_RoomResources.FloorID=@FloorID
union
SELECT RoomResourcesID, rtrim(Number) as Number
FROM SYS_RoomResources
where RoomResourcesID in (SELECT UnitNumberID
FROM PW_SeserveUnit where PW_SeserveUnit.IncalidOr=0) and SYS_RoomResources.FloorID=@FloorID
union
SELECT RoomResourcesID, rtrim(Number) as Number
FROM SYS_RoomResources
where RoomResourcesID in (SELECT RoomResourcesID
FROM PW_SubscribeUnit where PW_SubscribeUnit.CancelWhether=0) and SYS_RoomResources.FloorID=@FloorID
end
if @Type='cboRoomNumber_SelectionChangeCommitted_SelectCustomer'--根據選定的房源來查詢所屬房源相應的客戶
begin
SELECT RTRIM(PW_ClientInformation.RelationPhone) AS RelationPhone, PW_ClientInformation.HomeBuyerConsultantID, RTRIM(SYS_Staff.StaffName) AS HomeBuyerConsultantName, PW_ClientInformation.ClientID,
RTRIM(PW_ClientInformation.ClientName) as ClientName
FROM PW_ClientInformation INNER JOIN
SYS_Staff ON PW_ClientInformation.HomeBuyerConsultantID = SYS_Staff.StaffID
where PW_ClientInformation.ClientID in (
SELECT ClientID FROM PW_ReserveUnit where PW_ReserveUnit.IncalidOr=0 and PW_ReserveUnit.ReserveUnitID=@RoomResourcesID)
or PW_ClientInformation.ClientID in(
SELECT KeepPeople FROM PW_RoomSelect_Keep where PW_RoomSelect_Keep.IncalidOr=0 and PW_RoomSelect_Keep.RoomResourcesID=@RoomResourcesID)
or PW_ClientInformation.ClientID in(
SELECT ClientID FROM PW_SeserveUnit where PW_SeserveUnit.IncalidOr=0 and PW_SeserveUnit.SeserveUnitID=@RoomResourcesID)
or PW_ClientInformation.ClientID in(
SELECT ClientID FROM PW_SubscribeUnit where PW_SubscribeUnit.CancelWhether=0 and PW_SubscribeUnit.SubscribeUnitID=@RoomResourcesID)
end
if @Type='Binding_dgvdgvClientRecord'--查詢客戶記錄
begin
SELECT RTRIM(PW_ClientInformation.ClientNumber) AS ClientNumber, RTRIM(PW_ClientInformation.ClientName) AS ClientName, PW_ClientEventRecord.RecordDate AS RecordDate,
RTRIM(PW_ClientEventRecord.Characteristic) AS Characteristic, RTRIM(PW_ClientEventRecord.explain) AS explain, PW_ClientInformation.ClientID
FROM PW_ClientEventRecord INNER JOIN
PW_ClientInformation ON PW_ClientEventRecord.ClientID = PW_ClientInformation.ClientID
where PW_ClientEventRecord.ClientID=@ClientID
end
第二步:BLL(邏輯層)具體代碼
[OperationContract]
#region 綁定dgv項目
public DataSet CustomerQuery_Load_BindingdgvProject()
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
};
SQLCMDpas[0].Value = "CustomerQuery_Load_BindingdgvProject";
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 模糊查詢客戶
public DataSet btnSelect_Click_SelectAppointCustomer(string strCondition)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@Condition", SqlDbType.Char),
};
SQLCMDpas[0].Value = "btnSelect_Click_SelectAppointCustomer";
SQLCMDpas[1].Value = strCondition;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 綁定cboFloor
public DataSet dgvProject_CellMouseDoubleClick_BindingcboFloor(int intProjectID)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@ProjectID", SqlDbType.Int),
};
SQLCMDpas[0].Value = "dgvProject_CellMouseDoubleClick_BindingcboFloor";
SQLCMDpas[1].Value = intProjectID;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 綁定cboRoomResource
public DataSet cboBuildingNumber_SelectionChangeCommitted_BindingcboRoomResource(int intFloorID)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@FloorID", SqlDbType.Int),
};
SQLCMDpas[0].Value = "cboBuildingNumber_SelectionChangeCommitted_BindingcboRoomResource";
SQLCMDpas[1].Value = intFloorID;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 綁定dgvClientRecord
public DataSet Binding_dgvdgvClientRecord(int intClientID)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@ClientID", SqlDbType.Int),
};
SQLCMDpas[0].Value = "Binding_dgvdgvClientRecord";
SQLCMDpas[1].Value = intClientID;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 根據房間查詢客戶
public DataSet cboRoomNumber_SelectionChangeCommitted_SelectCustomer(int intRoomResourcesID)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@RoomResourcesID", SqlDbType.Int),
};
SQLCMDpas[0].Value = "cboRoomNumber_SelectionChangeCommitted_SelectCustomer";
SQLCMDpas[1].Value = intRoomResourcesID;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
第三步:界面層(UIL)的代碼
BLL新銳房地產銷售系統.MarketManagement.frmMarketManagement_CustomerQuery.frmMarketManagement_CustomerQueryClient myfrmMarketManagement_CustomerQueryClient = new BLL新銳房地產銷售系統.MarketManagement.frmMarketManagement_CustomerQuery.frmMarketManagement_CustomerQueryClient();//實例化BLL
DataTable dtNotBuyClient = new DataTable();
DataTable dtAllCustomer = new DataTable();
private void frmMarketManagement_CustomerQuery_Load(object sender, EventArgs e)
{
DataTable dtProject = myfrmMarketManagement_CustomerQueryClient.CustomerQuery_Load_BindingdgvProject().Tables[0];
dgvProject.DataSource = dtProject;
DataTable dtHomeBuyerConsultant = myfrmMarketManagement_CustomerQueryClient.Binding_cboHomeBuyerConsultant().Tables[0];
PublicMethod.SettingComboBox(cboHomeBuyerConsultant, dtHomeBuyerConsultant, "StaffID", "HomeBuyerConsultantName");//調用自己寫的公用方法設置cbo數據源,具體調用之前的已經過,不詳說
dtNotBuyClient = myfrmMarketManagement_CustomerQueryClient.Binding_dgvNotBuyClient().Tables[0];//綁定dgv
dgvNotBuyClient.DataSource = dtNotBuyClient;
dtAllCustomer = myfrmMarketManagement_CustomerQueryClient.Binding_dgvAllCustomer().Tables[0];
dgvAllCustomer.DataSource = dtAllCustomer;//綁定dgv
}
private void btnSelectProject_Click(object sender, EventArgs e)
{
dgvProject.Size =new Size(266, 125);//設定dgv的大小
dgvProject.Visible = true;//設置dgv的可見性
}
private void dgvProject_MouseLeave(object sender, EventArgs e)
{
dgvProject.Visible = false;
}
int intProjectID = 0;//聲明全局變量
private void dgvProject_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)//dgv雙擊綁定客戶
{
intProjectID = (int)dgvProject.CurrentRow.Cells["ProjectID"].Value;
txtProjectName.Text = dgvProject.CurrentRow.Cells["項目名稱"].Value.ToString().Trim();//綁定項目文本框
dgvProject.Visible = false;
DataTable dtFloor = myfrmMarketManagement_CustomerQueryClient.dgvProject_CellMouseDoubleClick_BindingcboFloor(intProjectID).Tables[0];
PublicMethod.SettingComboBox(cboBuildingNumber, dtFloor, "FloorID", "FloorName");
int intFloorID = (int)cboBuildingNumber.SelectedValue;
DataTable dtRoomResource = myfrmMarketManagement_CustomerQueryClient.cboBuildingNumber_SelectionChangeCommitted_BindingcboRoomResource(intFloorID).Tables[0];
PublicMethod.SettingComboBox(cboRoomNumber, dtRoomResource, "RoomResourcesID", "Number");
}
private void cboBuildingNumber_SelectionChangeCommitted(object sender, EventArgs e)
{
int intFloorID = (int)cboBuildingNumber.SelectedValue;//獲取cbo樓棟選定的值
DataTable dtRoomResource = myfrmMarketManagement_CustomerQueryClient.cboBuildingNumber_SelectionChangeCommitted_BindingcboRoomResource(intFloorID).Tables[0];
PublicMethod.SettingComboBox(cboRoomNumber, dtRoomResource, "RoomResourcesID", "Number");//根據cbo樓棟選定的值查出一張表,再綁定到cbo房間號
}
private void cboRoomNumber_SelectionChangeCommitted(object sender, EventArgs e)
{
txtCientNameAndPhone.Text = "";
int intRoomResourceID = (int)cboRoomNumber.SelectedValue;
DataTable dtCustomer = myfrmMarketManagement_CustomerQueryClient.cboRoomNumber_SelectionChangeCommitted_SelectCustomer(intRoomResourceID).Tables[0];//根據選定的房間來查詢客戶
if (dtCustomer.Rows.Count > 0)
{
int intCustomerID = (int)dtCustomer.Rows[0]["ClientID"];
txtUnitNumber.Text = cboRoomNumber.Text.ToString();
txtContactPhoneNumber.Text = dtCustomer.Rows[0]["RelationPhone"].ToString().Trim();
txtHomeBuyerConsultant.Text = dtCustomer.Rows[0]["HomeBuyerConsultantName"].ToString().Trim();
DataTable dtClientRecord = myfrmMarketManagement_CustomerQueryClient.Binding_dgvdgvClientRecord(intCustomerID).Tables[0];//根據選定的客戶來綁定客戶記錄
dgvClientRecord.DataSource = dtClientRecord;
}
}
private void txtProjectName_TextChanged(object sender, EventArgs e)//當文本框的文本改變時候發生
{
string strProjectName=txtProjectName.Text.ToString().Trim();
if (strProjectName == "")
{
dgvProject.Visible = false;
return;
}
}
private void txtCientNameAndPhone_KeyPress(object sender, KeyPressEventArgs e)//當文本框“客戶姓名或電話”按下且放開一個鍵時發生
{
if (e.KeyChar == (char)Keys.Enter)//當按下的那個鍵時Enter鍵時,執行幫dgv的客戶綁定,並相應查詢記錄
{
intCustomerID = (int)dgvCustomer.CurrentRow.Cells["CustomerID"].Value;
txtCientNameAndPhone.Text = dgvCustomer.CurrentRow.Cells["CustomName"].Value.ToString().Trim();
txtContactPhoneNumber.Text = dgvCustomer.CurrentRow.Cells["CustomerPhoneNumber"].Value.ToString().Trim();
txtHomeBuyerConsultant.Text = dgvCustomer.CurrentRow.Cells["HomeBuyerConsultantName"].Value.ToString().Trim();
DataTable dtClientRecord = myfrmMarketManagement_CustomerQueryClient.Binding_dgvdgvClientRecord(intCustomerID).Tables[0];//查詢客戶記錄
dgvClientRecord.DataSource = dtClientRecord;
dgvCustomer.Visible = false;
return;
}
}
private void dgvCustomer_MouseLeave(object sender, EventArgs e)//鼠標離開dgv的事件
{
dgvCustomer.Visible = false;//設置dgv可見性
}
private void txtCientNameAndPhone_Enter(object sender, EventArgs e)
{
string strCondition = txtCientNameAndPhone.Text.ToString().Trim();
DataTable dtCustomer = myfrmMarketManagement_CustomerQueryClient.btnSelect_Click_SelectAppointCustomer(strCondition).Tables[0];
dgvCustomer.DataSource = dtCustomer;
dgvCustomer.Size = new Size(266, 125);//甚至dgv的大小
dgvCustomer.Visible = true;//設置dgv 的可見性
}
int intCustomerID = 0;
private void dgvCustomer_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)//dgv雙擊綁定客戶
{
intCustomerID = (int)dgvCustomer.CurrentRow.Cells["CustomerID"].Value;
txtCientNameAndPhone.Text = dgvCustomer.CurrentRow.Cells["CustomName"].Value.ToString().Trim();
txtContactPhoneNumber.Text = dgvCustomer.CurrentRow.Cells["CustomerPhoneNumber"].Value.ToString().Trim();
txtHomeBuyerConsultant.Text = dgvCustomer.CurrentRow.Cells["HomeBuyerConsultantName"].Value.ToString().Trim();
DataTable dtClientRecord = myfrmMarketManagement_CustomerQueryClient.Binding_dgvdgvClientRecord(intCustomerID).Tables[0];
dgvClientRecord.DataSource = dtClientRecord;//綁定客戶重要事件記錄
dgvCustomer.Visible = false;
}
int intCurrentIndex = 0;
private void txtCientNameAndPhone_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 38) //當按下上鍵時
{
if (intCurrentIndex > 0)
intCurrentIndex--;
}
if (e.KeyValue == 40) //當按下下鍵時
{
if (intCurrentIndex < dgvCustomer.Rows.Count - 1)
intCurrentIndex++;
}
string strCondition = txtCientNameAndPhone.Text.ToString().Trim();
dgvCustomer.CurrentCell = dgvCustomer.Rows[intCurrentIndex].Cells[0];
}
private void txtCientNameAndPhone_TextChanged(object sender, EventArgs e)
{
string strCondition = txtCientNameAndPhone.Text.ToString().Trim();
DataTable dtCustomer = myfrmMarketManagement_CustomerQueryClient.btnSelect_Click_SelectAppointCustomer(strCondition).Tables[0];
dgvCustomer.DataSource = dtCustomer;//綁定dgv客戶
}
2.未購客戶批量查詢
從界面上可以看到我們這裏用到的控件有
控件名稱 |
說明 |
標註(Label) |
控件可以在工具箱直接拖動至窗體,拖至窗體後右擊屬性可以修改控件的樣式和各種屬性,還可以編輯事件。 |
選項卡(TabControl) |
|
複選框(CheckBox) |
|
單選按鈕(RadioButton) |
|
文本(TextBox) |
|
按鈕(Button) |
|
菜單(ToolStripMenuItem) |
|
工具欄(ToolStrip) |
|
組容器(GroupBox) |
|
表格(DataGridView) |
功能實現:
第一步:數據庫
1、表與關係
表1: 房間資源表(dbo.SYS_RoomResource)
Primary Key(主鍵): RoomResourcesID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
RoomResourcesID |
int - Identity |
|
No |
房間資源ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
TheCodeModelID |
int |
|
Yes |
屬性明細表,代碼模式ID
|
Number |
nchar (10) |
|
Yes |
編號
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
FloorStotey |
nchar (10) |
|
Yes |
樓層
|
RoomCategoryID |
int |
|
Yes |
屬性明細表,房間類別ID
|
TowardID |
int |
|
Yes |
屬性明細表,朝向ID
|
DoorModelID |
int |
|
Yes |
屬性明細表,戶型ID
|
RoomTypeID |
int |
|
Yes |
屬性明細表,房間類型ID
|
RoomLandScapeID |
int |
|
Yes |
屬性明細表,房間景觀ID
|
RoomSpecialID |
int |
|
Yes |
屬性明細表,房間特殊ID
|
ConstructionArea |
decimal (18, 2) |
|
Yes |
建築面積
|
PricateArea |
decimal (18, 2) |
|
Yes |
私有面積
|
PublicArea |
decimal (18, 2) |
|
Yes |
公攤面積
|
Usage |
decimal (18, 2) |
|
Yes |
使用率
|
TheUnitPrice |
decimal (18, 2) |
|
Yes |
標價單價
|
BidPrice |
decimal (18, 2) |
|
Yes |
標價總價
|
NumberOfPrice |
nchar (10) |
|
Yes |
價格次數
|
SalesStatusID |
int |
((102)) |
Yes |
屬性明細表,銷售狀態ID
|
BriefNote |
nchar (30) |
|
Yes |
簡要備註
|
SchematicDiagram |
image |
|
Yes |
示意圖
|
Chart |
image |
|
Yes |
效果圖
|
表2: 樓棟信息表(dbo.SYS_FloorInformation)
Primary Key(主鍵): FloorID
非主鍵ID值均是外鍵
(這裏因爲在這個表裏邊沒有設置有默認值,所以沒有默認值的那一列)
列名 |
數據類型 |
Nulls? |
說明 |
FloorID |
int - Identity |
No |
樓棟ID
|
ProjectID |
int |
Yes |
項目信息表,項目ID
|
FloorStructureID |
int |
Yes |
屬性明細表,樓棟結構ID
|
OpenBatchID |
int |
Yes |
屬性明細表,開盤批次ID
|
LaunchSituationID |
int |
Yes |
屬性明細表,推出情況ID
|
OpeningSituationID |
int |
Yes |
屬性明細表,開盤情況ID
|
FloorLevelID |
int |
Yes |
樓棟級別ID
|
SortNumber |
nchar (10) |
Yes |
序號
|
FloorName |
nchar (20) |
Yes |
樓棟名稱
|
PropertyRightFloorName |
nchar (20) |
Yes |
產權樓棟名稱
|
FloorStorey |
nchar (10) |
Yes |
樓棟層數
|
LaunchDate |
datetime |
Yes |
推出日期
|
DoMortgageDate |
datetime |
Yes |
具備辦按揭日期
|
CapsDate |
datetime |
Yes |
封頂日期
|
AccumulationFundDate |
datetime |
Yes |
具備辦公積金日期
|
ExpectedPayDate |
datetime |
Yes |
預計交房日期
|
PropertyRightDate |
datetime |
Yes |
具備辦產權日期
|
MakingRoomDate |
datetime |
Yes |
交房日期 |
表3: 項目信息表(dbo.SYS_ProjectInformation)
Primary Key(主鍵): ProjectID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ProjectID |
int - Identity |
|
No |
項目ID
|
SortNumber |
int |
|
Yes |
排序號
|
ProjectAreaID |
int |
|
Yes |
屬性明細表,項目區域ID
|
Project_FatherlID |
int |
|
Yes |
項目信息表,項目級別ID
|
ProjectName |
nchar (20) |
|
Yes |
項目名稱
|
PropertyRightProjectName |
nchar (20) |
|
Yes |
產權項目名稱
|
ProjectCompanyName |
nchar (20) |
|
Yes |
項目公司名稱
|
ProjectAddress |
nchar (50) |
|
Yes |
項目座落地址
|
CaseWhether |
bit |
|
Yes |
是否結案
|
CancelWhether |
bit |
((0)) |
Yes |
有效否
|
表4: 房源保留表(dbo.PW_RoomSelect_Keep)
Primary Key(主鍵): KeepID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
KeepID |
int - Identity |
|
No |
保留ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
RoomResourcesID |
int |
|
Yes |
房間資源ID,房間ID
|
UnitPrice |
decimal (18, 2) |
|
Yes |
單價
|
Price |
decimal (18, 2) |
|
Yes |
售價
|
KeepPeople |
int |
|
Yes |
保留人
|
Note |
nchar (300) |
|
Yes |
說明
|
StartDate |
datetime |
|
Yes |
開始時間
|
KeepTime |
nchar (10) |
|
Yes |
保留時長
|
KeepDate |
nchar (10) |
|
Yes |
保留天數
|
OperatingPerson |
int |
|
Yes |
經辦人員
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表5: 客戶信息 (dbo.PW_ClientInformation)
Primary Key(主鍵): ClientID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientID |
int - Identity |
|
No |
客戶ID
|
ProjectID |
int |
|
Yes |
項目信息表,項目ID
|
ClientNumber |
nchar (10) |
|
Yes |
客戶編號
|
ClientName |
nchar (10) |
|
Yes |
客戶名稱
|
EarlyVisitIntention |
nchar (10) |
|
Yes |
初訪意向
|
Gender |
nchar (10) |
|
Yes |
性別
|
MaritalStatus |
nchar (10) |
|
Yes |
婚否
|
ClientRegistrationWayID |
int |
|
Yes |
屬性明細表,客戶登記方式ID
|
RelationPhone |
nchar (15) |
|
Yes |
聯繫電話
|
ElectronMail |
nchar (30) |
|
Yes |
電子郵箱
|
HomeBuyerConsultantID |
int |
|
Yes |
員工表,置業顧問ID
|
DateOfVisit |
datetime |
|
Yes |
來訪日期
|
CommunicationAddress |
nchar (50) |
|
Yes |
通訊地址
|
Postcode |
nchar (10) |
|
Yes |
郵編
|
IDentityCard |
nchar (30) |
|
Yes |
身份證號
|
BirthDay |
date |
|
Yes |
出生日期
|
Age |
nchar (20) |
|
Yes |
年齡
|
Professional |
nchar (20) |
|
Yes |
職業
|
NowLivingArea |
nchar (20) |
|
Yes |
現居住區域
|
LearnTheWayToTheCase |
nchar (20) |
|
Yes |
獲取本案途徑
|
VisitConstitute |
nchar (20) |
|
Yes |
來客構成
|
Traffic |
nchar (20) |
|
Yes |
交通
|
RealEstateSituation |
nchar (20) |
|
Yes |
置業狀況
|
ResidentialMortgageLoans |
nchar (20) |
|
Yes |
住宅按揭貸款
|
HomesBuyersPurpose |
nchar (20) |
|
Yes |
置業目的
|
PlanTorealEstatePrice |
nchar (20) |
|
Yes |
計劃置業價格
|
DemandArea |
nchar (20) |
|
Yes |
需求面積
|
PaymentWay |
nchar (20) |
|
Yes |
付款方式ID
|
BuyingConsideration |
nchar (20) |
|
Yes |
買房考慮因素
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表6: 預定表 (dbo.PW_ReserveUnit)
Primary Key(主鍵): ReserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ReserveUnitID |
int - Identity |
|
No |
預訂單元ID
|
ClientID |
int |
|
Yes |
客戶表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
nchar (10) |
|
Yes |
預售面積
|
ReservationPrice |
money |
|
Yes |
預收單價
|
BookingReservationPrice |
money |
|
Yes |
預定總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
BookingDate |
datetime |
|
Yes |
預定日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
AuditDate |
date |
|
Yes |
審覈日期
|
NewReserveUnitID |
int |
|
Yes |
預定表,新預定ID
|
ChangeReason |
int |
|
Yes |
屬性明細表,變更原因ID
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表7: 預留表 (dbo. PW_SeserveUnit)
Primary Key(主鍵): SeserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SeserveUnitID |
int - Identity |
|
No |
預留單元ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
房間資源表,房間單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
decimal (18, 2) |
|
Yes |
預售面積
|
SeservationUnitPrice |
decimal (18, 2) |
|
Yes |
預留單價
|
BookingSeservationPrice |
decimal (18, 2) |
|
Yes |
預留總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
SeservatingDate |
datetime |
|
Yes |
預留日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (100) |
|
Yes |
簡要備註
|
AuditDate |
datetime |
|
Yes |
審覈日期
|
NewSeserveUnitID |
int |
|
Yes |
預留表,新的預留ID
|
ChangeReason |
int |
|
Yes |
變更原因
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表8: 認購表 (dbo. PW_SubscribeUnit)
Primary Key(主鍵): SubscribeUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SubscribeUnitID |
int - Identity |
|
No |
認購單元ID
|
SalesChangeID |
int |
|
Yes |
銷售便更表,銷售變更ID
|
SubscriptioNumber |
nchar (20) |
|
Yes |
認購單編號
|
SubscribeToDate |
datetime |
|
Yes |
認購日期
|
AnticipatedDateSigned |
datetime |
|
Yes |
預計簽約日期
|
ContractArea |
nchar (10) |
|
Yes |
合同面積
|
TypeOfPanymentID |
int |
|
Yes |
付款方式表,付款方式ID
|
PaymentDetailsOfNameID |
int |
|
Yes |
付款方式明細表,付款名稱細目ID
|
SalesAreaOfWayID |
int |
|
Yes |
屬性明細表,銷售面積方式ID
|
FsvorableDiscount |
decimal (18, 2) |
|
Yes |
優惠折扣
|
ClinchADealUnitPrice |
money |
|
Yes |
成交單價
|
ClinchADealThePrice |
money |
|
Yes |
成交總價
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
AgentID |
int |
|
Yes |
員工表,經辦人ID
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
ReviewWhether |
bit |
((0)) |
Yes |
審覈否
|
CancelWhether |
bit |
((0)) |
Yes |
作廢否
|
ChangeOfAuditStatusID |
int |
|
Yes |
屬性明細表,變更審覈狀態ID
|
RoomResourcesID |
int |
|
Yes |
房間資源表,房源ID
|
AfterUpdateID |
int |
|
Yes |
認購表,修改後的認購ID
|
表9: 認籌表 (dbo. PW_ClientConfessToRaise)
Primary Key(主鍵): ClientConfessToRaiseID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientConfessToRaiseID |
int - Identity |
|
No |
客戶認籌ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
RaiseNumeralRecognition |
nchar (10) |
|
Yes |
認籌排號
|
TheOrderNumber |
nchar (10) |
|
Yes |
訂單號
|
ConfessToRaiseClassificationID |
int |
|
Yes |
屬性明細表,籌卡分類ID
|
AccountsReceivableAppointmentGold |
money |
|
Yes |
應收預約金
|
ConfesstoraiseDate |
datetime |
|
Yes |
認籌日期
|
EffectiveDate |
datetime |
|
Yes |
有效日期
|
IntentionUnitInstructions |
nchar (10) |
|
Yes |
意向單元說明
|
Note |
nchar (30) |
|
Yes |
備註
|
ToSeserve |
bit |
((0)) |
Yes |
轉預留否
|
SeserveID |
int |
|
Yes |
預留表,預留ID
|
AuditWhether |
bit |
((0)) |
Yes |
審覈否
|
IncalidWhether |
bit |
((0)) |
Yes |
作廢否
|
AfterUpdateID |
int |
|
Yes |
認籌表,修改後ID
|
表10: 員工表 (dbo. SYS_Staff)
Primary Key(主鍵): StaffID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
StaffID |
int - Identity |
No |
員工ID
|
StaffNumber |
nchar (10) |
Yes |
員工編號
|
StaffName |
nchar (10) |
Yes |
員工姓名
|
DepartMentID |
int |
Yes |
所屬部門
|
GenderID |
int |
Yes |
屬性明細表,性別ID
|
Age |
int |
Yes |
年齡
|
EducationBackgroundID |
int |
Yes |
屬性明細表,學歷ID
|
MarryWhether |
bit |
Yes |
婚否
|
Position |
nchar (10) |
Yes |
職位
|
ContactPhoneNumber |
nchar (15) |
Yes |
聯繫電話
|
ContactAddress |
nchar (20) |
Yes |
聯繫地址
|
Notes |
nchar (100) |
Yes |
備註
|
StaffImage |
image |
Yes |
員工照片
|
2、具體代碼實現
第一步:數據庫存儲過程
if @Type='Binding_dgvNotBuyClient'--查詢未購客戶
begin
with CTE as (
SELECT rtrim(PW_ClientInformation.ClientName) as ClientName, PW_ClientInformation.ClientID, rtrim(PW_ClientInformation.RelationPhone) as RelationPhone, PW_ClientInformation.HomeBuyerConsultantID,
rtrim(SYS_Staff.StaffName) AS HomeBuyerConsultantName, rtrim(PW_ClientInformation.EarlyVisitIntention) as EarlyVisitIntention, rtrim(PW_ClientInformation.Gender) as Gender, rtrim(PW_ClientInformation.MaritalStatus) as MaritalStatus,
PW_ClientInformation.ClientRegistrationWayID, rtrim(SYS_AttributeDetails.AuttributeDetailsName) AS ClientRegistrationWay, rtrim(PW_ClientInformation.ElectronMail) as ElectronMail, PW_ClientInformation.DateOfVisit,
rtrim(PW_ClientInformation.CommunicationAddress) as CommunicationAddress, rtrim(PW_ClientInformation.Postcode) as Postcode, rtrim(PW_ClientInformation.IDentityCard) as IDentityCard, PW_ClientInformation.BirthDay, rtrim(PW_ClientInformation.Age) as Age,
rtrim(PW_ClientInformation.Professional) as Professional, rtrim(PW_ClientInformation.NowLivingArea) as NowLivingArea, rtrim(PW_ClientInformation.LearnTheWayToTheCase) as LearnTheWayToTheCase, rtrim(PW_ClientInformation.VisitConstitute) as VisitConstitute, rtrim(PW_ClientInformation.Traffic) as Traffic,
rtrim(PW_ClientInformation.RealEstateSituation) as RealEstateSituation, rtrim(PW_ClientInformation.ResidentialMortgageLoans) as ResidentialMortgageLoans, rtrim(PW_ClientInformation.HomesBuyersPurpose) as HomesBuyersPurpose, rtrim(PW_ClientInformation.PlanTorealEstatePrice) as PlanTorealEstatePrice,
rtrim(PW_ClientInformation.DemandArea) as DemandArea, rtrim(PW_ClientInformation.PaymentWay) as PaymentWay, rtrim(PW_ClientInformation.BuyingConsideration) as BuyingConsideration
FROM PW_ClientInformation INNER JOIN
SYS_Staff ON PW_ClientInformation.HomeBuyerConsultantID = SYS_Staff.StaffID INNER JOIN
SYS_AttributeDetails ON PW_ClientInformation.ClientRegistrationWayID = SYS_AttributeDetails.AttributeDetailsID
where (PW_ClientInformation.ClientID not in(SELECT ClientID
FROM PW_ClientConfessToRaise where PW_ClientConfessToRaise.IncalidWhether=0)
and PW_ClientInformation.ClientID not in(SELECT ClientID
FROM PW_ReserveUnit where PW_ReserveUnit.IncalidOr=0 )
and PW_ClientInformation.ClientID not in(SELECT ClientID
FROM PW_SeserveUnit where PW_SeserveUnit.IncalidOr=0 )
and PW_ClientInformation.ClientID not in(SELECT KeepPeople
FROM PW_RoomSelect_Keep
where PW_RoomSelect_Keep.IncalidOr=0))and PW_ClientInformation.IncalidOr=0 )
SELECT CTE.*
FROM CTE
end
if @Type='Binding_cboHomeBuyerConsultant'--綁定置業顧問
begin
SELECT StaffID, rtrim(StaffName) as HomeBuyerConsultantName
FROM SYS_Staff
end
第二步:邏輯層(BLL)具體代碼解釋
[OperationContract]
#region 綁定未購客戶
public DataSet Binding_dgvNotBuyClient()
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
};
SQLCMDpas[0].Value = "Binding_dgvNotBuyClient";
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 綁定cbo置業顧問
public DataSet Binding_cboHomeBuyerConsultant()
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
};
SQLCMDpas[0].Value = "Binding_cboHomeBuyerConsultant";
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
第三步:界面層(UIL)具體事件代碼
string strCondition = " 1=1 ";
string strConditionHomeBuyerConsultant = "";
private void cboHomeBuyerConsultant_SelectionChangeCommitted(object sender, EventArgs e)
{
int intHomeBuyerConsultantID = (int)cboHomeBuyerConsultant.SelectedValue;
strConditionHomeBuyerConsultant = " and HomeBuyerConsultantID=" + intHomeBuyerConsultantID;
MultiConditionSelect(strCondition + strConditionHomeBuyerConsultant + strConditionGender);
}
string strConditionGender = "";
private void pub_Gender_Click(object sender, EventArgs e)
{
RadioButton radPub = sender as RadioButton;
if (radAllGender.Checked)//根據複選框是否選定來字符串拼接
{
strConditionGender = "";
MultiConditionSelect(strCondition + strConditionHomeBuyerConsultant + strConditionGender);
}
if (radFemale.Checked)
{
strConditionGender = " and Gender ='女'";//拼接條件
MultiConditionSelect(strCondition + strConditionHomeBuyerConsultant + strConditionGender);
}
if (radMale.Checked)
{
strConditionGender = " and Gender ='男'";
MultiConditionSelect(strCondition + strConditionHomeBuyerConsultant + strConditionGender);
}
}
/// <summary>
/// 不定條件查詢
/// </summary>
/// <param name="strConditionOfSelect">條件</param>
void MultiConditionSelect(string strConditionOfSelect)
{
DataView dv = new DataView(dtNotBuyClient);
dv.RowFilter = strConditionOfSelect;
DataTable dt = dv.ToTable();
dgvNotBuyClient.DataSource = dt;
}
private void Pub_rad_ES_Click(object sender, EventArgs e)//公用的單選框點擊事件
{
txtCustomerNameOrTelephone.Text = "";
string strCondition = "";
if (radAll_ES.Checked)
{
strCondition = "";
}
if (radMale_ES.Checked)
{
strCondition = " Gender ='男'";
}
if (radFemale_ES.Checked)
{
strCondition = " Gender ='女'";
}
DataView dv = new DataView(dtAllCustomer);
dv.RowFilter = strCondition;//過濾數據
DataTable dt = dv.ToTable();
dgvAllCustomer.DataSource = dt;
}
3.客戶交往批量查詢
從界面上可以看到我們這裏用到的控件有
控件名稱 |
說明 |
標註(Label) |
控件可以在工具箱直接拖動至窗體,拖至窗體後右擊屬性可以修改控件的樣式和各種屬性,還可以編輯事件。 |
選項卡(TabControl) |
|
下拉框(ComboBox) |
|
文本(TextBox) |
|
按鈕(Button) |
|
菜單(ToolStripMenuItem) |
|
工具欄(ToolStrip) |
|
單選按鈕(RadioButton) |
|
組容器(GroupBox) |
|
表格(DataGridView) |
功能實現:
第一步:數據庫
1、表與關係
表1: 房間資源表(dbo.SYS_RoomResource)
Primary Key(主鍵): RoomResourcesID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
RoomResourcesID |
int - Identity |
|
No |
房間資源ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
TheCodeModelID |
int |
|
Yes |
屬性明細表,代碼模式ID
|
Number |
nchar (10) |
|
Yes |
編號
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
FloorStotey |
nchar (10) |
|
Yes |
樓層
|
RoomCategoryID |
int |
|
Yes |
屬性明細表,房間類別ID
|
TowardID |
int |
|
Yes |
屬性明細表,朝向ID
|
DoorModelID |
int |
|
Yes |
屬性明細表,戶型ID
|
RoomTypeID |
int |
|
Yes |
屬性明細表,房間類型ID
|
RoomLandScapeID |
int |
|
Yes |
屬性明細表,房間景觀ID
|
RoomSpecialID |
int |
|
Yes |
屬性明細表,房間特殊ID
|
ConstructionArea |
decimal (18, 2) |
|
Yes |
建築面積
|
PricateArea |
decimal (18, 2) |
|
Yes |
私有面積
|
PublicArea |
decimal (18, 2) |
|
Yes |
公攤面積
|
Usage |
decimal (18, 2) |
|
Yes |
使用率
|
TheUnitPrice |
decimal (18, 2) |
|
Yes |
標價單價
|
BidPrice |
decimal (18, 2) |
|
Yes |
標價總價
|
NumberOfPrice |
nchar (10) |
|
Yes |
價格次數
|
SalesStatusID |
int |
((102)) |
Yes |
屬性明細表,銷售狀態ID
|
BriefNote |
nchar (30) |
|
Yes |
簡要備註
|
SchematicDiagram |
image |
|
Yes |
示意圖
|
Chart |
image |
|
Yes |
效果圖
|
表2: 樓棟信息表(dbo.SYS_FloorInformation)
Primary Key(主鍵): FloorID
非主鍵ID值均是外鍵
(這裏因爲在這個表裏邊沒有設置有默認值,所以沒有默認值的那一列)
列名 |
數據類型 |
Nulls? |
說明 |
FloorID |
int - Identity |
No |
樓棟ID
|
ProjectID |
int |
Yes |
項目信息表,項目ID
|
FloorStructureID |
int |
Yes |
屬性明細表,樓棟結構ID
|
OpenBatchID |
int |
Yes |
屬性明細表,開盤批次ID
|
LaunchSituationID |
int |
Yes |
屬性明細表,推出情況ID
|
OpeningSituationID |
int |
Yes |
屬性明細表,開盤情況ID
|
FloorLevelID |
int |
Yes |
樓棟級別ID
|
SortNumber |
nchar (10) |
Yes |
序號
|
FloorName |
nchar (20) |
Yes |
樓棟名稱
|
PropertyRightFloorName |
nchar (20) |
Yes |
產權樓棟名稱
|
FloorStorey |
nchar (10) |
Yes |
樓棟層數
|
LaunchDate |
datetime |
Yes |
推出日期
|
DoMortgageDate |
datetime |
Yes |
具備辦按揭日期
|
CapsDate |
datetime |
Yes |
封頂日期
|
AccumulationFundDate |
datetime |
Yes |
具備辦公積金日期
|
ExpectedPayDate |
datetime |
Yes |
預計交房日期
|
PropertyRightDate |
datetime |
Yes |
具備辦產權日期
|
MakingRoomDate |
datetime |
Yes |
交房日期 |
表3: 項目信息表(dbo.SYS_ProjectInformation)
Primary Key(主鍵): ProjectID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ProjectID |
int - Identity |
|
No |
項目ID
|
SortNumber |
int |
|
Yes |
排序號
|
ProjectAreaID |
int |
|
Yes |
屬性明細表,項目區域ID
|
Project_FatherlID |
int |
|
Yes |
項目信息表,項目級別ID
|
ProjectName |
nchar (20) |
|
Yes |
項目名稱
|
PropertyRightProjectName |
nchar (20) |
|
Yes |
產權項目名稱
|
ProjectCompanyName |
nchar (20) |
|
Yes |
項目公司名稱
|
ProjectAddress |
nchar (50) |
|
Yes |
項目座落地址
|
CaseWhether |
bit |
|
Yes |
是否結案
|
CancelWhether |
bit |
((0)) |
Yes |
有效否
|
表4: 房源保留表(dbo.PW_RoomSelect_Keep)
Primary Key(主鍵): KeepID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
KeepID |
int - Identity |
|
No |
保留ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
RoomResourcesID |
int |
|
Yes |
房間資源ID,房間ID
|
UnitPrice |
decimal (18, 2) |
|
Yes |
單價
|
Price |
decimal (18, 2) |
|
Yes |
售價
|
KeepPeople |
int |
|
Yes |
保留人
|
Note |
nchar (300) |
|
Yes |
說明
|
StartDate |
datetime |
|
Yes |
開始時間
|
KeepTime |
nchar (10) |
|
Yes |
保留時長
|
KeepDate |
nchar (10) |
|
Yes |
保留天數
|
OperatingPerson |
int |
|
Yes |
經辦人員
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表5: 客戶信息 (dbo.PW_ClientInformation)
Primary Key(主鍵): ClientID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientID |
int - Identity |
|
No |
客戶ID
|
ProjectID |
int |
|
Yes |
項目信息表,項目ID
|
ClientNumber |
nchar (10) |
|
Yes |
客戶編號
|
ClientName |
nchar (10) |
|
Yes |
客戶名稱
|
EarlyVisitIntention |
nchar (10) |
|
Yes |
初訪意向
|
Gender |
nchar (10) |
|
Yes |
性別
|
MaritalStatus |
nchar (10) |
|
Yes |
婚否
|
ClientRegistrationWayID |
int |
|
Yes |
屬性明細表,客戶登記方式ID
|
RelationPhone |
nchar (15) |
|
Yes |
聯繫電話
|
ElectronMail |
nchar (30) |
|
Yes |
電子郵箱
|
HomeBuyerConsultantID |
int |
|
Yes |
員工表,置業顧問ID
|
DateOfVisit |
datetime |
|
Yes |
來訪日期
|
CommunicationAddress |
nchar (50) |
|
Yes |
通訊地址
|
Postcode |
nchar (10) |
|
Yes |
郵編
|
IDentityCard |
nchar (30) |
|
Yes |
身份證號
|
BirthDay |
date |
|
Yes |
出生日期
|
Age |
nchar (20) |
|
Yes |
年齡
|
Professional |
nchar (20) |
|
Yes |
職業
|
NowLivingArea |
nchar (20) |
|
Yes |
現居住區域
|
LearnTheWayToTheCase |
nchar (20) |
|
Yes |
獲取本案途徑
|
VisitConstitute |
nchar (20) |
|
Yes |
來客構成
|
Traffic |
nchar (20) |
|
Yes |
交通
|
RealEstateSituation |
nchar (20) |
|
Yes |
置業狀況
|
ResidentialMortgageLoans |
nchar (20) |
|
Yes |
住宅按揭貸款
|
HomesBuyersPurpose |
nchar (20) |
|
Yes |
置業目的
|
PlanTorealEstatePrice |
nchar (20) |
|
Yes |
計劃置業價格
|
DemandArea |
nchar (20) |
|
Yes |
需求面積
|
PaymentWay |
nchar (20) |
|
Yes |
付款方式ID
|
BuyingConsideration |
nchar (20) |
|
Yes |
買房考慮因素
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表6: 客戶事件記錄表 (dbo.PW_ClientEventRecord)
Primary Key(主鍵): EventRecordID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
EventRecordID |
int - Identity |
No |
事件記錄ID
|
ClientID |
int |
Yes |
客戶信息表,客戶ID
|
RecordDate |
datetime |
Yes |
記錄日期
|
Characteristic |
nchar (200) |
Yes |
特徵
|
explain |
nchar (200) |
Yes |
說明
|
表7: 客戶交往明細表 (dbo.PW_ClientContractDetails)
Primary Key(主鍵): ClientContractDetailsID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
ClientContractDetailsID |
int - Identity |
No |
客戶交往明細ID
|
ProjectID |
int |
Yes |
項目信息表,項目ID
|
ClientID |
int |
Yes |
客戶表,客戶ID
|
ContractTime |
datetime |
Yes |
交往時間
|
DegreeOfInterest |
char (10) |
Yes |
意向程度
|
InteractionsID |
int |
Yes |
屬性明細表,交往方式ID
|
VisitFormID |
int |
Yes |
屬性明細表,來訪形態ID
|
HomeBuyerConsultantID |
int |
Yes |
員工表,置業顧問ID
|
RecommendedHousingID |
int |
Yes |
房間資源表,推薦房源ID
|
CommunicationContent |
nchar (30) |
Yes |
交往內容
|
表8: 預定表 (dbo.PW_ReserveUnit)
Primary Key(主鍵): ReserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ReserveUnitID |
int - Identity |
|
No |
預訂單元ID
|
ClientID |
int |
|
Yes |
客戶表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
單元表,單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
nchar (10) |
|
Yes |
預售面積
|
ReservationPrice |
money |
|
Yes |
預收單價
|
BookingReservationPrice |
money |
|
Yes |
預定總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
BookingDate |
datetime |
|
Yes |
預定日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
AuditDate |
date |
|
Yes |
審覈日期
|
NewReserveUnitID |
int |
|
Yes |
預定表,新預定ID
|
ChangeReason |
int |
|
Yes |
屬性明細表,變更原因ID
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表9: 保留表 (dbo. PW_RoomSelect_Keep)
Primary Key(主鍵): KeepID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
KeepID |
int - Identity |
|
No |
保留ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
RoomResourcesID |
int |
|
Yes |
房間資源表,房間ID
|
UnitPrice |
decimal (18, 2) |
|
Yes |
單價
|
Price |
decimal (18, 2) |
|
Yes |
售價
|
KeepPeople |
int |
|
Yes |
保留人
|
Note |
nchar (300) |
|
Yes |
說明
|
StartDate |
datetime |
|
Yes |
開始時間
|
KeepTime |
nchar (10) |
|
Yes |
保留時長
|
KeepDate |
nchar (10) |
|
Yes |
保留天數
|
OperatingPerson |
int |
|
Yes |
經辦人員
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表10: 預留表 (dbo. PW_SeserveUnit)
Primary Key(主鍵): SeserveUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SeserveUnitID |
int - Identity |
|
No |
預留單元ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
FloorID |
int |
|
Yes |
樓棟信息表,樓棟ID
|
UnitNumberID |
int |
|
Yes |
房間資源表,房間單元ID
|
RoomNumeral |
nchar (10) |
|
Yes |
房間排號
|
PresalseArea |
decimal (18, 2) |
|
Yes |
預售面積
|
SeservationUnitPrice |
decimal (18, 2) |
|
Yes |
預留單價
|
BookingSeservationPrice |
decimal (18, 2) |
|
Yes |
預留總價
|
AccountsReceivableBookingGoid |
money |
|
Yes |
應收預約金
|
SeservatingDate |
datetime |
|
Yes |
預留日期
|
ValidDate |
datetime |
|
Yes |
有效日期
|
BriefNote |
nchar (100) |
|
Yes |
簡要備註
|
AuditDate |
datetime |
|
Yes |
審覈日期
|
NewSeserveUnitID |
int |
|
Yes |
預留表,新的預留ID
|
ChangeReason |
int |
|
Yes |
變更原因
|
IncalidOr |
bit |
((0)) |
Yes |
作廢否
|
表11: 認購表 (dbo. PW_SubscribeUnit)
Primary Key(主鍵): SubscribeUnitID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
SubscribeUnitID |
int - Identity |
|
No |
認購單元ID
|
SalesChangeID |
int |
|
Yes |
銷售便更表,銷售變更ID
|
SubscriptioNumber |
nchar (20) |
|
Yes |
認購單編號
|
SubscribeToDate |
datetime |
|
Yes |
認購日期
|
AnticipatedDateSigned |
datetime |
|
Yes |
預計簽約日期
|
ContractArea |
nchar (10) |
|
Yes |
合同面積
|
TypeOfPanymentID |
int |
|
Yes |
付款方式表,付款方式ID
|
PaymentDetailsOfNameID |
int |
|
Yes |
付款方式明細表,付款名稱細目ID
|
SalesAreaOfWayID |
int |
|
Yes |
屬性明細表,銷售面積方式ID
|
FsvorableDiscount |
decimal (18, 2) |
|
Yes |
優惠折扣
|
ClinchADealUnitPrice |
money |
|
Yes |
成交單價
|
ClinchADealThePrice |
money |
|
Yes |
成交總價
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
AgentID |
int |
|
Yes |
員工表,經辦人ID
|
BriefNote |
nchar (20) |
|
Yes |
簡要備註
|
ReviewWhether |
bit |
((0)) |
Yes |
審覈否
|
CancelWhether |
bit |
((0)) |
Yes |
作廢否
|
ChangeOfAuditStatusID |
int |
|
Yes |
屬性明細表,變更審覈狀態ID
|
RoomResourcesID |
int |
|
Yes |
房間資源表,房源ID
|
AfterUpdateID |
int |
|
Yes |
認購表,修改後的認購ID
|
表12: 認籌表 (dbo. PW_ClientConfessToRaise)
Primary Key(主鍵): ClientConfessToRaiseID
非主鍵ID值均是外鍵
列名 |
數據類型 |
默認值 |
Nulls? |
說明 |
ClientConfessToRaiseID |
int - Identity |
|
No |
客戶認籌ID
|
ClientID |
int |
|
Yes |
客戶信息表,客戶ID
|
RaiseNumeralRecognition |
nchar (10) |
|
Yes |
認籌排號
|
TheOrderNumber |
nchar (10) |
|
Yes |
訂單號
|
ConfessToRaiseClassificationID |
int |
|
Yes |
屬性明細表,籌卡分類ID
|
AccountsReceivableAppointmentGold |
money |
|
Yes |
應收預約金
|
ConfesstoraiseDate |
datetime |
|
Yes |
認籌日期
|
EffectiveDate |
datetime |
|
Yes |
有效日期
|
IntentionUnitInstructions |
nchar (10) |
|
Yes |
意向單元說明
|
Note |
nchar (30) |
|
Yes |
備註
|
ToSeserve |
bit |
((0)) |
Yes |
轉預留否
|
SeserveID |
int |
|
Yes |
預留表,預留ID
|
AuditWhether |
bit |
((0)) |
Yes |
審覈否
|
IncalidWhether |
bit |
((0)) |
Yes |
作廢否
|
AfterUpdateID |
int |
|
Yes |
認籌表,修改後ID
|
表13: 員工表 (dbo. SYS_Staff)
Primary Key(主鍵): StaffID
非主鍵ID值均是外鍵
列名 |
數據類型 |
Nulls? |
說明 |
StaffID |
int - Identity |
No |
員工ID
|
StaffNumber |
nchar (10) |
Yes |
員工編號
|
StaffName |
nchar (10) |
Yes |
員工姓名
|
DepartMentID |
int |
Yes |
所屬部門
|
GenderID |
int |
Yes |
屬性明細表,性別ID
|
Age |
int |
Yes |
年齡
|
EducationBackgroundID |
int |
Yes |
屬性明細表,學歷ID
|
MarryWhether |
bit |
Yes |
婚否
|
Position |
nchar (10) |
Yes |
職位
|
ContactPhoneNumber |
nchar (15) |
Yes |
聯繫電話
|
ContactAddress |
nchar (20) |
Yes |
聯繫地址
|
Notes |
nchar (100) |
Yes |
備註
|
StaffImage |
image |
Yes |
員工照片
|
2、具體代碼實現
第一步:數據庫存儲過程
if @Type='Binding_dgvAllCustomer'--查詢所有客戶
begin
SELECT rtrim(PW_ClientInformation.ClientName) as ClientName, PW_ClientInformation.ClientID, rtrim(PW_ClientInformation.RelationPhone) as RelationPhone, PW_ClientInformation.HomeBuyerConsultantID,
rtrim(SYS_Staff.StaffName) AS HomeBuyerConsultantName, rtrim(PW_ClientInformation.EarlyVisitIntention) as EarlyVisitIntention, rtrim(PW_ClientInformation.Gender) as Gender, rtrim(PW_ClientInformation.MaritalStatus) as MaritalStatus,
PW_ClientInformation.ClientRegistrationWayID, rtrim(SYS_AttributeDetails.AuttributeDetailsName) AS ClientRegistrationWay, rtrim(PW_ClientInformation.ElectronMail) as ElectronMail, PW_ClientInformation.DateOfVisit,
rtrim(PW_ClientInformation.CommunicationAddress) as CommunicationAddress, rtrim(PW_ClientInformation.Postcode) as Postcode, rtrim(PW_ClientInformation.IDentityCard) as IDentityCard, PW_ClientInformation.BirthDay, rtrim(PW_ClientInformation.Age) as Age,
rtrim(PW_ClientInformation.Professional) as Professional, rtrim(PW_ClientInformation.NowLivingArea) as NowLivingArea, rtrim(PW_ClientInformation.LearnTheWayToTheCase) as LearnTheWayToTheCase, rtrim(PW_ClientInformation.VisitConstitute) as VisitConstitute, rtrim(PW_ClientInformation.Traffic) as Traffic,
rtrim(PW_ClientInformation.RealEstateSituation) as RealEstateSituation, rtrim(PW_ClientInformation.ResidentialMortgageLoans) as ResidentialMortgageLoans, rtrim(PW_ClientInformation.HomesBuyersPurpose) as HomesBuyersPurpose, rtrim(PW_ClientInformation.PlanTorealEstatePrice) as PlanTorealEstatePrice,
rtrim(PW_ClientInformation.DemandArea) as DemandArea, rtrim(PW_ClientInformation.PaymentWay) as PaymentWay, rtrim(PW_ClientInformation.BuyingConsideration) as BuyingConsideration
FROM PW_ClientInformation INNER JOIN
SYS_Staff ON PW_ClientInformation.HomeBuyerConsultantID = SYS_Staff.StaffID INNER JOIN
SYS_AttributeDetails ON PW_ClientInformation.ClientRegistrationWayID = SYS_AttributeDetails.AttributeDetailsID
where PW_ClientInformation.IncalidOr=0
end
if @Type='dgvAllCustomer_CellMouseClick_BindingdgvClientHistoryRecord'--根據客戶查詢相關交往的信息
begin
SELECT RTRIM(SYS_AttributeDetails_1.AuttributeDetailsName) AS 交往方式, RTRIM(SYS_AttributeDetails.AuttributeDetailsName) AS 來訪形態,
PW_ClientContractDetails.ClientContractDetailsID, PW_ClientContractDetails.ClientID, PW_ClientContractDetails.ContractTime
AS 交往日期, RTRIM(PW_ClientContractDetails.DegreeOfInterest) AS 意向程度, PW_ClientContractDetails.InteractionsID,
PW_ClientContractDetails.VisitFormID, PW_ClientContractDetails.HomeBuyerConsultantID,
PW_ClientContractDetails.RecommendedHousing, RTRIM(PW_ClientContractDetails.CommunicationContent) AS 交往內容, RTRIM(SYS_Staff.StaffName) as 置業顧問
FROM PW_ClientContractDetails INNER JOIN
SYS_AttributeDetails AS SYS_AttributeDetails_1 ON PW_ClientContractDetails.InteractionsID = SYS_AttributeDetails_1.AttributeDetailsID INNER JOIN
SYS_AttributeDetails ON PW_ClientContractDetails.VisitFormID = SYS_AttributeDetails.AttributeDetailsID INNER JOIN
SYS_Staff ON PW_ClientContractDetails.HomeBuyerConsultantID = SYS_Staff.StaffID
where PW_ClientContractDetails.ClientID = @ClientID
end
第二步:邏輯層(BLL)
[OperationContract]
#region 綁定dgvAllCustomer
public DataSet Binding_dgvAllCustomer()
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
};
SQLCMDpas[0].Value = "Binding_dgvAllCustomer";
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
[OperationContract]
#region 條件綁定dgvClientHistoryRecord
public DataSet dgvAllCustomer_CellMouseClick_BindingdgvClientHistoryRecord(int intClientID)
{
SqlParameter[] SQLCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@ClientID", SqlDbType.Int),
};
SQLCMDpas[0].Value = "dgvAllCustomer_CellMouseClick_BindingdgvClientHistoryRecord";
SQLCMDpas[1].Value = intClientID;
DataTable myDataTable = myDALPublic.DAL_SelectDB_Par("frmMarketManagement_CustomerQuery", SQLCMDpas);
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add(myDataTable);
return myDataSet;
}
#endregion
第三步:界面層(UIL)的代碼
private void dgvAllCustomer_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)//雙擊選擇客戶
{
int intClientID = (int)dgvAllCustomer.CurrentRow.Cells["客戶ID_All"].Value;
DataTable dtClientRecord = myfrmMarketManagement_CustomerQueryClient.dgvAllCustomer_CellMouseClick_BindingdgvClientHistoryRecord(intClientID).Tables[0];
dgvClientHistoryRecord.DataSource = dtClientRecord;
}
private void txtCustomerNameOrTelephone_TextChanged(object sender, EventArgs e)//通過客戶名稱或者電話號碼精確查詢
{
string strtxtCustomerNameOrTelephone = txtCustomerNameOrTelephone.Text.ToString().Trim();
if (strtxtCustomerNameOrTelephone != "")
{
radAll_ES.Checked = true;
}
string strCondition = " ClientName like '%" + strtxtCustomerNameOrTelephone + "%' or RelationPhone like '%" + strtxtCustomerNameOrTelephone + "%'";//字符串拼接過濾條件
DataView dv = new DataView(dtAllCustomer);
dv.RowFilter = strCondition;//實現過濾
DataTable dt = dv.ToTable();
dgvAllCustomer.DataSource = dt;//綁定過濾後的信息
}
private void Pub_rad_ES_Click(object sender, EventArgs e)//公用的單選框點擊事件
{
txtCustomerNameOrTelephone.Text = "";
string strCondition = "";
if (radAll_ES.Checked)
{
strCondition = "";
}
if (radMale_ES.Checked)
{
strCondition = " Gender ='男'";
}
if (radFemale_ES.Checked)
{
strCondition = " Gender ='女'";
}
DataView dv = new DataView(dtAllCustomer);
dv.RowFilter = strCondition;//過濾數據
DataTable dt = dv.ToTable();
dgvAllCustomer.DataSource = dt;
}