您的位置:首页 > 其它

用友ERT T6 技术解析(四)采购入库 下

2015-05-31 18:27 316 查看
7、新增采购订单
第一步:数据库的存储过程
(1)新增单据表——采购入库单

<p align="left"></p><pre name="code" class="sql">if(@Type='tlsbSave_Click_InsertBePutInStorageReceipts')


--新增单据表——采购入库单
BEGIN
INSERT INTOTheDocumentsTable
(NameOfDocuments,  --单据名称
DocumentNumber,   --单据编号
DateOfDocuments,  --单据日期
TypeOfDocumen,  --单据类型
InThisPaper)  --摘要
VALUES (@NameOfDocuments, @DocumentNumber,
@DateOfDocuments, @TypeOfDocumen, @InThisPaper)
SELECT @@IDENTITY
END



(2)新增采购入库单

if(@Type='tlsbSave_Click_InsertPurchaseOrderForm')
--新增采购入库单
BEGIN
INSERT INTOPurchaseReceiptTable
(DocumentsID_PurchaseOrder,   --单据ID_采购单
DocumentsID_GRN,  --单据ID_入库单ID
InAndOutOfInventoryRecordID,  --出入库存记录ID
DocumentsInvoice,  --提单号
BusinessNo,  --业务号
CustomerID,   --客户ID
Note,   --备注
TheOperatorID_MakingPeople,   --操作员ID_制单人
TheOperatorID_personOfChargeToAnAccount,  -操作员ID_记账人
TheOperatorID_Salesman,  --操作员ID_业务员
BusinessTypeID,  --业务类型ID
ReviewWhether) --审核否
VALUES (@DocumentsID_PurchaseOrder,@DocumentsID_GRN,
@InAndOutOfInventoryRecordID,@DocumentsInvoice,
@BusinessNo, @CustomerID,@Note,       @TheOperatorID_MakingPeople,@TheOperatorID_personOfChargeToAnAccount,@TheOperatorID_Salesman,@BusinessTypeID,0)
SELECT @@IDENTITY   --查询刚新增的单据ID
END


(3)查询仓库对应的存货没有的新增存货

if(@Type='tlsbBeLaidUp_Click_SelectStorageANInventory')
--查询仓库对应的存货没有的新增存货
BEGIN
SELECT   TheInventoryIDAS 存货ID
FROM         TheInventoryTable
WHERE  TheInventoryTable.WarehouseID=@WarehouseID--仓库ID
AND    TheInventoryTable.ProductID = @ProductID   --产品ID
END


(4)新增存货

if(@Type='tlsbBeLaidUp_Click_InsertInventory')  --新增存货
BEGIN
INSERT INTOTheInventoryTable
(InventoryClassificationID,  --存货分类ID
ProductID,   --产品ID
WarehouseID,   --仓库ID
TheExistingQuantity,   --现存数量
DocumentID)  --单据ID
VALUES (@InventoryClassificationID,@ProductID,
@WarehouseID, @TheExistingQuantity, @DocumentID)
END


(5)新增明细表

if(@Type='tlsbSave_Click_InsertInventory')  --新增明细表
BEGIN
INSERT INTOPurchasingScheduleOfPutInStorage
(TheInventoryID, Quantity, Amount, PurchaseReceiptID)
VALUES (@TheInventoryID,--存货ID
@Quantity,--数量
@Amount,--
@PurchaseReceiptID)--采购入库单ID
END


第二步:逻辑层(BLL)代码

(1) 新增单据表——采购单

///<summary>
///  新增单据表——采购单
///</summary>
///<paramname="strNameOfDocuments">单据名称</param>
///<paramname="strDocumentNumber">单据编号</param>
///<paramname="dtpDateOfDocuments">单据日期</param>
///<paramname="strTypeOfDocumen">单据类型</param>
///<param name="strInThisPaper">摘要</param>
///<returns></returns>
[OperationContract]
public DataSettlsbSave_Click_InsertBePutInStorageReceipts(stringstrNameOfDocuments, string strDocumentNumber,
DateTimedtpDateOfDocuments,string strTypeOfDocumen,string strInThisPaper)
{
myParameter.InsertnameOfDocuments =strNameOfDocuments;
myParameter.DocumentNumber =strDocumentNumber;
myParameter.DateOfDocuments =dtpDateOfDocuments;
myParameter.TypeOfDocumen =strTypeOfDocumen;
myParameter.InThisPaper =strInThisPaper;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
newSqlParameter("@NameOfDocuments",SqlDbType.Char), //单据名称
new SqlParameter("@DocumentNumber", SqlDbType.Char), //单据编号
new SqlParameter("@DateOfDocuments", SqlDbType.DateTime), //单据日期
new SqlParameter("@TypeOfDocumen", SqlDbType.Char), //单据类型
new SqlParameter("@InThisPaper", SqlDbType.Char),//摘要
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertBePutInStorageReceipts";
SQlCMDpas[1].Value =myParameter.InsertnameOfDocuments;
SQlCMDpas[2].Value =myParameter.DocumentNumber;
SQlCMDpas[3].Value =myParameter.DateOfDocuments;
SQlCMDpas[4].Value =myParameter.TypeOfDocumen;
SQlCMDpas[5].Value =myParameter.InThisPaper;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(2) 新增采购入库单

///<summary>
///新增采购入库单
///</summary>
///<paramname="DocumentsID_PurchaseOrder">单据ID_采购单</param>
///<paramname="DocumentsID_GRN">单据ID_入库单ID</param>
///<paramname="InAndOutOfInventoryRecordID">出入库存记录ID</param>
///<paramname="DocumentsID_ToInvoice">单据ID_到货单</param>
///<paramname="BusinessNo">业务号</param>
///<paramname="CustomerID">客户ID</param>
///<paramname="Note">备注</param>
///<paramname="TheOperatorID_MakingPeople">操作员ID_制单人</param>
///<paramname="TheOperatorID_personOfChargeToAnAccount">操作员ID_记账人</param>
///<param name="TheOperatorID_Salesman">操作员ID_业务员</param>
///<paramname="BusinessTypeID">业务类型ID</param>
///<returns></returns>
[OperationContract]
public DataSet tlsbSave_Click_InsertPurchaseOrderForm(int DocumentsID_PurchaseOrder, int DocumentsID_GRN,
intInAndOutOfInventoryRecordID, stringDocumentsID_ToInvoice, string BusinessNo, int CustomerID
, stringNote, int TheOperatorID_MakingPeople, int TheOperatorID_personOfChargeToAnAccount, int TheOperatorID_Salesman
, int BusinessTypeID)
{
myParameter.DocumentsID_PurchaseOrder = DocumentsID_PurchaseOrder;
myParameter.DocumentsID_GRN =DocumentsID_GRN;
myParameter.InsertinAndOutOfInventoryRecordID = InAndOutOfInventoryRecordID;
myParameter.BusinessNo =BusinessNo;
myParameter.CustomerID =CustomerID;
myParameter.Note = Note;
myParameter.InserttheOperatorID_MakingPeople =TheOperatorID_MakingPeople;
myParameter.InserttheOperatorID_personOfChargeToAnAccount= TheOperatorID_personOfChargeToAnAccount;
myParameter.InserttheOperatorID_Salesman = TheOperatorID_Salesman;
myParameter.InsertbusinessTypeID =TheOperatorID_Salesman;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@DocumentsID_PurchaseOrder", SqlDbType.Int), //单据ID_采购单
newSqlParameter("@DocumentsID_GRN",SqlDbType.Int), //单据ID_入库单ID
new SqlParameter("@InAndOutOfInventoryRecordID", SqlDbType.Int), //出入库存记录ID
new SqlParameter("@DocumentsInvoice", SqlDbType.Char), //单据ID_到货单
new SqlParameter("@BusinessNo", SqlDbType.Char),//业务号
new SqlParameter("@CustomerID", SqlDbType.Int),//客户ID
new SqlParameter("@Note", SqlDbType.Char),//备注
new SqlParameter("@TheOperatorID_MakingPeople", SqlDbType.Int), //操作员ID_制单人
newSqlParameter("@TheOperatorID_personOfChargeToAnAccount",SqlDbType.Int), //操作员ID_记账人
new SqlParameter("@TheOperatorID_Salesman", SqlDbType.Int), //操作员ID_业务员
new SqlParameter("@BusinessTypeID",SqlDbType.Int), //业务类型ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertPurchaseOrderForm";
SQlCMDpas[1].Value =myParameter.DocumentsID_PurchaseOrder;
SQlCMDpas[2].Value =myParameter.DocumentsID_GRN;
SQlCMDpas[3].Value =myParameter.InsertinAndOutOfInventoryRecordID;
SQlCMDpas[4].Value =DocumentsID_ToInvoice;
SQlCMDpas[5].Value =myParameter.BusinessNo;
SQlCMDpas[6].Value =myParameter.CustomerID;
SQlCMDpas[7].Value =myParameter.Note;
SQlCMDpas[8].Value =myParameter.InserttheOperatorID_MakingPeople;
SQlCMDpas[9].Value =myParameter.InserttheOperatorID_personOfChargeToAnAccount;
SQlCMDpas[10].Value =myParameter.InserttheOperatorID_Salesman;
SQlCMDpas[11].Value =myParameter.InsertbusinessTypeID;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(3) 查询仓库对应的存货没有的新增存货

///<summary>
///查询仓库对应的存货
///</summary>
///<paramname="intWarehouseID">仓库ID</param>
///<paramname="intProductID">产品ID</param>
///<returns></returns>
[OperationContract]
public DataSettlsbBeLaidUp_Click_SelectStorageANInventory(intintWarehouseID, int intProductID)
{
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
newSqlParameter("@WarehouseID",SqlDbType.Int), //仓库ID
new SqlParameter("@ProductID", SqlDbType.Int),//产品ID
};
SQlCMDpas[0].Value = "tlsbBeLaidUp_Click_SelectStorageANInventory";
SQlCMDpas[1].Value =intWarehouseID;
SQlCMDpas[2].Value = intProductID;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(4) 新增存货

///<summary>
///新增存货
///</summary>
///<paramname="intInventoryClassificationID">存货分类ID</param>
///<paramname="intProductID">产品ID</param>
///<paramname="intWarehouseID">仓库ID</param>
///<param name="strTheExistingQuantity">现存数量</param>
///<paramname="intDocumentID">单据ID</param>
///<returns></returns>
[OperationContract]
public int tlsbBeLaidUp_Click_InsertInventory(int intInventoryClassificationID, int intProductID, intintWarehouseID,
stringstrTheExistingQuantity, int intDocumentID)
{
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
newSqlParameter("@InventoryClassificationID",SqlDbType.Int), //存货分类ID
new SqlParameter("@ProductID", SqlDbType.Int),//产品ID
new SqlParameter("@WarehouseID", SqlDbType.Int),//仓库ID
new SqlParameter("@TheExistingQuantity", SqlDbType.NChar),//现存数量
new SqlParameter("@DocumentID", SqlDbType.Int),//单据ID
};
SQlCMDpas[0].Value = "tlsbBeLaidUp_Click_InsertInventory";
SQlCMDpas[1].Value =intInventoryClassificationID;
SQlCMDpas[2].Value = intProductID;
SQlCMDpas[3].Value =intWarehouseID;
SQlCMDpas[4].Value = strTheExistingQuantity;
SQlCMDpas[5].Value = intDocumentID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


(5) 新增明细表

///<summary>
///新增明细表
///</summary>
///<paramname="intTheInventoryID">存货ID</param>
///<paramname="strQuantity">数量</param>
///<paramname="decAmount"></param>
///<paramname="intPurchaseReceiptID">采购入库单ID</param>
///<returns></returns>
[OperationContract]
public int tlsbSave_Click_InsertInventory(int intTheInventoryID, stringstrQuantity,
decimaldecAmount, int intPurchaseReceiptID)
{
myParameter.Inventory_TheInventoryID = intTheInventoryID;
myParameter.Inventory_Quantity =strQuantity;
myParameter.Inventory_Amount =decAmount;
myParameter.Inventory_PurchaseReceiptID = intPurchaseReceiptID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@TheInventoryID", SqlDbType.Int), //存货ID
new SqlParameter("@Quantity", SqlDbType.Char),//数量
new SqlParameter("@Amount", SqlDbType.Decimal),//
new SqlParameter("@PurchaseReceiptID", SqlDbType.Int),//采购入库单ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertInventory";
SQlCMDpas[1].Value =myParameter.Inventory_TheInventoryID;
SQlCMDpas[2].Value =myParameter.Inventory_Quantity;
SQlCMDpas[3].Value =myParameter.Inventory_Amount;
SQlCMDpas[4].Value =myParameter.Inventory_PurchaseReceiptID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


第三步:界面层(UIL)代码,在窗体的Load事件中绑定下拉框的数据
截图效果(点击新增按钮把表头数据录入完毕再把明细数据录完点击保存按钮):






#region 保存
private voidtlsbSave_Click(object sender, EventArgs e)
{
foreach(DataGridViewRow dgvr in dgvPurchaseBeLaidUp.Rows)    //dgv数量不能为空
{
if(dgvr != dgvPurchaseBeLaidUp.Rows[dgvPurchaseBeLaidUp.Rows.Count - 1])
{
try
{
if (dgvr.Cells["数量"].Value.ToString().Trim() == "")
{
MessageBox.Show("明细数量有空!请填满!");
return;
}
}
catch{ return; }
}
}
if(txtArrivalOfGoodsNumber.Text == "")
{
MessageBox.Show("提单号没填!");
txtArrivalOfGoodsNumber.Focus();
return;
}
if(txtArrivalOfGoodsNumber.Text.Length != 10)
{
MessageBox.Show("提单号为10位数字!");
txtArrivalOfGoodsNumber.Focus();
return;
}
if(bolNewlyIncreased == true)  //判断是否新增
{
if(dgvPurchaseBeLaidUp.Rows.Count == 1)    //判断明细有木有数据
{
MessageBox.Show("明细没有数据!新增订单没有意义!请添加数据!");
return;
}

stringstrMaximumOddNumber =myfrm_PurchaseOddNumbers.frm_PurchaseOddNumbers_Load_SelectMaximumReceipts().Tables[0].Rows[0][0].ToString().Trim();//获取最大单据数
switch(strMaximumOddNumber.Length)
{
case1:
strMaximumOddNumber = "000" + strMaximumOddNumber;
break;
case2:
strMaximumOddNumber = "00" + strMaximumOddNumber;
break;
case3:
strMaximumOddNumber = "0" + strMaximumOddNumber;
break;
default:
break;
}

txtBusinessNumber.Text = PublicStaticMothd.BusinessNumber("YW",myfrm_PurchaseOddNumbers.frm_PurchaseOddNumbers_Load_SelectMaximumBusiness().Tables[0].Rows[0][0].ToString().Trim());//获取最大业务号

txtIndentNumber.Text = PublicStaticMothd.ShengChengDanHao("CG", strMaximumOddNumber).Trim();

intintReceiptsNumber = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertBePutInStorageReceipts("采购单", txtIndentNumber.Text.Trim(),
Convert.ToDateTime(DateTime.Now.ToString().Trim()), "采购单", txtRemark.Text.Trim()).Tables[0].Rows[0][0]);                                //新增采购单据  获取 单据ID

intintIfSucceed = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertPurchaseOrderForm(intReceiptsNumber,0, 0, txtArrivalOfGoodsNumber.Text, txtBusinessNumber.Text.Trim(),
Convert.ToInt32(cboSupplyOfMaterialUnit.SelectedValue.ToString().Trim()),txtRemark.Text.Trim(), Convert.ToInt32(cboReceiptsProducer.SelectedValue.ToString().Trim()),
Convert.ToInt32(cboTallyPerson.SelectedValue.ToString().Trim()),Convert.ToInt32(cboBusinessNumber.SelectedValue.ToString().Trim()),
Convert.ToInt32(cboBusinessType.SelectedValue.ToString().Trim())).Tables[0].Rows[0][0]);                                                                                       //采购单

for(int intRowsCount = 0; intRowsCount <dgvPurchaseBeLaidUp.Rows.Count - 1; intRowsCount++)//遍历新增明细表
{
intintProductID = Convert.ToInt32(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["产品ID"].Value.ToString().Trim());
stringstrQuantity = dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["数量"].Value.ToString().Trim();
if(!(myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_SelectStorageANInventory(Convert.ToInt32(cboStorage.SelectedValue.ToString()),intProductID).Tables[0].Rows.Count > 0))//根据仓库ID 与 产品ID 查询存货,没有的新增存货
{
myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_InsertInventory(Convert.ToInt32(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["存货分类"].Value.ToString().Trim()),
intProductID, Convert.ToInt32(cboStorage.SelectedValue.ToString().Trim()),"0", intIfSucceed);
}
intintTheInventoryID = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_SelectStorageANInventory(Convert.ToInt32(cboStorage.SelectedValue.ToString()),intProductID).Tables[0].Rows[0][0].ToString().Trim());//根据产品ID 与 仓库ID 查询存货ID
decimaldecAmount = Convert.ToDecimal(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["金额"].Value.ToString().Trim());
decimaldecUnitPrice = Convert.ToDecimal(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["单价"].Value.ToString().Trim());
myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertInventory(intTheInventoryID,strQuantity, decAmount, intIfSucceed);//新增明细表
}
if(intIfSucceed > 0)
{
intTpage = 0;
PageSkip(intTpage);
ChangeColour();
bolNewlyIncreased = false;//标识不新增
Popup.Controls.Frm_Popup.Instance().TextAssignment(string.Format("\n操作员 【 {0} 】\n刚刚新增了采购订单【{1}】", PublicStaticFields.strOperatorName,txtIndentNumber.Text.Trim()));  //显示文本输入
Popup.Controls.Frm_Popup.Instance().Show();            //  显示信息
timCurrentDate.Enabled = false;//关闭 获取当前时间计时器
ClosePromptCancel();//隐藏判断输入框是否合法图片
MessageBox.Show("新增成功!");
}
}
}


8、修改采购订单
第一步:数据库的存储过程
(1) 修改订单

if(@Type='tlsbSave_Click_ModificationReceipts') --修改订单
BEGIN
UPDATE    PurchaseReceiptTable
SET   CustomerID = @CustomerID,--客户ID
Note =@Note,    --备注
TheOperatorID_MakingPeople = @TheOperatorID_MakingPeople, --制单人ID
TheOperatorID_personOfChargeToAnAccount= @TheOperatorID_personOfChargeToAnAccount, --记账人ID
TheOperatorID_Salesman= @TheOperatorID_Salesman, --业务员ID
BusinessTypeID=@BusinessTypeID  --业务类型ID
WHEREPurchaseReceiptTable.PurchaseReceiptID = @PurchaseReceiptID --采购入库单ID
END


(2) 修改出入库

if(@Type='tlsbSave_Click_ModificationTakeNotes') --修改出入库
BEGIN
UPDATE InAndOutOfInventoryRecord
SET   ForTheTypeID= @ForTheTypeID--出入库类型ID
WHERE InAndOutOfInventoryRecord.InAndOutOfInventoryRecordID
=@InAndOutOfInventoryRecordID --出入库记录ID
END


(3) 修改单据明细

if(@Type='tlsbSave_Click_ModificationList')  --修改明细
BEGIN
UPDATE  PurchasingScheduleOfPutInStorage
SET     TheInventoryID=@TheInventoryID, -- 存货ID
Quantity =   @Quantity , --数量,
Amount =@Amount  -- 金额
WHERE PurchasingScheduleOfPutInStorage.ProcurementWarehousingDetailID
= @ProcurementWarehousingDetailID--采购入库单明细ID
END


(4) 删除单据明细
if(@Type='tlsbDelete_Click_DaletePurchaseOrderFormList')  --删除采购入库明细单
BEGIN
DELETE FROMPurchasingScheduleOfPutInStorage
WHERE PurchasingScheduleOfPutInStorage.ProcurementWarehousingDetailID=
@ProcurementWarehousingDetailID   --采购入库明细ID
END


第二步:逻辑层(BLL)代码

(1) 修改订单
///<summary>
///修改订单
///</summary>
///<paramname="intCustomerID">客户ID</param>
///<paramname="strNote">备注</param>
///<param name="intTheOperatorID_MakingPeople">制单人ID</param>
///<paramname="intTheOperatorID_personOfChargeToAnAccount">记账人ID</param>
///<paramname="intTheOperatorID_Salesman">业务员ID</param>
///<paramname="intBusinessTypeID">业务类型ID</param>
///<returns></returns>
[OperationContract]
public int tlsbSave_Click_ModificationReceipts(int intCustomerID, stringstrNote, int intTheOperatorID_MakingPeople,
intintTheOperatorID_personOfChargeToAnAccount, intintTheOperatorID_Salesman, intintBusinessTypeID, int intPurchaseReceiptID)
{
myParameter.UpdateCustomerID =intCustomerID;
myParameter.UpdateNote = strNote;
myParameter.TheOperatorID_MakingPeople = intTheOperatorID_MakingPeople;
myParameter.TheOperatorID_personOfChargeToAnAccount =intTheOperatorID_personOfChargeToAnAccount;
myParameter.TheOperatorID_Salesman= intTheOperatorID_Salesman;
myParameter.BusinessTypeID =intBusinessTypeID;
myParameter.UpdatepurchaseReceiptID= intPurchaseReceiptID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@CustomerID", SqlDbType.Int),//客户ID
new SqlParameter("@Note", SqlDbType.Char),//备注
new SqlParameter("@TheOperatorID_MakingPeople", SqlDbType.Int),//制单人ID
new SqlParameter("@TheOperatorID_personOfChargeToAnAccount",SqlDbType.Int),//记账人ID
new SqlParameter("@TheOperatorID_Salesman", SqlDbType.Int),//业务员ID@
new SqlParameter("@BusinessTypeID", SqlDbType.Int),//业务类型ID
new SqlParameter("@PurchaseReceiptID", SqlDbType.Int),//采购入库单ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_ModificationReceipts";
SQlCMDpas[1].Value =myParameter.UpdateCustomerID;
SQlCMDpas[2].Value =myParameter.UpdateNote;
SQlCMDpas[3].Value =myParameter.TheOperatorID_MakingPeople;
SQlCMDpas[4].Value =myParameter.TheOperatorID_personOfChargeToAnAccount;
SQlCMDpas[5].Value =myParameter.TheOperatorID_Salesman;
SQlCMDpas[6].Value =myParameter.BusinessTypeID;
SQlCMDpas[7].Value = myParameter.UpdatepurchaseReceiptID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


(2) 修改出入库

///<summary>
///修改出入库类型
///</summary>
///<paramname="intForTheTypeID">出入库类型ID</param>
///<paramname="intInAndOutOfInventoryRecordID">出入库记录ID</param>
///<returns></returns>
[OperationContract]
public int tlsbSave_Click_ModificationTakeNotes(int intForTheTypeID, intintInAndOutOfInventoryRecordID)
{
myParameter.UpdatepurchaseReceiptID =intForTheTypeID;
myParameter.UpdateInAndOutOfInventoryRecordID =intInAndOutOfInventoryRecordID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@ForTheTypeID", SqlDbType.Int), //出入库类型ID
new SqlParameter("@InAndOutOfInventoryRecordID", SqlDbType.Int),//出入库记录ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_ModificationTakeNotes";
SQlCMDpas[1].Value =myParameter.UpdatepurchaseReceiptID;
SQlCMDpas[2].Value =myParameter.UpdateInAndOutOfInventoryRecordID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


(3) 修改单据明细
///<summary>
///修改采购明细
///</summary>
///<paramname="intTheInventoryID">存货ID</param>
///<param name="strQuantity">数量</param>
///<paramname="decAmount">金额</param>
///<paramname="intProcurementWarehousingDetailID">采购入库单明细ID</param>
///<returns></returns>
[OperationContract]
public int tlsbSave_Click_ModificationList(int intTheInventoryID, stringstrQuantity, decimal decAmount
, intintProcurementWarehousingDetailID)
{
myParameter.UpdateTheInventoryID =intTheInventoryID;
myParameter.UpdateQuantity =strQuantity;
myParameter.UpdateAmount= decAmount;
myParameter.UpdateProcurementWarehousingDetailID =intProcurementWarehousingDetailID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@TheInventoryID", SqlDbType.Int),//存货ID
new SqlParameter("@Quantity", SqlDbType.Char),//数量
new SqlParameter("@Amount",SqlDbType.Decimal),//金额
new SqlParameter("@ProcurementWarehousingDetailID", SqlDbType.Int),//采购入库单明细ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_ModificationList";
SQlCMDpas[1].Value =myParameter.UpdateTheInventoryID;
SQlCMDpas[2].Value =myParameter.UpdateQuantity;
SQlCMDpas[3].Value =myParameter.UpdateAmount;
SQlCMDpas[4].Value =myParameter.UpdateProcurementWarehousingDetailID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


(4) 删除单据明细

///<summary>
///删除采购入库明细
///</summary>
///<param name="intProcurementWarehousingDetailID">采购入库单明细ID</param>
///<returns></returns>
[OperationContract]
public int tlsbDelete_Click_DaletePurchaseOrderFormList(int intProcurementWarehousingDetailID)
{
myParameter.DeleteProcurementWarehousingDetailID= intProcurementWarehousingDetailID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@ProcurementWarehousingDetailID", SqlDbType.Int),//采购入库单明细ID
};
SQlCMDpas[0].Value = "tlsbDelete_Click_DaletePurchaseOrderFormList";
SQlCMDpas[1].Value =myParameter.DeleteProcurementWarehousingDetailID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
}


第三步:界面层(UIL)代码,在窗体的Load事件中绑定下拉框的数据
(1) 记录删除单据明细数据,点击保存的时候在删除
截图效果(先点击修改按钮在明细表里,选择行右键删除):





<p align="left"><span style="color: rgb(43, 145, 175);">DataTable</span> dtListDeleteID = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">DataTable</span>();            <span style="color: green;">//</span><span style="color: green;">记录修改订单 </span>删除的明细ID</p><p align="left"><span style="color: blue;">#region</span> 右键删除dgv明细右键菜单 删除键</p>
privatevoid 删除当前选择行ToolStripMenuItem_Click(objectsender, EventArgs e)  //
{
if((bolWhetherWhether == true ||bolNewlyIncreased == true) &&dgvPurchaseBeLaidUp.CurrentRow.Index > 0) //修改或者新增
{
DataTabledtListID = new DataTable();
dtListID.Columns.Add("采购入库明细ID");
dtListID.Columns.Add("产品ID");
if(dgvPurchaseBeLaidUp.Rows.Count > 1)           //dgv 行大于1行
{
for (int intCount = 0; intCount <dgvPurchaseBeLaidUp.SelectedRows.Count; intCount++)   //遍历所选择的行
{
if (bolWhetherWhether == true&& dgvPurchaseBeLaidUp.Rows[intCount].Cells["采购入库明细ID"].Value != null)
{
dtListID.Rows.Add();
dtListID.Rows[dtListID.Rows.Count - 1]["采购入库明细ID"] =
dgvPurchaseBeLaidUp.Rows[dgvPurchaseBeLaidUp.SelectedRows[intCount].Index].Cells["采购入库明细ID"].Value;//获取要删除的明细ID到datatable保存
dtListID.Rows[dtListID.Rows.Count - 1]["产品ID"] =
dgvPurchaseBeLaidUp.Rows[dgvPurchaseBeLaidUp.SelectedRows[intCount].Index].Cells["产品ID"].Value;//获取要删除的产品ID到datatable保存
}
if (dgvPurchaseBeLaidUp.Rows.Count - 1 !=dgvPurchaseBeLaidUp.SelectedRows[intCount].Index)  //删除行不是最后一行
{
int intProduct = Convert.ToInt32(dgvPurchaseBeLaidUp.SelectedRows[intCount].Cells["产品ID"].Value.ToString().Trim());
for (int intRows = 0;intRows < dgvInventory.Rows.Count; intRows++)
{
if (Convert.ToInt32(dgvInventory.Rows[intRows].Cells["产品ID"].Value.ToString().Trim()) == intProduct)
{
dgvInventory.Rows[intRows].DefaultCellStyle.BackColor = Color.White;
}
}
dgvPurchaseBeLaidUp.Rows.RemoveAt(dgvPurchaseBeLaidUp.SelectedRows[intCount].Index);//删除行
intCount--;    //减去索引
}
}
}
DataViewdvListID = new DataView(dtListID);
dtListDeleteID =dvListID.ToTable(true, "采购入库明细ID", "产品ID");   //返回不含相同行的数据集
}
}
#endregion


(2) 修改订单
截图效果(修改完毕后点击保存按钮):




#region 保存
privatevoid tlsbSave_Click(objectsender, EventArgs e)
{
foreach(DataGridViewRow dgvr in dgvPurchaseBeLaidUp.Rows)    //dgv数量不能为空
{
if(dgvr != dgvPurchaseBeLaidUp.Rows[dgvPurchaseBeLaidUp.Rows.Count - 1])
{
try
{
if (dgvr.Cells["数量"].Value.ToString().Trim() == "")
{
MessageBox.Show("明细数量有空!请填满!");
return;
}
}
catch{ return; }
}
}
if(txtArrivalOfGoodsNumber.Text == "")
{
MessageBox.Show("提单号没填!");
txtArrivalOfGoodsNumber.Focus();
return;
}
if(txtArrivalOfGoodsNumber.Text.Length != 10)
{
MessageBox.Show("提单号为10位数字!");
txtArrivalOfGoodsNumber.Focus();
return;
}
if(bolWhetherWhether == true)  //判断是否修改
{
intintIfSucceed = myfrm_PurchaseOddNumbers.tlsbSave_Click_ModificationReceipts(Convert.ToInt32(cboSupplyOfMaterialUnit.SelectedValue.ToString().Trim()),
txtRemark.Text.Trim(), Convert.ToInt32(cboReceiptsProducer.SelectedValue.ToString().Trim()),Convert.ToInt32(cboTallyPerson.SelectedValue.ToString().Trim()),
Convert.ToInt32(cboTallyPerson.SelectedValue.ToString().Trim()),Convert.ToInt32(cboBusinessType.SelectedValue.ToString().Trim()),
intOrderNumber);      //修改订单
intIfSucceed +=myfrm_PurchaseOddNumbers.tlsbSave_Click_ModificationTakeNotes(Convert.ToInt32(cboBeLaidUpSort.SelectedValue.ToString().Trim()),
intAndOutOfInventoryRecordID);    //修改出入库类型
List<int> lstProduct = newList<int>();//现在明细的产品ID
List<int> lstNeedProduct = newList<int>();  //不删除但 需要修改的ID
for(int intRows = 0; intRows <dgvPurchaseBeLaidUp.Rows.Count - 1; intRows++)
{
lstProduct.Add(Convert.ToInt32(dgvPurchaseBeLaidUp.Rows[intRows].Cells["产品ID"].Value.ToString().Trim())); //添加现在明细的产品ID
}
for(int intCount = 0; intCount <dtListDeleteID.Rows.Count; intCount++)   //遍历删除  明细
{
if(dtListDeleteID.Rows[intCount]["采购入库明细ID"].ToString().Trim() != "")
{
if (lstProduct.Exists(i => i == Convert.ToInt32(dtListDeleteID.Rows[intCount]["产品ID"].ToString().Trim())))  //判断是否在删除表 和 明细表
{
myfrm_PurchaseOddNumbers.tlsbDelete_Click_DaletePurchaseOrderFormList(Convert.ToInt32(dtListDeleteID.Rows[intCount]["采购入库明细ID"].ToString().Trim()));
}
else
{
lstNeedProduct.Add(Convert.ToInt32(dtListDeleteID.Rows[intCount]["产品ID"].ToString().Trim()));
}
}
}
foreach(DataGridViewRow dgvr in dgvPurchaseBeLaidUp.Rows)
{
if(dgvr != dgvPurchaseBeLaidUp.Rows[dgvPurchaseBeLaidUp.Rows.Count - 1])
{
if (lstNeedProduct.Exists(i => i == Convert.ToInt32(dgvr.Cells["产品ID"].Value.ToString().Trim())))  //判断是否在删除表 和 明细表 有明细ID的修改
{
int intInventoryID = Convert.ToInt32(dtPurchaseList.Rows[dgvr.Cells["产品ID"].RowIndex]["存货ID"].ToString().Trim());
int intPurchaseListID = Convert.ToInt32(dtPurchaseList.Rows[dgvr.Cells["产品ID"].RowIndex]["采购入库明细ID"].ToString().Trim());
myfrm_PurchaseOddNumbers.tlsbSave_Click_ModificationList(intInventoryID,
dgvr.Cells["数量"].Value.ToString().Trim(), Convert.ToDecimal(dgvr.Cells["金额"].Value.ToString().Trim()), intPurchaseListID);
}
if(dgvr.Cells["采购入库明细ID"].Value != null)    //有明细ID的修改
{
myfrm_PurchaseOddNumbers.tlsbSave_Click_ModificationList(Convert.ToInt32(dgvr.Cells["存货ID"].Value.ToString().Trim()),
dgvr.Cells["数量"].Value.ToString().Trim(), Convert.ToDecimal(dgvr.Cells["金额"].Value.ToString().Trim()), Convert.ToInt32(dgvr.Cells["采购入库明细ID"].Value.ToString().Trim()));
}
else                                                               //没有明细ID的新增
{
int intInventoryID = Convert.ToInt32(dgvr.Cells["产品ID"].Value.ToString().Trim());
if (!(myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_SelectStorageANInventory(Convert.ToInt32(cboStorage.SelectedValue.ToString()),intInventoryID).Tables[0].Rows.Count > 0))//根据仓库ID 与 产品ID 查询存货,没有的新增存货
{
myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_InsertInventory(Convert.ToInt32(dgvr.Cells["存货分类"].Value.ToString().Trim()),
intInventoryID, Convert.ToInt32(cboStorage.SelectedValue.ToString().Trim()),"0", intIfSucceed);
}
int intTheInventoryID = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_SelectStorageANInventory(Convert.ToInt32(cboStorage.SelectedValue.ToString()),intInventoryID).Tables[0].Rows[0][0].ToString().Trim());
myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertInventory(intTheInventoryID,
dgvr.Cells["数量"].Value.ToString().Trim(), Convert.ToDecimal(dgvr.Cells["金额"].Value.ToString().Trim()), intOrderNumber);
}
}

if(intIfSucceed > 0)
{
int intCount = intTpage;
PageSkip(intTpage);
ChangeColour();
bolWhetherWhether = false;//标识不修改
Popup.Controls.Frm_Popup.Instance().TextAssignment(string.Format("\n操作员 【 {0} 】\n刚刚修改了采购订单【{1}】", PublicStaticFields.strOperatorName,txtBusinessNumber.Text.Trim()));  //显示文本输入
Popup.Controls.Frm_Popup.Instance().Show();            //  显示信息
MessageBox.Show("修改成功!");
ClosePromptCancel();//隐藏判断输入框是否合法图片
}
}
}
foreach(Control Control inpnlMain.Controls)
{
if(Control is LineTextBox.LineTextBox)
{
LineTextBox.LineTextBox LineTextBox = Control as LineTextBox.LineTextBox;
LineTextBox.Enabled = false;             //不能编辑
}
if(Control is ComboBox)
{
ComboBoxComboBox = Control as ComboBox;
ComboBox.Enabled = false;             //不能编辑
}
}
tlsbSave.Enabled = false;   //保存按钮不启用
tlsbAbstainFrom.Enabled = false;// 放弃按钮不启用
tlsbPrint.Enabled = true;//打印按钮启用
tlsbAllPreview.Enabled = true;//预览按钮启用
tlsbDelete.Enabled = true;//删除按钮启用
tlsbExamineAndVerify.Enabled = true;//审核按钮启用
tlsbFixedPosition.Enabled = true;//定位按钮启用
tlsbHelp.Enabled = true;//刷新按钮启用
tlsbModification.Enabled = true;//修改按钮启用
tlsbIncrease.Enabled = true;//新增按钮启用
dgvPurchaseBeLaidUp.Columns[2].ReadOnly = true;//不允许修改DGV

dtListDeleteID.Clear();  //清除所有要删除的明细ID
}
#endregion


9、采购订单入库
第一步:数据库的存储过程

(1)新增单据表——采购入库单

if(@Type='tlsbSave_Click_InsertBePutInStorageReceipts')
--新增单据表——采购入库单
BEGIN
INSERT INTOTheDocumentsTable
(NameOfDocuments,  --单据名称
DocumentNumber,   --单据编号
DateOfDocuments,  --单据日期
TypeOfDocumen,  --单据类型
InThisPaper)  --摘要
VALUES (@NameOfDocuments, @DocumentNumber,
@DateOfDocuments, @TypeOfDocumen, @InThisPaper)
SELECT @@IDENTITY
END


(2)入库对应增加数量

if(@Type='tlsbSave_Click_UpdateTheInventoryQuantity')
--入库对应增加数量
BEGIN
UPDATE  TheInventoryTable
SET     TheExistingQuantity= TheExistingQuantity+ @TheExistingQuantity  --增加数量
WHERE   TheInventoryTable.TheInventoryID = @TheInventoryID  --存货ID
END


(3)新增采购出入库记录单

if(@Type='tlsbSave_Click_InsertDiscrepancyStockTakeNotes')
--新增采购出入库记录单
BEGIN
INSERT INTOInAndOutOfInventoryRecord
(WarehouseInventory_ID,   --入库仓库ID
ForTheTypeID,   --出入库类型ID
OoperateDate) --单据日期
VALUES (@WarehouseInventory_ID,@ForTheTypeID, @OoperateDate)
SELECT @@IDENTITY

UPDATE PurchaseReceiptTable
SET    PurchaseReceiptTable.InAndOutOfInventoryRecordID=(SELECT @@IDENTITY)--修改采购入库单出入库记录ID
WHERE  PurchaseReceiptTable.PurchaseReceiptID = @PurchaseReceiptID    --单据ID
END


(4)新增入库记录明细单

if(@Type='tlsbSave_Click_InsertDiscrepancyStockTakeNotesList')  --新增入库记录明细单
BEGIN
INSERT INTOInAndOutOfInventoryRecordList
(Quantity, --数量
TheUnitPrice, --单价
InAndOutOfInventoryRecordID,  --出入库存记录ID
TheInventoryID)  --存货ID
VALUES (@Quantity, @TheUnitPrice,
@InAndOutOfInventoryRecordID, @TheInventoryID)
END


第二步:逻辑层(BLL)代码
(1)新增单据表——采购入库单

///<summary>
///  新增单据表——入库单
///</summary>
///<paramname="strNameOfDocuments">单据名称</param>
///<paramname="strDocumentNumber">单据编号</param>
///<paramname="dtpDateOfDocuments">单据日期</param>
///<paramname="strTypeOfDocumen">单据类型</param>
///<param name="strInThisPaper">摘要</param>
///<returns></returns>
[OperationContract]
public DataSettlsbSave_Click_InsertBePutInStorageReceipts(stringstrNameOfDocuments, string strDocumentNumber,
DateTimedtpDateOfDocuments,string strTypeOfDocumen,string strInThisPaper)
{
myParameter.InsertnameOfDocuments =strNameOfDocuments;
myParameter.DocumentNumber =strDocumentNumber;
myParameter.DateOfDocuments =dtpDateOfDocuments;
myParameter.TypeOfDocumen =strTypeOfDocumen;
myParameter.InThisPaper =strInThisPaper;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
newSqlParameter("@NameOfDocuments",SqlDbType.Char), //单据名称
new SqlParameter("@DocumentNumber", SqlDbType.Char), //单据编号
new SqlParameter("@DateOfDocuments", SqlDbType.DateTime), //单据日期
new SqlParameter("@TypeOfDocumen", SqlDbType.Char), //单据类型
new SqlParameter("@InThisPaper", SqlDbType.Char),//摘要
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertBePutInStorageReceipts";
SQlCMDpas[1].Value =myParameter.InsertnameOfDocuments;
SQlCMDpas[2].Value =myParameter.DocumentNumber;
SQlCMDpas[3].Value =myParameter.DateOfDocuments;
SQlCMDpas[4].Value =myParameter.TypeOfDocumen;
SQlCMDpas[5].Value =myParameter.InThisPaper;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(2)入库对应增加数量

///<summary>
///修改现存数量
///</summary>
///<paramname="strTheExistingQuantity">现存数量</param>
///<paramname="intTheInventoryID">存货ID</param>
///<returns></returns>
[OperationContract]
public DataSet tlsbSave_Click_UpdateTheInventoryQuantity(decimal decTheExistingQuantity, int intTheInventoryID)
{
myParameter.UpdatTheExistingQuantity= decTheExistingQuantity;
myParameter.UpdatTheInventoryID =intTheInventoryID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@TheExistingQuantity", SqlDbType.Decimal), //现存数量
new SqlParameter("@TheInventoryID", SqlDbType.Int), //存货ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_UpdateTheInventoryQuantity";
SQlCMDpas[1].Value =myParameter.UpdatTheExistingQuantity;
SQlCMDpas[2].Value =myParameter.UpdatTheInventoryID;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_ProductBeLaidUp",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(3) 新增采购出入库记录单

///<summary>
///新增入库记录单
///</summary>
///<param name="intWarehouseInventory_ID">出入仓库ID</param>
///<paramname="intForTheTypeID">出入库类型ID</param>
///<paramname="dtpOoperateDate">出入库记录单据日期</param>
///<paramname="PurchaseReceiptID">单据ID</param>
///<returns></returns>
[OperationContract]
public DataSettlsbSave_Click_InsertDiscrepancyStockTakeNotes(intintWarehouseInventory_ID, int intForTheTypeID, DateTime dtpOoperateDate,
intintPurchaseReceiptID)
{
myParameter.WarehouseInventory_ID =intWarehouseInventory_ID;
myParameter.InsertforTheTypeID =intForTheTypeID;
myParameter.OperateDate =dtpOoperateDate;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@WarehouseInventory_ID", SqlDbType.Int), //出入仓库ID
new SqlParameter("@ForTheTypeID", SqlDbType.Int), //出入库类型ID
new SqlParameter("@OoperateDate", SqlDbType.DateTime), //出入库记录单据日期
new SqlParameter("@PurchaseReceiptID", SqlDbType.Int), //单据ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertDiscrepancyStockTakeNotes";
SQlCMDpas[1].Value =myParameter.WarehouseInventory_ID;
SQlCMDpas[2].Value =myParameter.InsertforTheTypeID;
SQlCMDpas[3].Value = myParameter.OperateDate;
SQlCMDpas[4].Value =intPurchaseReceiptID;
DataTabledt = myDALMethod.QueryDataTable("PurchaseManage_frm_PurchaseOddNumbers",SQlCMDpas);
DataSetds = new DataSet();
ds.Tables.Add(dt);
returnds;
}


(4)新增入库记录明细单

///<summary>
///新增出入库记录明细
///</summary>
///<paramname="decQuantity">数量</param>
///<paramname="decTheUnitPrice">单价</param>
///<paramname="intInAndOutOfInventoryRecordID">出入库存记录ID</param>
///<paramname="intTheInventoryID">存货ID</param>
///<returns></returns>
[OperationContract]
public inttlsbSave_Click_InsertDiscrepancyStockTakeNotesList(decimaldecQuantity, decimal decTheUnitPrice,
intintInAndOutOfInventoryRecordID, intintTheInventoryID)
{
myParameter.InsertQuantity =decQuantity;
myParameter.InsertTheUnitPrice =decTheUnitPrice;
myParameter.InAndOutOfInventoryRecordID = intInAndOutOfInventoryRecordID;
myParameter.TheInventoryID =intTheInventoryID;
SqlParameter[]SQlCMDpas = {
new SqlParameter("@Type", SqlDbType.Char),
new SqlParameter("@Quantity", SqlDbType.Decimal),//数量
new SqlParameter("@TheUnitPrice", SqlDbType.Decimal), //单价
new SqlParameter("@InAndOutOfInventoryRecordID", SqlDbType.Int), //出入库存记录ID
new SqlParameter("@TheInventoryID", SqlDbType.Int), //存货ID
};
SQlCMDpas[0].Value = "tlsbSave_Click_InsertDiscrepancyStockTakeNotesList";
SQlCMDpas[1].Value =myParameter.InsertQuantity;
SQlCMDpas[2].Value =myParameter.InsertTheUnitPrice;
SQlCMDpas[3].Value =myParameter.InAndOutOfInventoryRecordID;
SQlCMDpas[4].Value =myParameter.TheInventoryID;
returnmyDALMethod.UpdateData("PurchaseManage_frm_ProductBeLaidUp",SQlCMDpas);
}


第三步:界面层(UIL)代码,在窗体的Load事件中绑定下拉框的数据
截图效果(选择审核但未入库的订单进行入库):




#region 入库
privatevoid tlsbBeLaidUp_Click(object sender, EventArgs e)
{
if(MessageBox.Show(string.Format("是否确认入库,请确定。你的姓名是【{0}】你的身份是【{1}】", PublicStaticFields.strOperatorName,PublicStaticFields.strOperateTypeName), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
{
txtBeLaidUpOddNnumbers.Text = PublicStaticMothd.ShengChengDanHao("RK",myfrm_PurchaseOddNumbers.frm_PurchaseOddNumbers_Load_SelectbeLaidUp().Tables[0].Rows[0][0].ToString().Trim()).Trim();
intintBeLaidUpID = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertBePutInStorageReceipts("入库单", txtBeLaidUpOddNnumbers.Text, Convert.ToDateTime(DateTime.Now.ToString().Trim()), "入库单", "入库单").Tables[0].Rows[0][0]);//新增单据表——入库单
intintSucceed = myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_UpdateBeLaidUp(intBeLaidUpID,intOrderNumber);  //完整入库  将入库单ID新增在 采购入库单
if(intSucceed > 0)
{
intintDiscrepancyInventoryType = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbSave_Click_InsertDiscrepancyStockTakeNotes(Convert.ToInt32(cboStorage.SelectedValue.ToString().Trim())
, Convert.ToInt32(cboBeLaidUpSort.SelectedValue.ToString().Trim()),Convert.ToDateTime(DateTime.Now.ToString().Trim()),intOrderNumber).Tables[0].Rows[0][0]);            //新增出入库类型表 获取 出入库记录ID 并且一同修改采购的出入库记录ID

for(int intRowsCount = 0; intRowsCount <dgvPurchaseBeLaidUp.Rows.Count - 1; intRowsCount++)//遍历明细数量 进行入库
{
int intProductID = Convert.ToInt32(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["产品ID"].Value.ToString().Trim());
string strQuantity = dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["数量"].Value.ToString().Trim();
decimal decUnitPrice = Convert.ToDecimal(dgvPurchaseBeLaidUp.Rows[intRowsCount].Cells["单价"].Value.ToString().Trim());

int intTheInventoryID = Convert.ToInt32(myfrm_PurchaseOddNumbers.tlsbBeLaidUp_Click_SelectStorageANInventory(
Convert.ToInt32(cboStorage.SelectedValue.ToString()),intProductID).Tables[0].Rows[0][0].ToString().Trim());
myfrm_ProductBeLaidUp.tlsbSave_Click_UpdateTheInventoryQuantity(Convert.ToDecimal(strQuantity),intTheInventoryID); //增加存货数量 获取存货ID

myfrm_ProductBeLaidUp.tlsbSave_Click_InsertDiscrepancyStockTakeNotesList(Convert.ToDecimal(strQuantity), decUnitPrice,intDiscrepancyInventoryType, intTheInventoryID); //新增采购入库入库记录明细单
}
intintIndex = dgvPurchaseBe.CurrentRow.Index;              //获取当前入库行
PageSkip(intTpage);                                         //刷新数据
ChangeColour();                                             //审核行颜色改变
dgvPurchaseBe.FirstDisplayedScrollingRowIndex= intIndex;   //滚动到入库行
MessageBox.Show("恭喜!入库成功!");
}
}
}
#endregion


以上技术仅供参考,禁止用于商业用途,上述内容不代表用友立场!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: