预约变跟
预约变更实现变更客户来厂时间。
点击【变更原因】界面的“确定”按钮后,弹出下图:
点击“确定”后,弹出下图:
点击“确定”后,弹出下图:
从变更原因界面可以看到有控件:
控件 | 说明 |
文本框(TextBox) | 控件可以在工具箱直接拖动至窗体,拖至窗体后右击属性可以修改控件的样式和各种属性,还可以编辑事件。 |
按钮(Button) |
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、功能实现
1、作废预约单——“预约变更”界面“保存”按钮的点击事件。
第一步:数据库存储过程
IF(@TYPE='FRM_YuYueGuanLi_Update_BianGeng')
BEGIN
UPDATE PW_BespeakBillList
SET AlterationCauses=@AlterationCauses,NewBespeakOddlNumber=@NewBespeakOddlNumber,
AlterationPerson=@AlterationPerson,AlterationTime=@AlterationTime,IfResourceRelease=1, IfEffective=0
WHERE BespeakBillID=@BespeakBillID
END
第二步:逻辑层(BLL)
//保存变更所用到信息
[OperationContract]
public int FRM_YuYueGuanLi_Update_BianGeng(string strAlterationCauses,string strNewBespeakOddlNumber,string strAlterationPerson,string strAlterationTime,
int intBespeakBillID)
{
SqlParameter[] mySqlParameters =
{
new SqlParameter("@TYPE",SqlDbType.Char),
new SqlParameter("@AlterationCauses",SqlDbType.NChar),
new SqlParameter("@NewBespeakOddlNumber",SqlDbType.NChar),
new SqlParameter("@AlterationPerson",SqlDbType.NChar),
new SqlParameter("@AlterationTime",SqlDbType.NChar),
new SqlParameter("@BespeakBillID",SqlDbType.Int),
};
mySqlParameters[0].Value = "FRM_YuYueGuanLi_Update_BianGeng";
mySqlParameters[1].Value = strAlterationCauses;
mySqlParameters[2].Value = strNewBespeakOddlNumber;
mySqlParameters[3].Value = strAlterationPerson;
mySqlParameters[4].Value = strAlterationTime;
mySqlParameters[5].Value = intBespeakBillID;
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 btnSave_Click(object sender, EventArgs e)
{
FRM_YuYueGuanLi_YuYueBianGeng_YuanYin myFRM_YuYueGuanLi_YuYueBianGeng_YuanYin = new FRM_YuYueGuanLi_YuYueBianGeng_YuanYin();
myFRM_YuYueGuanLi_YuYueBianGeng_YuanYin.ShowDialog();
if (FRM_YuYueGuanLi_YuYueBianGeng_YuanYin.blnKuaiGuan == true)//如果公共静态变量的值为“true”,【变更原因】界面定义的公共变量
{
//给控件赋值
txtBespeakOddNumBer.Text = FRM_YuYueGuanLi_YuYueBianGeng_YuanYin.strBespeakOddNumBer;
txtOldBespeakOddNumber.Text = strShiFangYuYueDanHao;
BianGeng();//调用自定义方法
FRM_YuYueGuanLi.intBianGeng = 0;
FRM_YuYueGuanLi_YuYueBianGeng_YuanYin.blnKuaiGuan = false;
}
}
int intYuYueDanID = 0;
public void BianGeng()
{
//给参数赋值
int intYuYuePeiJian;
int intYuYueXiangMu;
string strYuYueDanHao = txtBespeakOddNumBer.Text;
int intCheLiangXinXiID = Convert.ToInt32(cboLicensePlateNumber.SelectedValue);
DateTime datYuYueShiJian = dtpBespeakTime.Value.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;
//调用方法保存到数据库
intYuYueDanID = myFRM_YuYueGuanLi_InsertClient.FRM_YuYueGuanLi_Insert_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);
//删除原有的预约项目
int intDeleteYuYueXiangMu = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_DeleteYuYueXiangMu(FRM_YuYueGuanLi.intYuYueDanID);
for (int i = 0; i < dgvBespeakServiceItem.Rows.Count; i++)//循环遍历提取信息
{
//给参数赋值
int intYuYueDanID1 = 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_InsertClient.FRM_YuYueGuanLi_Insert_SaveYuYueXiangMu(intYuYueDanID1, IntGongShiXiangMuID, intZhangL, decGongShiDanJia,
datKeZhangGongShi, datBiaoZhunGongShi, DecYuJiGongShiJinE);
}
//删除原有的预约配件
int intDeleteYuYuePeiJian = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_DeleteYuYuePeiJian(FRM_YuYueGuanLi.intYuYueDanID);
for (int j = 0; j < dgvBespeakParts.Rows.Count; j++)//循环遍历提取信息
{
//给参数赋值
int intYuYueDanID2 = 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_InsertClient.FRM_YuYueGuanLi_Insert_SaveYuYuePeiJian(intYuYueDanID2, intPeiJianID, intZhangLei, decYuLiuShuLiang, decXuQiuShuLiang,
decZaiTuShuLiang, decKeShouShuLiang, decDanJia, boolZiYuanShiFangFou, decJinE);
}
}
第三步:界面层(UIL),“变更原因”界面“确定”按钮的点击事件。
BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient myFRM_YuYueGuanLi_UpdateClient =
new BLL海马汽车销售系统.预约管理.FRM_YuYueGuanLi_Update.FRM_YuYueGuanLi_UpdateClient();
public static string strAlterationCauses;//公共静态变量
public static string strBespeakOddNumBer;//公共静态变量
public static bool blnKuaiGuan;// 公共静态变量
private void btnQueDing_Click(object sender, EventArgs e)
{
string strXiaoShouShouKuan = "YY";
strBespeakOddNumBer = ShengChengDanHao(strXiaoShouShouKuan);
strAlterationCauses = txtAlterationCauses.Text;
//给参数赋值
int intBespeakBillID = FRM_YuYueGuanLi.intYuYueDanID;
string strNewBespeakOddlNumber = strBespeakOddNumBer;
string strAlterationPerson = FRM_Login.strStaffName;
string strAlterationTime = DateTime.Now.ToString();
//调用方法保存数据,改变原预约单【有效否】的状态
int intBianGeng = myFRM_YuYueGuanLi_UpdateClient.FRM_YuYueGuanLi_Update_BianGeng(strAlterationCauses,strNewBespeakOddlNumber,strAlterationPerson,strAlterationTime,intBespeakBillID);
if (MessageBox.Show("原预约单‘" + FRM_YuYueGuanLi_Update.strShiFangYuYueDanHao + "’所占用资源已释放", "HaiMa", MessageBoxButtons.OK) == DialogResult.OK)
{
MessageBox.Show("成功生成一张新预约单,单号为‘" + strBespeakOddNumBer+"’", "HaiMa", MessageBoxButtons.OK);
this.Close();
}
blnKuaiGuan = true; //blnKuaiGuan的值为true,表明当前事件已执行。
}
以上仅供学习参考,禁止用于商业用途!!!