private void btnAdd_Click(object sender, EventArgs e) { if (!CheckDataItem()) { return; } S_HomemadeRejectList goods = new S_HomemadeRejectList(); goods.Bill_ID = m_strBillID; goods.GoodsID = (int)txtCode.Tag; goods.Provider = txtProvider.Text; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtBatchNo.Text; goods.Amount = numAmount.Value; goods.Remark = txtRemark.Text; DataTable dvt = m_goodsServer.GetBillView(m_strBillID); if (CheckSameGoods(dvt, goods)) { if (!m_goodsServer.AddGoods(goods, m_strStorage, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetBillView(m_strBillID); RefreshDataGridView(m_queryGoodsInfo); PositioningRecord(m_strGoodsCode, m_strGoodsName, m_strSpec); }
/// <summary> /// 添加物品信息 /// </summary> /// <param name="goods">物品信息</param> /// <param name="storageID">库房ID</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool AddGoods(S_HomemadeRejectList goods, string storageID, out string error) { try { error = null; IsolationManageBill serverIsolation = new IsolationManageBill(); DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; if (!SetPriceInfo(goods, storageID, out error)) { return(false); } if (!serverIsolation.UpdateAssicotaeBillID(dataContxt, goods.Bill_ID, goods.GoodsID, goods.BatchNo, out error)) { return(false); } dataContxt.S_HomemadeRejectList.InsertOnSubmit(goods); dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageDialog.ShowPromptMessage("请选择要修改的记录后再进行此操作"); return; } else if (dataGridView1.SelectedRows.Count > 1) { MessageDialog.ShowPromptMessage("只能选择要修改的一条记录后再进行此操作"); return; } if (!CheckDataItem()) { return; } S_HomemadeRejectList goods = new S_HomemadeRejectList(); View_S_HomemadeRejectList viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]); goods.ID = viewGoods.序号; goods.Bill_ID = m_strBillID; if (txtCode.Tag != null && (int)txtCode.Tag != 0) { goods.GoodsID = (int)txtCode.Tag; } else { goods.GoodsID = viewGoods.物品ID; } goods.Provider = txtProvider.Text; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtBatchNo.Text; goods.Amount = numAmount.Value; goods.Remark = txtRemark.Text; if (!m_goodsServer.UpdateGoods(goods, m_strStorage, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetBillView(m_strBillID);//.GetGoods(BillNo); RefreshDataGridView(m_queryGoodsInfo); PositioningRecord(m_strGoodsCode, m_strGoodsName, m_strSpec); }
/// <summary> /// 检查相同物品 /// </summary> /// <param name="Dt">需要检测的数据集</param> /// <param name="goods">自制件明细细细</param> /// <returns>无相同的返回True,否则返回False</returns> bool CheckSameGoods(DataTable dt, S_HomemadeRejectList goods) { if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["物品ID"].ToString() == goods.GoodsID.ToString() && dt.Rows[i]["批次号"].ToString() == goods.BatchNo.ToString()) { MessageBox.Show("不能添加同一个物品,请重新确认物品", "提示"); return(false); } } } return(true); }
/// <summary> /// 设置金额信息 /// </summary> /// <param name="goods">物品信息</param> /// <param name="storageID">库房ID</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> private bool SetPriceInfo(S_HomemadeRejectList goods, string storageID, out string error) { decimal factUnitPrice = 0; decimal planUnitPrice = 0; if (!m_basicGoodsServer.GetPlanUnitPrice(goods.GoodsID, out planUnitPrice, out error)) { return(false); } goods.PlanUnitPrice = planUnitPrice; goods.PlanPrice = planUnitPrice * goods.Amount; goods.UnitPrice = factUnitPrice; goods.Price = factUnitPrice * goods.Amount; goods.TotalPrice = CalculateClass.GetTotalPrice(goods.Price); return(true); }
private void btnBatchCreate_Click(object sender, EventArgs e) { 退货业务报废物品筛选窗体 Form = new 退货业务报废物品筛选窗体(m_strProvider); Form.ShowDialog(); DataTable dt = Form.DtScrap; if (dt == null || dt.Rows.Count == 0) { return; } for (int i = 0; i < dt.Rows.Count; i++) { S_HomemadeRejectList goods = new S_HomemadeRejectList(); goods.Bill_ID = m_strBillID; goods.GoodsID = Convert.ToInt32(dt.Rows[i]["GoodsID"].ToString()); goods.Provider = dt.Rows[i]["Provider"].ToString(); goods.ProviderBatchNo = ""; goods.BatchNo = dt.Rows[i]["BatchNo"].ToString(); goods.Amount = Convert.ToDecimal(dt.Rows[i]["Quantity"].ToString()); goods.Remark = dt.Rows[i]["Reason"].ToString(); DataTable dvt = m_goodsServer.GetBillView(m_strBillID); if (CheckSameGoods(dvt, goods)) { if (!m_goodsServer.AddGoods(goods, m_strStorage, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } } } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetBillView(m_strBillID); RefreshDataGridView(m_queryGoodsInfo); }
/// <summary> /// 更新物品信息 /// </summary> /// <param name="goods">物品信息</param> /// <param name="storageID">库房ID</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool UpdateGoods(S_HomemadeRejectList goods, string storageID, out string error) { try { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.S_HomemadeRejectList where r.ID == goods.ID select r; if (result.Count() > 0) { S_HomemadeRejectList updateGoods = result.Single(); updateGoods.Bill_ID = goods.Bill_ID; updateGoods.GoodsID = goods.GoodsID; updateGoods.Provider = goods.Provider; updateGoods.BatchNo = goods.BatchNo; updateGoods.ProviderBatchNo = goods.ProviderBatchNo; updateGoods.Amount = goods.Amount; updateGoods.Remark = goods.Remark; if (!SetPriceInfo(updateGoods, storageID, out error)) { return(false); } dataContxt.SubmitChanges(); } return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContxt, S_HomemadeRejectBill bill, S_HomemadeRejectList item) { S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.OutDepotDate; detailBill.FillInPersonnel = bill.FillInPersonnel; detailBill.Department = bill.Department; detailBill.FactPrice = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.FactUnitPrice = item.UnitPrice; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.Provider = item.Provider; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = -item.Amount; detailBill.UnitPrice = item.UnitPrice; detailBill.Price = -Math.Round(item.UnitPrice * item.Amount, 2); detailBill.OperationType = (int)CE_SubsidiaryOperationType.自制件退货; detailBill.StorageID = bill.StorageID; detailBill.Remark = bill.Remark + "(根据自制件退货单自动生成)"; detailBill.AffrimPersonnel = bill.DepotManager; detailBill.FillInDate = bill.Bill_Time; return(detailBill); }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回库存信息对象</returns> S_Stock AssignStockInfo(DepotManagementDataContext dataContxt, S_HomemadeRejectBill bill, S_HomemadeRejectList item) { F_GoodsPlanCost info = m_basicGoodsServer.GetGoodsInfo(dataContxt, item.GoodsID); S_Stock stockInfo = new S_Stock(); stockInfo.GoodsID = info.ID; stockInfo.GoodsCode = info.GoodsCode; stockInfo.GoodsName = info.GoodsName; stockInfo.Spec = info.Spec; stockInfo.Provider = item.Provider; stockInfo.BatchNo = item.BatchNo; stockInfo.ExistCount = item.Amount; stockInfo.StorageID = bill.StorageID; return(stockInfo); }