海马汽车经销商管理系统技术解析(十二)工单核准

核准

 

如果有足够的配件资源进行预留,可点击【核准】,对该预约单的资源进行预留,包括维修作业资源和配件资源。见下图:

点击【释放配件还原】界面中任一按钮,弹出提示对话框,见下图:

点击【是】,核准成功,弹出对话框,见下图:

核准后的单据会变成蓝色,见下图:

 

从“释放配件还原”界面可看到控件有:

控件

说明

表格(DataGridView)

编辑控件可以在工具箱直接拖动至窗体,拖至窗体后右击属性可以修改控件的样式和各种属性,还可以事件。

按钮(Button)

1、数据库功能实现

第一步:数据库

1、表和关系

 

 

 

表1、维修工单表(PW_ServiceWorkBillList)

列名

数据类型

主键/外键

说明

ServiceWorkBillID

int - Identity

主键

维修工单ID

WorkOddNumBer

nchar (20)

 

维修工单号

BespeakBillID

int

外键

预约单表,预约单ID

CarNewsID

int

外键

车辆信息表,车辆信息ID

EntranceMileage

decimal (18, 2)

 

进厂里程

BusinessSort

nchar (20)

 

业务类别

EntranceTime

datetime

 

进厂时间

CarryRepairPerson

nchar (20)

 

送修人

SurplusOilVolume

decimal (18, 2)

 

剩余油量

PlanGathering

decimal (18, 2)

 

预收款

BookingCarDeliveryTime

nchar (20)

 

预计交车时间

LastTimeInTheFactory

nchar (20)

 

上次进厂时间

BespeakOddNumBer

nchar (20)

 

预约单号

MemberSort

nchar (20)

 

会员类别

ServiceAdviser_StaffID

int

外键

员工表,员工ID_服务顾问

InsureCompanyID

nchar (20)

 

保险公司ID

AttributeMinuteID_CarStatus

int

外键

属性明细表,属性明细ID_车辆状态

IfWashCar

bit

 

海马汽车否

OldPieceDispose

nchar (20)

 

旧件处理

InspectRecord

nchar (100)

 

环检记录

ClientDescribe

nchar (100)

 

顾客陈述

Remarks

nchar (100)

 

备注

IfBespeak

bit

 

预约否

IfDebt

bit

 

欠款否

IfResourceRelease

bit

 

资源释放否

 

表2:预约单表(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

 

资源释放否

表3:预约配件表(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

 

资源释放否

表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:出库单表(PW_OutStorageBillList)

列名

数据类型

主键/外键

说明

OutStorageBillID

int - Identity

主键

出库单ID

OutStorageBillNumber

nchar (20)

外键

出库单号

OutStorageTime

datetime

外键

出库时间

StaffID_OutStoragePerson

int

外键

员工档案表,员工ID_出库人

StaffID_VerifyPerson

int

外键

员工档案表,员工ID_审核人

IfVerify

bit

外键

审核否

IfOutStorage

bit

外键

出库否

表6:出库单明细表(PW_OutStorageBillMinuteList)

列名

数据类型

主键/外键

说明

OutStorageBillMinuteID

int - Identity

主键

出库单明细ID

OutStorageBillID

int

外键

PW_出库单表,出库单ID

NeedPartsID

int

外键

需求配件表,需求配件ID

BespeakPartsID

int

外键

预约配件表,预约配件ID

StorageID

int

外键

BM_仓库表,仓库ID

2、功能实现

1、【核准】按钮点击事件。生成预留出库单。

 

第一步:数据库存储过程

IF(@TYPE='FRM_QianTaiJieDai_SelectBespeakParts')
BEGIN
SELECT     PW_ServiceWorkBillList.ServiceWorkBillID, PW_BespeakPartsList.NeedNumber, PW_BespeakPartsList.ObligateNumBer, 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 Unit, PW_BespeakPartsList.PartsID, AttributeMinuteList_1.AttributeMinuteName AS AccountType, 
                      PW_BespeakPartsList.AttributeMinuteID_AccountType AS AccountTypeID, PW_ServiceWorkBillList.WorkOddNumBer, PW_BespeakBillList.BespeakOddNumBer, 
                      PW_BespeakPartsList.BespeakPartsID
FROM         PW_ServiceWorkBillList INNER JOIN
                      PW_BespeakBillList ON PW_ServiceWorkBillList.BespeakBillID = PW_BespeakBillList.BespeakBillID INNER JOIN
                      PW_BespeakPartsList ON PW_BespeakBillList.BespeakBillID = PW_BespeakPartsList.BespeakBillID INNER JOIN
                      BM_PartsList ON PW_BespeakPartsList.PartsID = BM_PartsList.PartsID INNER JOIN
                      AttributeMinuteList ON BM_PartsList.AttributeMinuteID_Unit = AttributeMinuteList.AttributeMinuteID INNER JOIN
                      AttributeMinuteList AS AttributeMinuteList_1 ON PW_BespeakPartsList.AttributeMinuteID_AccountType = AttributeMinuteList_1.AttributeMinuteID
WHERE   PW_ServiceWorkBillList.ServiceWorkBillID=@ServiceWorkBillID AND   PW_BespeakPartsList.IfResourceRelease=1                 
END
IF(@TYPE='FRM_QianTaiJieDai_UpdateIfApproval')
BEGIN
UPDATE     PW_ServiceWorkBillList
SET       ApprovalTime=@ApprovalTime,ApprovalPerson=@ApprovalPerson,IfApproval=1, AttributeMinuteID_CarStatus=20
WHERE   ServiceWorkBillID=@ServiceWorkBillID       
END
IF(@TYPE='FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian')
BEGIN
SELECT     PW_ServiceNeedPartsList.ServiceNeedPartsID, PW_ServiceNeedPartsList.PartsID, PW_ServiceNeedPartsList.AttributeMinuteID_AccountType AS AccountTypeID, 
                      PW_ServiceNeedPartsList.NeedNumber, PW_ServiceNeedPartsList.SellPrice, PW_ServiceNeedPartsList.Discount, PW_ServiceNeedPartsList.InsurePercentage, 
                      PW_ServiceNeedPartsList.PrivilegeAfterOfMoney, PW_ServiceNeedPartsList.Remarks, BM_PartsList.PartsCoding, BM_PartsList.PartsName, BM_PartsList.CarModels, 
                      AttributeMinuteList.AttributeMinuteName AS unit, AttributeMinuteList_1.AttributeMinuteName AS AccountType
FROM         AttributeMinuteList AS AttributeMinuteList_1 INNER JOIN
                      PW_ServiceNeedPartsList INNER JOIN
                      BM_PartsList ON PW_ServiceNeedPartsList.PartsID = BM_PartsList.PartsID ON AttributeMinuteList_1.AttributeMinuteID = PW_ServiceNeedPartsList.AttributeMinuteID_AccountType INNER JOIN
                      AttributeMinuteList ON BM_PartsList.AttributeMinuteID_Unit = AttributeMinuteList.AttributeMinuteID

WHERE   PW_ServiceNeedPartsList.ServiceWorkBillID=@ServiceWorkBillID
END
IF(@TYPE='FRM_QianTaiJieDai_btnApproval_Click_InsertChuKuCunMingXi')
BEGIN
INSERT     PW_OutStorageBillMinuteList(OutStorageBillID, BespeakPartsID)
VALUES         (@OutStorageBillID, @BespeakPartsID)

END
IF(@TYPE='FRM_QianTaiJieDai_btnApproval_Click_Click_InsertKu')
BEGIN
INSERT     PW_OutStorageBillList(OutStorageBillNumber, IfVerify, IfOutStorage)
VALUES         (@OutStorageBillNumber, @IfVerify, @IfOutStorage)
SELECT @@IDENTITY 
END

第二步:逻辑层(BLL)

//查询预约配件
[OperationContract]
        public DataSet FRM_QianTaiJieDai_SelectBespeakParts(int intServiceWorkBillID)
        {
            SqlParameter[] mySqlParameters =
        {
        new SqlParameter("@TYPE",SqlDbType.Char),
        new SqlParameter("@ServiceWorkBillID",SqlDbType.Int),
        };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_SelectBespeakParts";
            mySqlParameters[1].Value = intServiceWorkBillID;
            DataTable dt = myDALMethod.QueryDataTable("前台接待_FRM_QianTaiJieDai", mySqlParameters);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            return ds; //返回数据集
        }
//修改字段【核准否】
[OperationContract]
        public int FRM_QianTaiJieDai_UpdateIfApproval(DateTime dtmApprovalTime, string strApprovalPerson, int intServiceWorkBillID)
        {
            SqlParameter[] mySqlParameters =
        {
        new SqlParameter("@TYPE",SqlDbType.Char),
        new SqlParameter("@ApprovalTime",SqlDbType.DateTime),
        new SqlParameter("@ApprovalPerson",SqlDbType.NChar),
        new SqlParameter("@ServiceWorkBillID",SqlDbType.Int),
        };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_UpdateIfApproval";
            mySqlParameters[1].Value = dtmApprovalTime;
            mySqlParameters[2].Value = strApprovalPerson;
            mySqlParameters[3].Value = intServiceWorkBillID;
            return myDALMethod.UpdateData("前台接待_FRM_QianTaiJieDai", mySqlParameters);
//返回值为1,是在正常的,小于0是异常的。
        }
//查询维修配件
[OperationContract]
        public DataSet FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian(int intServiceWorkBillID)
        {
            SqlParameter[] mySqlParameters =
        {
        new SqlParameter("@TYPE",SqlDbType.Char),
        new SqlParameter("@ServiceWorkBillID",SqlDbType.Int),
        };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian";
            mySqlParameters[1].Value = intServiceWorkBillID;
            DataTable dt = myDALMethod.QueryDataTable("前台接待_FRM_QianTaiJieDai", mySqlParameters);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            return ds; //返回数据集
        }
//新增预留出库
[OperationContract]
        public int FRM_QianTaiJieDai_btnApproval_Click_Click_InsertKu(string strChuKuDanHao, bool boolShenHeFou, bool boolChuKuFou)
        {
            SqlParameter[] mySqlParameters =
       {
            new SqlParameter("@TYPE",SqlDbType.Char),
            new SqlParameter("@OutStorageBillNumber",SqlDbType.NChar),
            new SqlParameter("@IfVerify",SqlDbType.Bit),
            new SqlParameter("@IfOutStorage",SqlDbType.Bit),
       };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_btnApproval_Click_Click_InsertKu";
            mySqlParameters[1].Value = strChuKuDanHao;
            mySqlParameters[2].Value = boolShenHeFou;
            mySqlParameters[3].Value = boolChuKuFou;
            DataTable dt = myDALMethod.QueryDataTable("前台接待_FRM_QianTaiJieDai", mySqlParameters);
            return Convert.ToInt32(dt.Rows[0][0]); //返回新增单据的ID
        }
//新增预留出库明细
        [OperationContract]
        public int FRM_QianTaiJieDai_btnApproval_Click_InsertChuKuCunMingXi(int intChuKuDanID, int intYuYuePeiJianID)
        {
            SqlParameter[] mySqlParameters =
       {
            new SqlParameter("@TYPE",SqlDbType.Char),
            new SqlParameter("@OutStorageBillID",SqlDbType.Int),
            new SqlParameter("@BespeakPartsID",SqlDbType.Int),
       };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_btnApproval_Click_InsertChuKuCunMingXi";
            mySqlParameters[1].Value = intChuKuDanID;
            mySqlParameters[2].Value = intYuYuePeiJianID;
            return myDALMethod.UpdateData("前台接待_FRM_QianTaiJieDai", mySqlParameters);
//返回值为1,是在正常的,小于0是异常的。
        }

第三步:界面层(UIL)

BLL海马汽车销售系统.前台接待.FRM_QianTaiJieDai.FRM_QianTaiJieDaiClient myFRM_QianTaiJieDaiClient = 
            new BLL海马汽车销售系统.前台接待.FRM_QianTaiJieDai.FRM_QianTaiJieDaiClient();
private void btnApproval_Click(object sender, EventArgs e)
        {
            int intApproval = 0;
            int intChuKuDan = 0;
            if (Convert.ToBoolean(dgvServiceWorkingBill.CurrentRow.Cells["核准否"].Value) == false)//如果所选单据还未核准
            {
                //根据维修工单ID查询释放的预约配件
                DataTable dtBespeakParts = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_SelectBespeakParts(Convert.ToInt32(dgvServiceWorkingBill.CurrentRow.Cells["维修工单ID"].Value)).Tables[0];
                if (dtBespeakParts.Rows.Count > 0)//如果释放过配件
                {
                    intServiceWorkingBillID = Convert.ToInt32(dgvServiceWorkingBill.CurrentRow.Cells["维修工单ID"].Value);                   
                    FRM_HuanYuanShiFangPeiJian myFRM_HuanYuanShiFangPeiJian = new FRM_HuanYuanShiFangPeiJian();
                    myFRM_HuanYuanShiFangPeiJian.ShowDialog();//显示【释放配件还原】
                }
                //【提示】对话框,如果点击【是】
                if (MessageBox.Show("确定核准此单据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //改变【核准否】状态
                    intApproval = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_UpdateIfApproval(DateTime.Now, FRM_Login.strStaffName, Convert.ToInt32(dgvServiceWorkingBill.CurrentRow.Cells["维修工单ID"].Value));
                    //查询维修配件
                    DataTable dtWeiXiuXuQiuPeiJian = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian(Convert.ToInt32(dgvServiceWorkingBill.CurrentRow.Cells["维修工单ID"].Value)).Tables[0];
                    if (dtWeiXiuXuQiuPeiJian.Rows.Count > 0)//如果有维修配件
                    {
                        string strXiaoShouShouKuan = "CK";
                        string strChuKuDanHao = ShengChengDanHao(strXiaoShouShouKuan);//生成出库单号
                        bool boolShenHeFou = false;
                        bool boolChuKuFou = false;
                        intChuKuDan = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_btnApproval_Click_Click_InsertKu(strChuKuDanHao, boolShenHeFou, boolChuKuFou);
                        for (int i = 0; i < dtWeiXiuXuQiuPeiJian.Rows.Count; i++)//循环维修配件
                        {
                            int intChuKuDanID = intChuKuDan;
                            int intYuYuePeiJianID = Convert.ToInt32(dtWeiXiuXuQiuPeiJian.Rows[i]["ServiceNeedPartsID"]);
                            //生成出库明细表
                            int intChuKuMingXi = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_btnApproval_Click_InsertChuKuCunMingXi(intChuKuDanID, intYuYuePeiJianID);
                        }
                        if (intApproval > 0 && intChuKuDan > 0)
                        {
                            MessageBox.Show("核准成功,预约配件库存可售数充足,已生成一张预留出库单," + "\n单号为【" + strChuKuDanHao + "】");
                            FRM_QianTaiJieDai_Load(null, null);
                        }
                    }
                    else//如果没有维修配件
                    {
                        //改变【核准否】状态
                        intApproval = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_UpdateIfApproval(DateTime.Now, FRM_Login.strStaffName, Convert.ToInt32(dgvServiceWorkingBill.CurrentRow.Cells["维修工单ID"].Value));
                    }
                    if (intApproval > 0 )
                    {
                        MessageBox.Show("核准成功!");
                        FRM_QianTaiJieDai_Load(null, null);//调用方法刷新dgv(维修工单)
                    }
                }
            }
            else//如果所选单据已审核
            {
                MessageBox.Show("请选择未核准单据再进行此操作!");
            }           
        }

2、【释放配件还原】界面的还原功能

第一步:数据库存储过程

IF(@TYPE='FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian')
BEGIN
SELECT     PW_ServiceNeedPartsList.ServiceNeedPartsID, PW_ServiceNeedPartsList.PartsID, PW_ServiceNeedPartsList.AttributeMinuteID_AccountType AS AccountTypeID, 
                      PW_ServiceNeedPartsList.NeedNumber, PW_ServiceNeedPartsList.SellPrice, PW_ServiceNeedPartsList.Discount, PW_ServiceNeedPartsList.InsurePercentage, 
                      PW_ServiceNeedPartsList.PrivilegeAfterOfMoney, PW_ServiceNeedPartsList.Remarks, BM_PartsList.PartsCoding, BM_PartsList.PartsName, BM_PartsList.CarModels, 
                      AttributeMinuteList.AttributeMinuteName AS unit, AttributeMinuteList_1.AttributeMinuteName AS AccountType
FROM         AttributeMinuteList AS AttributeMinuteList_1 INNER JOIN
                      PW_ServiceNeedPartsList INNER JOIN
                      BM_PartsList ON PW_ServiceNeedPartsList.PartsID = BM_PartsList.PartsID ON AttributeMinuteList_1.AttributeMinuteID = PW_ServiceNeedPartsList.AttributeMinuteID_AccountType INNER JOIN
                      AttributeMinuteList ON BM_PartsList.AttributeMinuteID_Unit = AttributeMinuteList.AttributeMinuteID
WHERE   PW_ServiceNeedPartsList.ServiceWorkBillID=@ServiceWorkBillID
END
IF(@TYPE='FRM_QianTaiJieDai_JieChe_InsertWeiXiuPeiJian')
 BEGIN
INSERT     PW_ServiceNeedPartsList(ServiceWorkBillID, PartsID, AttributeMinuteID_AccountType, NeedNumber, AttributeMinuteID_Unit, SellPrice, Discount, PrivilegeAfterOfMoney, Remarks)
VALUES         (@ServiceWorkBillID, @PartsID, @AttributeMinuteID_AccountType, @NeedNumber, @AttributeMinuteID_Unit, @SellPrice, @Discount, @PrivilegeAfterOfMoney, @Remarks)
 END
IF(@TYPE='FRM_QianTaiJieDai_UpdateBespeakPartsIfResourceRelease')
BEGIN
UPDATE     PW_BespeakPartsList 
SET        IfResourceRelease=0 
WHERE BespeakPartsID=@BespeakPartsID
END

第二步:逻辑层(BLL)

//修改预约配件的释放状态
[OperationContract]
        public int FRM_QianTaiJieDai_UpdateBespeakPartsIfResourceRelease(int intBespeakPartsID)
        {
            SqlParameter[] mySqlParameters =
        {
        new SqlParameter("@TYPE",SqlDbType.Char),
        new SqlParameter("@BespeakPartsID",SqlDbType.Int),
        };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_UpdateBespeakPartsIfResourceRelease";
            mySqlParameters[1].Value = intBespeakPartsID;
            return myDALMethod.UpdateData("前台接待_FRM_QianTaiJieDai", mySqlParameters);
//返回值为1是正常的,小于0是不正常的。

        }
//查询需求配件
[OperationContract]
        public DataSet FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian(int intServiceWorkBillID)
        {
            SqlParameter[] mySqlParameters =
        {
        new SqlParameter("@TYPE",SqlDbType.Char),
        new SqlParameter("@ServiceWorkBillID",SqlDbType.Int),
        };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian";
            mySqlParameters[1].Value = intServiceWorkBillID;
            DataTable dt = myDALMethod.QueryDataTable("前台接待_FRM_QianTaiJieDai", mySqlParameters);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            return ds; //返回数据集
        }
//新增需求配件
[OperationContract]
        public int FRM_QianTaiJieDai_JieChe_InsertWeiXiuPeiJian(int intWeiXiuDanMingXiID, int intPeiJianID, int intZhangLei, decimal decXuQiuShuLiang, int intDanWei,
            decimal decXiaoShouDanJian, decimal decZheKo, decimal decYouHuiHouJinE, string strBeiZhu)
        {
            SqlParameter[] mySqlParameters =
       {
            new SqlParameter("@TYPE",SqlDbType.Char),
            new SqlParameter("@ServiceWorkBillID",SqlDbType.Int),
            new SqlParameter("@PartsID",SqlDbType.Int),
            new SqlParameter("@AttributeMinuteID_AccountType",SqlDbType.Int),
            new SqlParameter("@NeedNumber",SqlDbType.Decimal),
            new SqlParameter("@AttributeMinuteID_Unit",SqlDbType.Int),
            new SqlParameter("@SellPrice",SqlDbType.Decimal),
            new SqlParameter("@Discount",SqlDbType.Decimal),
            new SqlParameter("@PrivilegeAfterOfMoney",SqlDbType.Decimal),
            new SqlParameter("@Remarks",SqlDbType.NChar),
       };
            mySqlParameters[0].Value = "FRM_QianTaiJieDai_JieChe_InsertWeiXiuPeiJian";
            mySqlParameters[1].Value = intWeiXiuDanMingXiID;
            mySqlParameters[2].Value = intPeiJianID;
            mySqlParameters[3].Value =  intZhangLei;
            mySqlParameters[4].Value = decXuQiuShuLiang;
            mySqlParameters[5].Value = intDanWei;
            mySqlParameters[6].Value = decXiaoShouDanJian;
            mySqlParameters[7].Value = decZheKo;
            mySqlParameters[8].Value = decYouHuiHouJinE;
            mySqlParameters[9].Value = strBeiZhu;
            return myDALMethod.UpdateData("前台接待_FRM_QianTaiJieDai", mySqlParameters);
//返回值为1是正常的,小于0是不正常的。
        }

第三步:界面层(UIL)

BLL海马汽车销售系统.前台接待.FRM_QianTaiJieDai.FRM_QianTaiJieDaiClient myFRM_QianTaiJieDaiClient = 
            new BLL海马汽车销售系统.前台接待.FRM_QianTaiJieDai.FRM_QianTaiJieDaiClient();
private void btnRestore_Click(object sender, EventArgs e)
        {
            //查询维修配件
            DataTable dtServiceParts = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_Update_Load_SelectXuQiuPeiJian(FRM_QianTaiJieDai.intServiceWorkingBillID).Tables[0];
            if (dtServiceParts.Rows.Count > 0)//表不为空
            {
                for (int i = 0; i < dtServiceParts.Rows.Count; i++)//循环表
                {
                    for (int j = 0; j < dgvBespeakParts.Rows.Count; j++)//循环dgv
                    {
                        if (Convert.ToBoolean(dgvBespeakParts.Rows[j].Cells["选择"].Value) == true)//如果名为【选择】的列打上勾
                        {
                              //如果【释放配件还原】界面上的配件已在维修配件里存在
                            if (Convert.ToInt32(dtServiceParts.Rows[i]["PartsID"]) == Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["配件ID"].Value))
                            {
                                intChongFu++;
                                dgvBespeakParts.Rows.Remove(dgvBespeakParts.Rows[j]);//从dgv上移除这已配件
                            }
                            else
                            { }
                        }
                    }
                }
            }
            if (dgvBespeakParts.Rows.Count > 0)//如果dgv不为空
            {
                for (int j = 0; j < dgvBespeakParts.Rows.Count; j++)//循环dgv
                {
                    if (Convert.ToBoolean(dgvBespeakParts.Rows[j].Cells["选择"].Value) == true)//如果名为【选择】的列打上勾
                    {
                        //给参数赋值
                        int intWeiXiuGongDan = FRM_QianTaiJieDai.intServiceWorkingBillID;
                        int intPeiJianID = Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["配件ID"].Value);
                        int intZhangLei = Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["帐类ID"].Value);
                        decimal decXuQiuShuLiang = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["需求数量"].Value);
                        int intDanWei = Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["单位ID"].Value);
                        decimal decXiaoShouDanJian = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["单价"].Value);
                        DataTable dtAttributeMinuteListRemark = myFRM_QianTaiJieDai_JieCheClient.FRM_QianTaiJieDai_JieChe_SelectAttributeMinuteListRemark(Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["帐类ID"].Value)).Tables[0];
                        decimal decZheKo = Convert.ToDecimal(dtAttributeMinuteListRemark.Rows[0]["Remark"]);
                        decimal decYouHuiHouJinE = Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["需求数量"].Value) * Convert.ToDecimal(dgvBespeakParts.Rows[j].Cells["单价"].Value) * decZheKo / 100;
                        string strBeiZhu1 = "";
                        decimal decKeShouShu = KuCun(Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["配件ID"].Value));
                        if (decXuQiuShuLiang > decKeShouShu)//如果库存不足
                        {
                                                   }
                        else//如果库存充足
                        {
//添加到维修配件中
                            intXuQiuPeiJian = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_JieChe_InsertWeiXiuPeiJian(intWeiXiuGongDan, intPeiJianID, intZhangLei,
                               decXuQiuShuLiang, intDanWei, decXiaoShouDanJian, decZheKo, decYouHuiHouJinE, strBeiZhu1);
                            //改变配件释放状态
                            int intBespeakPartsIfResourceRelease = myFRM_QianTaiJieDaiClient.FRM_QianTaiJieDai_UpdateBespeakPartsIfResourceRelease(Convert.ToInt32(dgvBespeakParts.Rows[j].Cells["预约配件ID"].Value));
                                                    }
                    }
                }
            }


以上仅供学习参考,禁止用于商业用途!!!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值