预约修改
修改预约单功能实现修改相对应的信息的功能。
从界面上可以看到的控件与新增界面的相同:
空间名称 | 说明 |
文本框(TextBox) | 控件可以在工具箱直接拖动至窗体,拖至窗体后右击属性可以修改控件的样式和各种属性,还可以编辑事件。 |
日期控件(DataTimepPicker) | |
(NumericUpDown) | |
下拉框(ComboBox) | |
复选框(CheckBox) | |
表格(DataGridView) | |
选项卡(TabControl) | |
按钮(Button) | |
(ToolStrip) |
1、数据库功能实现
第一步:数据库
1、表和关系
表1:预约单表(PW_BespeakBillList)
列名 | 数据类型 | 主键/外键 | 说明 |
BespeakBillID | int - Identity | 主键 | 预约单ID |
BespeakOddNumBer | nchar (20) | 预约单号 | |
CarNewsID | int | 外键 | 车辆信息表,车辆信息ID |
BespeakTime | datetime | 预约时间 | |
AttributeMinuteID_BespeakWay | int | 外键 | 属性明细表,属性明细ID_预约方式 |
BespeakMileage | decimal (18, 2) | 预约里程 | |
BespeakStatus | nchar (20) | 预约状态 | |
Gross | decimal (18, 2) | 总计金额 | |
FailCause | nchar (100) | 失败原因 | |
StaffID_HearPersons | int | 外键 | 员工档案表,员工ID_受理人 |
StaffID_Receiver | int | 外键 | 员工档案表,员工ID_接待人 |
LastTimeInTheFactory | nchar (20) | 上次进厂时间 | |
IfBespeakSucceed | bit | 预约成功否 | |
StaffID_AlterationPerson | nchar (20) | 外键 | 员工档案表,员工ID_变更人 |
BookingCarDeliveryTime | nchar (20) | 预约交车时间 | |
BespeakWarnTime | nchar (20) | 预约提醒时间 | |
ServiceOddNumber | nchar (20) | 外键 | 维修单表,维修单号 |
NewBespeakOddlNumber | nchar (20) | 新预约单号 | |
OldBespeakOddNumber | nchar (20) | 旧预约单号 | |
AlterationTime | nchar (20) | 变更时间 | |
AlterationCauses | nchar (100) | 变更原因 | |
ClientDescribe | nchar (100) | 客户描述 | |
Remarks | nchar (100) | 备注 | |
IfResourceRelease | bit | 资源释放否 |
表2:预约配件表(BespeakPartsList)
列名 | 数据类型 | 主键/外键 | 说明 |
BespeakPartsID | int | 主键 | 预约配件ID |
BespeakBillID | int | 外键 | 预约单表,预约单ID |
PartsID | int | 外键 | 配件表,配件ID |
AttributeMinuteID_AccountType | int | 外键 | 属性明细表,属性明细ID_帐类 |
ObligateNumBer | decimal (18, 2) |
| 预留数量 |
NeedNumber | decimal (18, 2) |
| 需求数量 |
InTranSitNumBer | decimal (18, 2) |
| 在途数量 |
AvailableForSaleNumber | decimal (18, 2) |
| 可售数量 |
Price | decimal (18, 2) |
| 单价 |
IfResourceRelease | bit |
| 资源释放否 |
表3:预约维修项目表(BespeakServiceItemList)
列名 | 数据类型 | 主键/外键 | 说明 |
BespeakServiceItemID | int | 主键 | 预约维修项目ID |
BespeakBillID | int | 外键 | 预约单表,预约单ID |
WorkHoursItemMinuteID | int | 外键 | 工时项目明细表,工时项目明细ID |
AttributeMinuteID_AccountType | int | 外键 | 属性明细表,属性明细ID_帐类 |
WorkHoursPrice | decimal (18, 2) |
| 工时单价 |
GuestAccountWorkHours | decimal (18, 2) |
| 客帐工时 |
ParWorkHours | decimal (18, 2) |
| 标准工时 |
AnticipatedWorkHoursMoney | decimal (18, 2) |
| 预计工时金额 |
表4、配件表(BM_PartsList)
列名 | 数据类型 | 主键/外键 | 说明 |
PartsID | int - Identity | 主键 | 配件ID |
PartsCoding | nchar (20) |
| 配件代码 |
PartsName | nchar (20) |
| 配件名称 |
CarModels | nchar (20) |
| 车型 |
Specification | nchar (20) |
| 规格 |
AttributeMinuteID_Unit | int | 外键 | 属性明细表,属性明细ID_单位 |
SellPrice | nchar (20) |
| 销售价格 |
表5、工时项目表(BM_WorkHoursItemList)
列名 | 数据类型 | 主键/外键 | 说明 |
WorkHoursItemID | int - Identity | 主键 | 工时项目ID |
ItemCode | nchar (20) |
| 项目代码 |
ItemName | nchar (20) |
| 项目代码 |
WorkKindID | int | 外键 | 工种表,工种ID |
FirstKind | nchar (20) |
| 第一类 |
SecondKind | nchar (20) |
| 第二类 |
ForeignLanguageName | nchar (20) |
| 外文名称 |
Remarks | nchar (100) |
| 备注 |
AllSuitSign | bit |
| 全适用标志 |
表6、工时项目明细表(BM_WorkHoursItemMinuteList)
列名 | 数据类型 | 主键/外键 | 说明 |
WorkHoursItemMinuteID | int - Identity | 主键 | 工时项目明细ID |
WorkHoursItemID | int | 外键 | 工时项目表,工时项目ID |
CarModels | nchar (20) |
| 车型 |
GuestAccountWorkHours | decimal (18, 2) |
| 客帐工时 |
InternalAccountWorkHours | decimal (18, 2) |
| 内部帐工时 |
ParWorkHours | decimal (18, 2) |
| 标准工时 |
InsureAccountWorkHours | decimal (18, 2) |
| 保险帐工时 |
WorkHoursMoney | decimal (18, 2) |
| 工时金额 |
IfWorkHoursMultiplyUnitPrice | bit |
| 是否取工时乘单价 |
Remarks | nchar (100) |
| 备注 |
TheOriginalPar | bit |
| 原厂标准 |
表7、车辆信息表(BM_CarNewsList)
列名 | 数据类型 | 主键/外键 | 说明 |
CarNewsID | int - Identity | 主键 | 车辆信息ID |
CarOwnerNewsID | int | 外键 | 车主信息ID |
RecordNumber | nchar (20) |
| 档案号 |
LicensePlateNumber | nchar (20) |
| 车牌号 |
CarModelsCode | nchar (20) |
| 车型代码 |
VINCode | nchar (20) |
| VIN码 |
MotorModel | nchar (20) |
| 发动机型号 |
Transmissiontype | nchar (20) |
| 变速器型式 |
MotorNumber | nchar (20) |
| 发动机号 |
TransmissionNumber | nchar (20) |
| 变速箱号码 |
KeyNumber | nchar (20) |
| 钥匙号 |
ShiftWay | nchar (20) |
| 换挡方式 |
CarModelsYearFund | nchar (20) |
| 车型年款 |
Displacement | nchar (20) |
| 排量 |
EquipmentCode | nchar (20) |
| 装备代码 |
BodyworkColour | nchar (10) |
| 车身颜色 |
LeaveFactoryDate | datetime |
| 出厂日期 |
FuelKind | nchar (20) |
| 燃料种类 |
BuyCarDate | datetime |
| 购车日期 |
BuyCarMileage | decimal (18, 2) |
| 购车里程 |
Purpose | nchar (20) |
| 用途 |
SellUnit | nchar (20) |
| 销售单位 |
CarBrand | nchar (20) |
| 车辆品牌 |
CarModelsSimpleCode | nchar (20) |
| 车型简码 |
IfInWarrantyperiod | bit |
| 是否在保修期内 |
UserManage | bit |
| 用户管理 |
IfEffective | bit |
| 有效否 |
表8、车主信息表(BM_CarOwnerNewsList)
列名 | 数据类型 | 说明 | 说明 |
CarOwnerNewsID | int - Identity | 主键 | 车主信息ID |
CarOwnerCode | nchar (20) |
| 车主代码 |
CarOwnerName | nchar (20) |
| 车主名称 |
AttributeMinuteID_ClientTypeOne | int | 外键 | 属性明细表,属性明细ID_客户类型一 |
AttributeMinuteID_ClientTypeTwo | int | 外键 | 属性明细表,属性明细ID_客户类型二 |
AttributeMinuteID_Sex | int | 外键 | 属性明细表,属性明细ID_性别 |
Site | nchar (100) |
| 地址 |
MobilePhone | nchar (20) |
| 手机号码 |
HousePhone | nchar (20) |
| 住宅电话 |
OfficePhone | nchar (20) |
| 办公电话 |
AddressPostcode | nchar (20) |
| 住址邮编 |
TheGenusCountiesAndCities | nchar (50) |
| 所属县市 |
WorkUnit | nchar (50) |
| 工作单位 |
Job | nchar (50) |
| 职位 |
AttributeMinuteID_MaritalStatus | int | 外键 | 属性明细表,属性明细ID_婚姻状况 |
IDCard | nchar (30) |
| 身份证 |
Birthday | datetime |
| 生日 |
Hobby | nchar (100) |
| 爱好 |
ChangeSite | nchar (100) |
| 变跟地址 |
Postcode | nchar (20) |
| 邮编 |
Nationality | nchar (50) |
| 国籍 |
| nchar (50) |
| |
FacilitateTheReturnTime | datetime |
| 方便回访时间 |
CarOwnerPicture | nchar (3000) |
| 车主照片 |
Remarks | nchar (50) |
| 备注 |
IfEffective | bit |
| 有效否 |
2功能实现
1、窗体加载,为各个控件绑定数据。Load事件
第一步:数据库存储过程
IF(@TYPE='FRM_YuYueGuanLi_Update_Load_SelectYuYueXinXi')
BEGIN
SELECT PW_BespeakBillList.BespeakOddNumBer, PW_BespeakBillList.CarNewsID, PW_BespeakBillList.BespeakTime, PW_BespeakBillList.BespeakMileage, PW_BespeakBillList.BespeakStatus,
PW_BespeakBillList.Gross, PW_BespeakBillList.FailCause, PW_BespeakBillList.AttributeMinuteID_BespeakWay AS BespeakWayID, PW_BespeakBillList.StaffID_HearPersons AS HearPersonsID,
PW_BespeakBillList.StaffID_Receiver AS ReceiverID, PW_BespeakBillList.ApprovalTime, PW_BespeakBillList.LastTimeInTheFactory, PW_BespeakBillList.IfBespeakSucceed,
PW_BespeakBillList.BookingCarDeliveryTime, PW_BespeakBillList.BespeakWarnTime, PW_BespeakBillList.PredictAOGTime, PW_BespeakBillList.ServiceOddNumber,
PW_BespeakBillList.NewBespeakOddlNumber, PW_BespeakBillList.OldBespeakOddNumber, PW_BespeakBillList.NeedOddNumber, PW_BespeakBillList.AlterationTime,
PW_BespeakBillList.AlterationCauses, PW_BespeakBillList.ClientDescribe, PW_BespeakBillList.Remarks, PW_BespeakBillList.IfResourceRelease, PW_BespeakBillList.IfEffective,
BM_CarNewsList.CarOwnerNewsID, BM_CarNewsList.LicensePlateNumber, BM_CarNewsList.VINCode, BM_CarNewsList.MotorNumber, BM_CarNewsList.CarModelsYearFund,
BM_CarNewsList.BodyworkColour, BM_CarNewsList.LeaveFactoryDate, BM_CarNewsList.BuyCarDate, BM_CarOwnerNewsList.CarOwnerCode, BM_CarOwnerNewsList.MobilePhone,
AttributeMinuteList.AttributeMinuteName AS BespeakWay, BM_StaffRecordList_3.StaffName AS HearPersons, BM_StaffRecordList.StaffName AS Receiver, PW_BespeakBillList.ApprovalPerson,
PW_BespeakBillList.AlterationPerson, BM_CarOwnerNewsList.CarOwnerName
FROM PW_BespeakBillList INNER JOIN
BM_CarNewsList ON PW_BespeakBillList.CarNewsID = BM_CarNewsList.CarNewsID INNER JOIN
BM_CarOwnerNewsList ON BM_CarNewsList.CarOwnerNewsID = BM_CarOwnerNewsList.CarOwnerNewsID INNER JOIN
AttributeMinuteList ON PW_BespeakBillList.AttributeMinuteID_BespeakWay = AttributeMinuteList.AttributeMinuteID INNER JOIN
BM_StaffRecordList AS BM_StaffRecordList_3 ON PW_BespeakBillList.StaffID_HearPersons = BM_StaffRecordList_3.StaffID INNER JOIN
BM_StaffRecordList ON PW_BespeakBillList.StaffID_Receiver = BM_StaffRecordList.StaffID
WHERE PW_BespeakBillList.BespeakBillID=@BespeakBillID
END
IF(@TYPE='FRM_YuYueGuanLi_Update_Load_SelectYuYueXiangMu')
BEGIN
SELECT PW_BespeakServiceItemList.AttributeMinuteID_AccountType AS AccountTypeID, PW_BespeakServiceItemList.WorkHoursPrice, PW_BespeakServiceItemList.GuestAccountWorkHours,
PW_BespeakServiceItemList.ParWorkHours, PW_BespeakServiceItemList.AnticipatedWorkHoursMoney, BM_WorkHoursItemList.ItemCode, BM_WorkHoursItemList.ItemName,
BM_WorkHoursItemList.WorkKindID, BM_WorkKindList.WorkKindName, BM_WorkHoursItemMinuteList.CarModels, AttributeMinuteList.AttributeMinuteName AS AccountType,
PW_BespeakServiceItemList.WorkHoursItemMinuteID, BM_WorkHoursItemMinuteList.WorkHoursItemID, BM_WorkHoursItemMinuteList.WorkHoursItemMinuteID AS WorkHoursItemMinuteID
FROM AttributeMinuteList INNER JOIN
PW_BespeakServiceItemList ON AttributeMinuteList.AttributeMinuteID = PW_BespeakServiceItemList.AttributeMinuteID_AccountType INNER JOIN
BM_WorkHoursItemMinuteList INNER JOIN
BM_WorkHoursItemList ON BM_WorkHoursItemMinuteList.WorkHoursItemID = BM_WorkHoursItemList.WorkHoursItemID INNER JOIN
BM_WorkKindList ON BM_WorkHoursItemList.WorkKindID = BM_WorkKindList.WorkKindID ON
PW_BespeakServiceItemList.WorkHoursItemMinuteID = BM_WorkHoursItemMinuteList.WorkHoursItemMinuteID
WHERE PW_BespeakServiceItemList.BespeakBillID=@BespeakBillID
END
IF(@TYPE='FRM_YuYueGuanLi_Update_Load_SelectYuYuePeiJian')
BEGIN
SELECT PW_BespeakPartsList.PartsID, PW_BespeakPartsList.AttributeMinuteID_AccountType AS AccountTypeID, PW_BespeakPartsList.ObligateNumBer,
PW_BespeakPartsList.NeedNumber, PW_BespeakPartsList.InTranSitNumBer, PW_BespeakPartsList.AvailableForSaleNumber,
PW_BespeakPartsList.Price, PW_BespeakPartsList.Money, BM_PartsList.PartsCoding, BM_PartsList.PartsName,
BM_PartsList.CarModels, BM_PartsList.AttributeMinuteID_Unit AS UnitID, AttributeMinuteList.AttributeMinuteName AS AccountType,
AttributeMinuteList_1.AttributeMinuteName AS Unit, PW_BespeakPartsList.BespeakPartsID
FROM AttributeMinuteList INNER JOIN
PW_BespeakPartsList INNER JOIN
BM_PartsList ON PW_BespeakPartsList.PartsID = BM_PartsList.PartsID ON AttributeMinuteList.AttributeMinuteID = PW_BespeakPartsList.AttributeMinuteID_AccountType INNER JOIN
AttributeMinuteList AS AttributeMinuteList_1 ON BM_PartsList.AttributeMinuteID_Unit = AttributeMinuteList_1.AttributeMinuteID
WHERE PW_BespeakPartsList.BespeakBillID=@BespeakBillID AND PW_BespeakPartsList.IfResourceRelease =0
END
第二步:逻辑层(BLL)
//查询预约单信息
[OperationContract]
public DataSet FRM_YuYueGuanLi_Update_Load_SelectYuYueXinXi(int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value="FRM_YuYueGuanLi_Update_Load_SelectYuYueXinXi";
mySqlParameters[1].Value = intYuYueDanID;
DataTable dt = myDALMethod.QueryDataTable("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds; //返回一个数据集
}
//查询预约项目信息
[OperationContract]
public DataSet FRM_YuYueGuanLi_Update_Load_SelectYuYueXiangMu(int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_Load_SelectYuYueXiangMu";
mySqlParameters[1].Value = intYuYueDanID;
DataTable dt = myDALMethod.QueryDataTable("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds; //返回一个数据集
}
//查询预约配件信息
[OperationContract]
public DataSet FRM_YuYueGuanLi_Update_Load_SelectYuYuePeiJian(int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_Load_SelectYuYuePeiJian";
mySqlParameters[1].Value = intYuYueDanID;
DataTable dt = myDALMethod.QueryDataTable("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds; //返回一个数据集
}
第三步:界面层(UIL)
BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient myFRM_YuYueGuanLi_UpdateClient =
new BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient();
private void FRM_YuYueGuanLi_Update_Load(object sender, EventArgs e)
{
//根据预约单ID查询预约单信息
DataTable dtYuYueXinXi = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_Load_SelectYuYueXinXi(FRM_YuYueGuanLi.intYuYueDanID).Tables[0];
//给各个控件绑定数据
strShiFangYuYueDanHao = dtYuYueXinXi.Rows[0]["BespeakOddNumBer"].ToString().Trim();
dtpBespeakTime.Value = Convert.ToDateTime(dtYuYueXinXi.Rows[0]["BespeakTime"]);
nudhour.Value = Convert.ToDateTime(dtYuYueXinXi.Rows[0]["BespeakTime"]).Hour;
nudminute.Value = Convert.ToDateTime(dtYuYueXinXi.Rows[0]["BespeakTime"]).Minute;
cboBespeakWay.SelectedValue = Convert.ToInt32(dtYuYueXinXi.Rows[0]["BespeakWayID"]);
txtBespeakOddNumBer.Text = dtYuYueXinXi.Rows[0]["BespeakOddNumBer"].ToString();
txtBespeakMileage.Text = dtYuYueXinXi.Rows[0]["BespeakMileage"].ToString();
txtBespeakStatus.Text = dtYuYueXinXi.Rows[0]["BespeakStatus"].ToString();
txtGross.Text = dtYuYueXinXi.Rows[0]["Gross"].ToString();
txtFailCause.Text = dtYuYueXinXi.Rows[0]["FailCause"].ToString();
cboLicensePlateNumber.SelectedValue = Convert.ToInt32(dtYuYueXinXi.Rows[0]["CarNewsID"]);
txtCarOwnerName.Text = dtYuYueXinXi.Rows[0]["CarOwnerName"].ToString();
txtMobilePhone.Text = dtYuYueXinXi.Rows[0]["MobilePhone"].ToString();
txtBuyCarDate.Text = dtYuYueXinXi.Rows[0]["BuyCarDate"].ToString();
txtCarModelsCode.Text = dtYuYueXinXi.Rows[0]["CarModelsYearFund"].ToString();
txtVINCode.Text = dtYuYueXinXi.Rows[0]["VINCode"].ToString();
cboHearPersons.SelectedValue = Convert.ToInt32(dtYuYueXinXi.Rows[0]["HearPersonsID"]);
cboReceiver.SelectedValue = Convert.ToInt32(dtYuYueXinXi.Rows[0]["ReceiverID"]);
//txtApprovalPerson.Text = dtYuYueXinXi.Rows[0]["ApprovalPerson"].ToString();
//txtApprovalTime.Text = dtYuYueXinXi.Rows[0]["ApprovalTime"].ToString();
txtLastTimeInTheFactory.Text = dtYuYueXinXi.Rows[0]["LastTimeInTheFactory"].ToString();
txtBodyworkColour.Text = dtYuYueXinXi.Rows[0]["BodyworkColour"].ToString();
chbIfBespeakSucceed.Checked = Convert.ToBoolean(dtYuYueXinXi.Rows[0]["IfBespeakSucceed"]);
txtAlterationPerson.Text = dtYuYueXinXi.Rows[0]["AlterationPerson"].ToString();
txtBookingCarDeliveryTime.Text = dtYuYueXinXi.Rows[0]["BookingCarDeliveryTime"].ToString();
txtBespeakWarnTime.Text = dtYuYueXinXi.Rows[0]["BespeakWarnTime"].ToString();
//txtPredictAOGTime.Text = dtYuYueXinXi.Rows[0]["PredictAOGTime"].ToString();
txtServiceOddNumBer.Text = dtYuYueXinXi.Rows[0]["ServiceOddNumBer"].ToString();
txtOldBespeakOddNumber.Text = dtYuYueXinXi.Rows[0]["NewBespeakOddlNumber"].ToString();
txtNewBespeakOddlNumber.Text = dtYuYueXinXi.Rows[0]["OldBespeakOddNumber"].ToString();
//txtNeedOddNumber.Text = dtYuYueXinXi.Rows[0]["NeedOddNumber"].ToString();
txtAlterationTime.Text = dtYuYueXinXi.Rows[0]["AlterationTime"].ToString();
txtAlterationCauses.Text = dtYuYueXinXi.Rows[0]["AlterationCauses"].ToString();
txtClientDescribe.Text = dtYuYueXinXi.Rows[0]["ClientDescribe"].ToString();
txtRemarks.Text = dtYuYueXinXi.Rows[0]["Remarks"].ToString();
dtpBespeakTime.Value = Convert.ToDateTime(dtYuYueXinXi.Rows[0]["BespeakTime"]);
//YuYueShiJian();
//根据预约单ID查询预约维修项目信息
DataTable dtYuYueXiangMu = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_Load_SelectYuYueXiangMu(FRM_YuYueGuanLi.intYuYueDanID).Tables[0];
for (int i = 0; i < dtYuYueXiangMu.Rows.Count; i++)//循环表,循环赋值
{
dgvBespeakServiceItem.Rows.Add();//给dgv(预约维修项目)增加一行
dgvBespeakServiceItem.Rows[i].Cells["工时项目明细ID1"].Value = dtYuYueXiangMu.Rows[i]["WorkHoursItemMinuteID"];
dgvBespeakServiceItem.Rows[i].Cells["工时项目ID1"].Value = dtYuYueXiangMu.Rows[i]["WorkHoursItemID"];
dgvBespeakServiceItem.Rows[i].Cells["项目代码"].Value = dtYuYueXiangMu.Rows[i]["ItemCode"];
dgvBespeakServiceItem.Rows[i].Cells["预约维修项目"].Value = dtYuYueXiangMu.Rows[i]["ItemName"];
dgvBespeakServiceItem.Rows[i].Cells["帐类ID1"].Value = dtYuYueXiangMu.Rows[i]["AccountTypeID"];
dgvBespeakServiceItem.Rows[i].Cells["帐类"].Value = dtYuYueXiangMu.Rows[i]["AccountType"];
dgvBespeakServiceItem.Rows[i].Cells["工种"].Value = dtYuYueXiangMu.Rows[i]["WorkKindName"];
dgvBespeakServiceItem.Rows[i].Cells["工时单价"].Value = dtYuYueXiangMu.Rows[i]["WorkHoursPrice"];
dgvBespeakServiceItem.Rows[i].Cells["客帐工时"].Value = dtYuYueXiangMu.Rows[i]["GuestAccountWorkHours"];
dgvBespeakServiceItem.Rows[i].Cells["标准工时"].Value = dtYuYueXiangMu.Rows[i]["ParWorkHours"];
dgvBespeakServiceItem.Rows[i].Cells["预计工时金额"].Value = dtYuYueXiangMu.Rows[i]["AnticipatedWorkHoursMoney"];
}
//根据预约单ID查询预约配件信息
DataTable dtYuYuePeiJian = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_Load_SelectYuYuePeiJian(FRM_YuYueGuanLi.intYuYueDanID).Tables[0];
for (int j = 0; j < dtYuYuePeiJian.Rows.Count; j++)//循环表,循环赋值
{
dgvBespeakParts.Rows.Add();//给dgv(预约配件)增加一行
dgvBespeakParts.Rows[j].Cells["配件ID"].Value = dtYuYuePeiJian.Rows[j]["PartsID"];
dgvBespeakParts.Rows[j].Cells["配件编码"].Value = dtYuYuePeiJian.Rows[j]["PartsCoding"];
dgvBespeakParts.Rows[j].Cells["配件名称"].Value = dtYuYuePeiJian.Rows[j]["PartsName"];
dgvBespeakParts.Rows[j].Cells["帐类ID"].Value = dtYuYuePeiJian.Rows[j]["AccountTypeID"];
dgvBespeakParts.Rows[j].Cells["帐类1"].Value = dtYuYuePeiJian.Rows[j]["AccountTypeID"];
dgvBespeakParts.Rows[j].Cells["需求数量"].Value = dtYuYuePeiJian.Rows[j]["NeedNumber"];
dgvBespeakParts.Rows[j].Cells["在途数量"].Value = dtYuYuePeiJian.Rows[j]["InTranSitNumBer"];
dgvBespeakParts.Rows[j].Cells["预留数量"].Value = dtYuYuePeiJian.Rows[j]["ObligateNumBer"];
dgvBespeakParts.Rows[j].Cells["可售数量"].Value = dtYuYuePeiJian.Rows[j]["AvailableForSaleNumber"];
dgvBespeakParts.Rows[j].Cells["单价"].Value = dtYuYuePeiJian.Rows[j]["Price"];
dgvBespeakParts.Rows[j].Cells["金额"].Value = dtYuYuePeiJian.Rows[j]["Money"];
dgvBespeakParts.Rows[j].Cells["车型"].Value = dtYuYuePeiJian.Rows[j]["CarModels"];
}
}
2、点击dgv,把点击的那一行数据绑定到控件,以dgv(预约维修配件)为例。
第一步:界面层(UIL),dgv(预约维修配件)点击事件。
private void dgvYuXiuXiangMu_MouseClick(object sender, MouseEventArgs e)
{
if (dgvBespeakServiceItem.Rows.Count > 0)//如果dgv(预约维修项目)不为空
{
//鼠标点击的那一行数据绑定到各个空间
cboItemCode.SelectedValue = Convert.ToInt32(dgvBespeakServiceItem.CurrentRow.Cells["工时项目ID1"].Value);
txtWorkHoursItem.Text = dgvBespeakServiceItem.CurrentRow.Cells["项目代码"].Value.ToString();
txtWorkKind.Text = dgvBespeakServiceItem.CurrentRow.Cells["工种"].Value.ToString();
cboAccountType.SelectedValue = Convert.ToInt32(dgvBespeakServiceItem.CurrentRow.Cells["帐类ID1"].Value);
txtWorkHoursPrice.Text = dgvBespeakServiceItem.CurrentRow.Cells["工时单价"].Value.ToString();
txtGuestAccountWorkHours.Text = dgvBespeakServiceItem.CurrentRow.Cells["客帐工时"].Value.ToString();
txtParWorkHours.Text = dgvBespeakServiceItem.CurrentRow.Cells["标准工时"].Value.ToString();
txtAnticipatedWorkHoursMoney.Text = dgvBespeakServiceItem.CurrentRow.Cells["预计工时金额"].Value.ToString();
}
}
4、保存修改界面的数据。
第一步:数据库的存储过程。
IF(@TYPE='FRM_YuYueGuanLi_Update_DeleteYuYuePeiJian')
BEGIN
DELETE PW_BespeakPartsList
WHERE PW_BespeakPartsList.BespeakBillID=@BespeakBillID
END
IF(@TYPE='FRM_YuYueGuanLi_Update_btnBaoCun_Click')
BEGIN
UPDATE PW_BespeakBillList
SET BespeakOddNumBer=@BespeakOddNumBer, CarNewsID=@CarNewsID, BespeakTime=@BespeakTime, AttributeMinuteID_BespeakWay=@AttributeMinuteID_BespeakWay,
BespeakMileage=@BespeakMileage, BespeakStatus=@BespeakStatus, Gross=@Gross,FailCause=@FailCause, StaffID_HearPersons=@StaffID_HearPersons,
StaffID_Receiver=@StaffID_Receiver, ApprovalPerson=@ApprovalPerson, ApprovalTime=@ApprovalTime, IfBespeakSucceed=@IfBespeakSucceed, LastTimeInTheFactory=@LastTimeInTheFactory,
AlterationPerson=@AlterationPerson,BookingCarDeliveryTime= @BookingCarDeliveryTime, BespeakWarnTime=@BespeakWarnTime, PredictAOGTime=@PredictAOGTime,
ServiceOddNumBer=@ServiceOddNumBer, NewBespeakOddlNumber=@NewBespeakOddlNumber,OldBespeakOddNumber=@OldBespeakOddNumber, NeedOddNumber=@NeedOddNumber, AlterationTime=@AlterationTime,
AlterationCauses=@AlterationCauses, ClientDescribe=@ClientDescribe, Remarks=@Remarks, IfResourceRelease=@IfResourceRelease, IfEffective=@IfEffective
WHERE PW_BespeakBillList.BespeakBillID=@BespeakBillID
END
IF(@TYPE='FRM_YuYueGuanLi_Update_SaveYuYueXiangMu')
BEGIN
INSERT PW_BespeakServiceItemList(BespeakBillID, WorkHoursItemMinuteID, AttributeMinuteID_AccountType, WorkHoursPrice, GuestAccountWorkHours, ParWorkHours, AnticipatedWorkHoursMoney)
VALUES (@BespeakBillID, @WorkHoursItemMinuteID, @AttributeMinuteID_AccountType, @WorkHoursPrice, @GuestAccountWorkHours, @ParWorkHours, @AnticipatedWorkHoursMoney)
END
IF(@TYPE='FRM_YuYueGuanLi_Update_SaveYuYuePeiJian')
BEGIN
INSERT PW_BespeakPartsList(BespeakBillID, PartsID, AttributeMinuteID_AccountType, ObligateNumBer, NeedNumber, InTranSitNumBer, AvailableForSaleNumber, Price, IfResourceRelease, Money)
VALUES (@BespeakBillID, @PartsID, @AttributeMinuteID_AccountType, @ObligateNumBer, @NeedNumber, @InTranSitNumBer, @AvailableForSaleNumber, @Price, @IfReleaseResource, @Money)
END
第二步:逻辑层(UIL)
//删除预约项目信息
[OperationContract]
public int FRM_YuYueGuanLi_Update_DeleteYuYueXiangMu(int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_DeleteYuYueXiangMu";
mySqlParameters[1].Value = intYuYueDanID;
return myDALMethod.UpdateData("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
}
[OperationContract]
//删除预约配件信息
public int FRM_YuYueGuanLi_Update_DeleteYuYuePeiJian(int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_DeleteYuYuePeiJian";
mySqlParameters[1].Value = intYuYueDanID;
return myDALMethod.UpdateData("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
}
//修改预约单信息
[OperationContract]
public int FRM_YuYueGuanLi_Update_btnBaoCun_Click(string strYuYueDanHao, int intCheLiangXinXiID, DateTime datYuYueShiJian, int intYuYueFangShiID, decimal decYuYueLiCheng, string strYuYueZhuangTai, decimal decZongJiJinE, string strShiBaiYuanYin, int intShouLiRen, int intJieDaiRen, bool bitYuYueChengGongFou, string strShangCiJinChangShiJian, string strBianGengRen, string strYuYueJiCheShiJian, string strYuYueTiXingShiJian, string strWeiXiuDanHao, string strYuanYuYueDanHao, string strBianGengShiJian,string strBianGengYuanYin, string strGuKeMiaoShu, string strBeiZhu, bool bitZiYuanShiFangFou, bool bitYouXiaoFou, string strXinYuYueDanHao, int intYuYueDanID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
//下面的都是实例化参数——数据库表的字段,标明数据类型
new SqlParameter("@BespeakOddNumBer",SqlDbType.NChar),
new SqlParameter("@CarNewsID",SqlDbType.Int),
new SqlParameter("@BespeakTime",SqlDbType.DateTime),
new SqlParameter("@AttributeMinuteID_BespeakWay",SqlDbType.Int),
new SqlParameter("@BespeakMileage",SqlDbType.Decimal),
new SqlParameter("@BespeakStatus",SqlDbType.NChar),
new SqlParameter("@Gross",SqlDbType.Decimal),
new SqlParameter("@FailCause",SqlDbType.NChar),
new SqlParameter("@StaffID_HearPersons",SqlDbType.Int),
new SqlParameter("@StaffID_Receiver",SqlDbType.Int),
new SqlParameter("@IfBespeakSucceed",SqlDbType.Bit),
new SqlParameter("@LastTimeInTheFactory",SqlDbType.NChar),
new SqlParameter("@AlterationPerson",SqlDbType.NChar),
new SqlParameter("@BookingCarDeliveryTime",SqlDbType.NChar),
new SqlParameter("@BespeakWarnTime",SqlDbType.NChar),
new SqlParameter("@ServiceOddNumBer",SqlDbType.NChar),
new SqlParameter("@OldBespeakOddNumber",SqlDbType.NChar),
new SqlParameter("@AlterationTime ",SqlDbType.NChar),
new SqlParameter("@AlterationCauses",SqlDbType.NChar),
new SqlParameter("@ClientDescribe",SqlDbType.NChar),
new SqlParameter("@Remarks",SqlDbType.NChar),
new SqlParameter("@IfReleaseResource",SqlDbType.Bit),
new SqlParameter("@IfEffective",SqlDbType.Bit),
new SqlParameter("@NewBespeakOddlNumber",SqlDbType.NChar),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_btnBaoCun_Click";
mySqlParameters[1].Value = strYuYueDanHao;
mySqlParameters[2].Value = intCheLiangXinXiID;
mySqlParameters[3].Value = datYuYueShiJian;
mySqlParameters[4].Value = intYuYueFangShiID;
mySqlParameters[5].Value = decYuYueLiCheng;
mySqlParameters[6].Value = strYuYueZhuangTai;
mySqlParameters[7].Value = decZongJiJinE;
mySqlParameters[8].Value = strShiBaiYuanYin;
mySqlParameters[9].Value = intShouLiRen;
mySqlParameters[10].Value = intJieDaiRen;
mySqlParameters[11].Value = bitYuYueChengGongFou;
mySqlParameters[12].Value = strShangCiJinChangShiJian;
mySqlParameters[13].Value = strBianGengRen;
mySqlParameters[14].Value = strYuYueJiCheShiJian;
mySqlParameters[15].Value = strYuYueTiXingShiJian;
mySqlParameters[16].Value = strWeiXiuDanHao;
mySqlParameters[17].Value = strYuanYuYueDanHao;
mySqlParameters[18].Value = strBianGengShiJian;
mySqlParameters[19].Value = strBianGengYuanYin;
mySqlParameters[20].Value = strGuKeMiaoShu;
mySqlParameters[21].Value = strBeiZhu;
mySqlParameters[22].Value = bitZiYuanShiFangFou;
mySqlParameters[23].Value = bitYouXiaoFou;
mySqlParameters[24].Value = strXinYuYueDanHao;
mySqlParameters[25].Value = intYuYueDanID;
return myDALMethod.UpdateData("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
//返回至值为1是正常的,返回值小于0是异常
}
//保存修改的预约项目信息
[OperationContract]
public int FRM_YuYueGuanLi_Update_SaveYuYueXiangMu(int intYuYueDanID, int IntGongShiXiangMuID, int intZhangLei, decimal decGongShiDanJia,
decimal decKeZhangGongShi, decimal decBiaoZhunGongShi, decimal DecYuJiGongShiJinE)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
//实例化参数,标明数据类型
new SqlParameter("@BespeakBillID",SqlDbType.Int),
new SqlParameter("@WorkHoursItemMinuteID",SqlDbType.Int),
new SqlParameter("@AttributeMinuteID_AccountType",SqlDbType.Int),
new SqlParameter("@WorkHoursPrice",SqlDbType.Decimal),
new SqlParameter("@GuestAccountWorkHours",SqlDbType.Decimal),
new SqlParameter("@ParWorkHours",SqlDbType.Decimal),
new SqlParameter("@AnticipatedWorkHoursMoney",SqlDbType.Decimal),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_SaveYuYueXiangMu";
mySqlParameters[1].Value = intYuYueDanID;
mySqlParameters[2].Value = IntGongShiXiangMuID;
mySqlParameters[3].Value = intZhangLei;
mySqlParameters[4].Value = decGongShiDanJia;
mySqlParameters[5].Value = decKeZhangGongShi;
mySqlParameters[6].Value = decBiaoZhunGongShi;
mySqlParameters[7].Value = DecYuJiGongShiJinE;
return myDALMethod.UpdateData("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
//返回至值为1是正常的,返回值小于0是异常
}
//保存修改的配件信息
[OperationContract]
public int FRM_YuYueGuanLi_Update_SaveYuYuePeiJian(int intYuYueDanID, int intPeiJianID, int intZhangLei, decimal decYuLiuShuLiang, decimal decXuQiuShuLiang,
decimal decZaiTuShuLiang, decimal decKeShouShuLiang, decimal decDanJia, bool boolZiYuanShiFangFou, decimal decJinE)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
//实例化参数,标明数据类型
new SqlParameter("@BespeakBillID",SqlDbType.Int),
new SqlParameter("@PartsID",SqlDbType.Int),
new SqlParameter("@AttributeMinuteID_AccountType",SqlDbType.Int),
new SqlParameter("@ObligateNumBer",SqlDbType.Decimal),
new SqlParameter("@NeedNumber",SqlDbType.Decimal),
new SqlParameter("@InTranSitNumBer",SqlDbType.Decimal),
new SqlParameter("@AvailableForSaleNumber",SqlDbType.Decimal),
new SqlParameter("@Price",SqlDbType.Decimal),
new SqlParameter("@IfReleaseResource",SqlDbType.Bit),
new SqlParameter("@Money",SqlDbType.Decimal),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_SaveYuYuePeiJian";
mySqlParameters[1].Value = intYuYueDanID;
mySqlParameters[2].Value = intPeiJianID;
mySqlParameters[3].Value = intZhangLei;
mySqlParameters[4].Value = decYuLiuShuLiang;
mySqlParameters[5].Value = decXuQiuShuLiang;
mySqlParameters[6].Value = decZaiTuShuLiang;
mySqlParameters[7].Value = decKeShouShuLiang;
mySqlParameters[8].Value = decDanJia;
mySqlParameters[9].Value = boolZiYuanShiFangFou;
mySqlParameters[10].Value = decJinE;
return myDALMethod.UpdateData("预约管理_FRM_YuYueGuanLi_Update", mySqlParameters);
//返回至值为1是正常的,返回值小于0是异常
}
第三步:界面层(UIL)
BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient myFRM_YuYueGuanLi_UpdateClient =
new BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient();
private void btnZongSave_Click(object sender, EventArgs e)
{
int intYuYuePeiJian;
int intYuYueXiangMu;
//给各个参数赋值
string strYuYueDanHao = txtBespeakOddNumBer.Text;
int intCheLiangXinXiID = Convert.ToInt32(cboLicensePlateNumber.SelectedValue);
DateTime datYuYueShiJian = dtpBespeakTime.Value.Date.AddHours(Convert.ToInt32(nudhour.Value)).AddMinutes(Convert.ToInt32(nudminute.Value));
int intYuYueFangShiID = Convert.ToInt32(cboBespeakWay.SelectedValue);
decimal decYuYueLiCheng = Convert.ToDecimal(txtBespeakMileage.Text);
string strYuYueZhuangTai = txtBespeakStatus.Text;
decimal decZongJiJinE = Convert.ToDecimal(txtGross.Text);
string strShiBaiYuanYin = txtFailCause.Text;
int intShouLiRen = Convert.ToInt32(cboHearPersons.SelectedValue);
int intJieDaiRen = Convert.ToInt32(cboReceiver.SelectedValue);
bool bitYuYueChengGongFou = Convert.ToBoolean(chbIfBespeakSucceed.Checked);
string strShangCiJinChangShiJian = txtLastTimeInTheFactory.Text;
string strBianGengRen = txtAlterationPerson.Text;
string strYuYueJiCheShiJian = txtBookingCarDeliveryTime.Text;
string strYuYueTiXingShiJian = txtBespeakWarnTime.Text;
string strWeiXiuDanHao = txtServiceOddNumBer.Text;
string strYuanYuYueDanHao = txtOldBespeakOddNumber.Text;
string strBianGengShiJian = txtAlterationTime.Text;
string strBianGengYuanYin = txtAlterationCauses.Text;
string strGuKeMiaoShu = txtClientDescribe.Text;
string strBeiZhu = txtRemarks.Text;
bool bitZiYuanShiFangFou = false;
bool bitYouXiaoFou = true;
string strXinYuYueDanHao = txtNewBespeakOddlNumber.Text;
int intYuYueDanID = FRM_YuYueGuanLi.intYuYueDanID;
int intYuYueDan = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_btnBaoCun_Click(strYuYueDanHao, intCheLiangXinXiID, datYuYueShiJian, intYuYueFangShiID,
decYuYueLiCheng, strYuYueZhuangTai, decZongJiJinE, strShiBaiYuanYin, intShouLiRen, intJieDaiRen, bitYuYueChengGongFou, strShangCiJinChangShiJian, strBianGengRen, strYuYueJiCheShiJian, strYuYueTiXingShiJian, strWeiXiuDanHao, strYuanYuYueDanHao, strBianGengShiJian, strBianGengYuanYin, strGuKeMiaoShu, strBeiZhu, bitZiYuanShiFangFou, bitYouXiaoFou, strXinYuYueDanHao, intYuYueDanID);
//删除原有的预约维修项目
int intDeleteYuYueXiangMu = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_DeleteYuYueXiangMu(FRM_YuYueGuanLi.intYuYueDanID);
if (dgvBespeakServiceItem.Rows.Count > 0)//如果dgv(预约维修项目)不为空
{
for (int i = 0; i < dgvBespeakServiceItem.Rows.Count; i++)//循环dgv(预约维修项目)
{
//给各个参数赋值
int intYuYueDanID1 = FRM_YuYueGuanLi.intYuYueDanID;
int IntGongShiXiangMuID = Convert.ToInt32(dgvBespeakServiceItem.Rows[i].Cells["工时项目明细ID1"].Value);
int intZhangL = Convert.ToInt32(dgvBespeakServiceItem.Rows[i].Cells["帐类ID1"].Value);
decimal decGongShiDanJia = Convert.ToDecimal(dgvBespeakServiceItem.Rows[i].Cells["工时单价"].Value);
decimal datKeZhangGongShi = Convert.ToDecimal(dgvBespeakServiceItem.Rows[i].Cells["客帐工时"].Value);
decimal datBiaoZhunGongShi = Convert.ToDecimal(dgvBespeakServiceItem.Rows[i].Cells["标准工时"].Value);
decimal DecYuJiGongShiJinE = Convert.ToDecimal(dgvBespeakServiceItem.Rows[i].Cells["预计工时金额"].Value);
intYuYueXiangMu = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_SaveYuYueXiangMu(intYuYueDanID1, IntGongShiXiangMuID, intZhangL, decGongShiDanJia,
datKeZhangGongShi, datBiaoZhunGongShi, DecYuJiGongShiJinE);
}
}
//删除原有的预约配件
int intDeleteYuYuePeiJian = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_DeleteYuYuePeiJian(FRM_YuYueGuanLi.intYuYueDanID);
if (dgvBespeakParts.Rows.Count > 0)//如果dgv(约预配件)不为空
{
for (int j = 0; j < dgvBespeakParts.Rows.Count; j++)//循环dgv(约预配件)
{
//给各个参数赋值
int intYuYueDanID2 = FRM_YuYueGuanLi.intYuYueDanID;
int intPeiJianID = Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["配件ID"].Value);
int intZhangLei = Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["帐类ID"].Value);
decimal decYuLiuShuLiang = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["预留数量"].Value);
decimal decXuQiuShuLiang = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["需求数量"].Value);
decimal decZaiTuShuLiang = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["在途数量"].Value);
decimal decKeShouShuLiang = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["可售数量"].Value);
decimal decDanJia = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["单价"].Value);
bool boolZiYuanShiFangFou = false;
decimal decJinE = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["金额"].Value);
intYuYuePeiJian = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_SaveYuYuePeiJian(intYuYueDanID2, intPeiJianID, intZhangLei, decYuLiuShuLiang, decXuQiuShuLiang,
decZaiTuShuLiang, decKeShouShuLiang, decDanJia, boolZiYuanShiFangFou, decJinE);
}
}
if (intYuYueDan > 0)
{
MessageBox.Show("修改成功!!!");
this.Close();
}
}
以上仅用于学习参考,禁止用于商业用途!!!