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; } View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value); if (planCost == null) { return; } S_OrdinaryInDepotGoodsBill goods = new S_OrdinaryInDepotGoodsBill(); View_S_OrdinaryInDepotGoodsBill viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]); goods.ID = viewGoods.序号; goods.GoodsID = planCost.序号; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtProviderBatchNo.Tag.ToString(); goods.Amount = numGoodsAmount.Value; goods.UnitPrice = numUnitPrice.Value; goods.Price = Math.Round(numUnitPrice.Value * numGoodsAmount.Value, 2); goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price); goods.TestingSingle = lnklbSingleBill.Text; if (m_operateMode == CE_BusinessOperateMode.仓库核实) { goods.ShelfArea = txtShelf.Text; goods.ColumnNumber = txtColumn.Text; goods.LayerNumber = txtLayer.Text; } goods.Remark = txtRemark.Text; if (!m_goodsServer.UpdateGoods(goods, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } int rowIndex = dataGridView1.SelectedRows[0].Index; RefreshDataGridView(m_queryResult); PositioningRecord(rowIndex); }
public static void Main() { List <CorporateInfo> CInfoList = new List <CorporateInfo>(); CalculateClass Cobj = new CalculateClass(); CInfoList = Cobj.GetData(); Cobj.GetSpread_to_Benchmark(CInfoList); Cobj.GetSpread_to_curve(CInfoList); }
/// <summary> /// 更新自制件入库单 /// </summary> /// <param name="updateBill">更新的自制件单据信息</param> /// <param name="returnBill">返回的单据查询结果集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool UpdateBill(S_HomemadePartBill updateBill, out IQueryResult returnBill, out string error) { returnBill = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; S_HomemadePartBill bill = (from r in dataContxt.S_HomemadePartBill where r.Bill_ID == updateBill.Bill_ID select r).Single(); bill.BatchNo = updateBill.BatchNo; bill.Bill_Time = updateBill.Bill_Time; bill.BillStatus = updateBill.BillStatus; bill.DeclareCount = updateBill.DeclareCount; bill.DeclarePersonnel = updateBill.DeclarePersonnel; bill.DeclarePersonnelCode = updateBill.DeclarePersonnelCode; bill.GoodsID = updateBill.GoodsID; bill.Provider = updateBill.Provider; bill.ProviderBatchNo = updateBill.ProviderBatchNo; bill.RebackReason = ""; bill.Remark = updateBill.Remark; #region 获取计划价格 decimal planUnitPrice = 0; bill.PlanUnitPrice = planUnitPrice; bill.PlanPrice = bill.DeclareCount * planUnitPrice; #endregion #region 获取单价 bill.UnitPrice = 0; bill.Price = bill.UnitPrice * bill.DeclareCount; bill.TotalPrice = CalculateClass.GetTotalPrice((decimal)bill.Price); #endregion dataContxt.SubmitChanges(); return(GetAllBill(out returnBill, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 添加自制件入库单 /// </summary> /// <param name="bill">自制件单据信息</param> /// <param name="returnBill">添加完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool AddBill(S_HomemadePartBill bill, out IQueryResult returnBill, out string error) { returnBill = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; string billID = m_assignBill.AssignNewNo(this, CE_BillTypeEnum.自制件入库单.ToString()); bill.Bill_ID = billID; bill.BatchNo = bill.BatchNo == "系统自动生成" ? billID : bill.BatchNo; bill.Bill_Time = ServerModule.ServerTime.Time; #region 获取计划价格 View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfoView(bill.GoodsID); decimal planUnitPrice = basicGoods.单价; bill.PlanUnitPrice = planUnitPrice; bill.PlanPrice = bill.DeclareCount * planUnitPrice; #endregion #region 获取单价 bill.UnitPrice = 0; bill.Price = bill.UnitPrice * bill.DeclareCount; bill.TotalPrice = CalculateClass.GetTotalPrice((decimal)bill.Price); #endregion if (GlobalObject.GeneralFunction.IsNullOrEmpty(bill.Bill_ID)) { throw new Exception("【单据号】获取失败,请重新再试"); } dataContxt.S_HomemadePartBill.InsertOnSubmit(bill); dataContxt.SubmitChanges(); return(GetAllBill(out returnBill, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <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 btnAutoGenerate_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { MessageDialog.ShowPromptMessage("请删除此清单中的所有物品后再进行此操作!"); return; } IOrderFormGoodsServer orderFormGoodsServer = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>(); IQueryable <View_B_OrderFormGoods> goodsGroup = null; if (!orderFormGoodsServer.GetOrderFormGoods( BasicInfo.ListRoles, BasicInfo.LoginID, m_billInfo.OrderBill_ID, out goodsGroup, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } S_OrdinaryInDepotBill lnqBill = m_serverBill.GetBill(m_billNo); IOrderFormInfoServer serviceOrderForm = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>(); View_B_OrderFormInfo orderInfo = serviceOrderForm.GetOrderFormInfo(m_billInfo.OrderBill_ID); foreach (var item in goodsGroup) { if (item.订货数量 == 0) { continue; } S_OrdinaryInDepotGoodsBill goods = new S_OrdinaryInDepotGoodsBill(); View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(item.图号型号, item.物品名称, item.规格, 0); if (planCost == null) { return; } goods.GoodsID = planCost.序号; goods.Bill_ID = m_billNo; goods.ProviderBatchNo = ""; if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号)) { goods.BatchNo = m_goodsServer.GetNewBatchNo(); } else { goods.BatchNo = ""; } goods.Amount = item.订货数量; IBargainGoodsServer serviceBargainGoods = ServerModuleFactory.GetServerModule <IBargainGoodsServer>(); goods.UnitPrice = serviceBargainGoods.GetGoodsUnitPrice(orderInfo.订单号, goods.GoodsID, orderInfo.供货单位); goods.Price = decimal.Round(goods.UnitPrice * item.订货数量, (int)2); goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price); goods.Remark = txtRemark.Text; if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } } btnRefresh_Click(sender, e); }
private void btnAdd_Click(object sender, EventArgs e) { if (!CheckDataItem()) { return; } S_OrdinaryInDepotBill lnqBill = m_serverBill.GetBill(m_billNo); S_OrdinaryInDepotGoodsBill goods = new S_OrdinaryInDepotGoodsBill(); View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value); if (planCost == null) { return; } goods.Bill_ID = m_billNo; goods.ProviderBatchNo = txtProviderBatchNo.Text; if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号)) { goods.BatchNo = m_goodsServer.GetNewBatchNo(); } else { goods.BatchNo = ""; } goods.Amount = numGoodsAmount.Value; goods.UnitPrice = numUnitPrice.Value; goods.Price = decimal.Round(goods.UnitPrice * numGoodsAmount.Value, 2); goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price); goods.ShelfArea = ""; goods.ColumnNumber = ""; goods.LayerNumber = ""; goods.Remark = txtRemark.Text; goods.TestingSingle = lnklbSingleBill.Text; goods.GoodsID = planCost.序号; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["图号型号"].Value.ToString() == txtCode.Text && row.Cells["物品名称"].Value.ToString() == txtName.Text && row.Cells["规格"].Value.ToString() == txtSpec.Text && row.Cells["供方批次号"].Value.ToString() == txtProviderBatchNo.Text) { MessageDialog.ShowPromptMessage("已经存在相同的物品信息列不允许再进行重复添加!"); return; } } if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error)) { if (m_error.Contains("不能在具有唯一索引")) { m_error = "此物品清单中的物品(同种物品、同一批号)可能已经在其他普通入库单中增加,不允许再重复入库!"; } MessageDialog.ShowErrorMessage(m_error); return; } RefreshDataGridView(m_queryResult); PositioningRecord(planCost.图号型号, planCost.物品名称, planCost.规格); }
/// <summary> /// 设置金额信息 /// </summary> /// <param name="orderFormNumber">订单号</param> /// <param name="goods">物品信息</param> /// <param name="storageID">库房ID</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回操作是否成功的标志</returns> public bool SetPriceInfo(string orderFormNumber, S_MaterialListRejectBill goods, string storageID, out string error) { decimal factUnitPrice = 0; decimal planUnitPrice = 0; if (!string.IsNullOrEmpty(orderFormNumber)) { if (orderFormNumber.Length > 3 && orderFormNumber.Substring(0, 3) == "BFD") { factUnitPrice = m_storeServer.GetFactUnitPrice(goods.GoodsID, goods.Provider, goods.BatchNo, storageID); } else { string strSql = "select b.UnitPrice/(1+cess/100) as UnitPrice from B_OrderFormInfo as a " + " inner join B_BargainInfo as d on a.BargainNumber = d.BargainNumber " + " inner join B_BargainGoods as b on a.BargainNumber = b.BargainNumber " + " where a.orderFormNumber = '" + orderFormNumber + "' and b.GoodsID = " + Convert.ToInt32(goods.GoodsID); DataTable dtBargainPrice = GlobalObject.DatabaseServer.QueryInfo(strSql); if (dtBargainPrice.Rows.Count == 0) { factUnitPrice = 0; } else { //委外报检的物品单价直接从委外报检入库单中的单价金额获得 if (goods.BatchNo.Contains("WJD")) { strSql = " select UnitPrice from S_CheckOutInDepotForOutsourcingBill where Bill_ID = '" + goods.BatchNo + "' "; DataTable dtRawMaterialPrice = GlobalObject.DatabaseServer.QueryInfo(strSql); if (dtRawMaterialPrice.Rows.Count == 0) { factUnitPrice = 0; } else { factUnitPrice = Convert.ToDecimal(dtRawMaterialPrice.Rows[0][0]); } } else { factUnitPrice = Convert.ToDecimal(dtBargainPrice.Rows[0][0].ToString()); } } } } 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); }
/// <summary> /// 自动插入报检入库单 /// </summary> /// <param name="dateTable">需要插入的数据集</param> /// <param name="storageID">库房ID</param> /// <param name="version">版次号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool AddCheckInDepotBill(DataTable dateTable, string storageID, string version, out string error) { error = null; BargainInfoServer serverBargainInfo = new BargainInfoServer(); CheckOutInDepotServer serverCheckInDepot = new CheckOutInDepotServer(); try { string strBatchNo = serverCheckInDepot.GetNextBillNo(1); DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; for (int i = 0; i < dateTable.Rows.Count; i++) { S_CheckOutInDepotBill bill = new S_CheckOutInDepotBill(); decimal dcUnitPrice = serverBargainInfo.GetBargainUnitPrice(dateTable.Rows[i]["订单号"].ToString(), Convert.ToInt32(dateTable.Rows[i]["物品ID"])); F_GoodsPlanCost lnqGoods = ServerModuleFactory.GetServerModule <IBasicGoodsServer>().GetGoodsInfo( Convert.ToInt32(dateTable.Rows[i]["物品ID"])); bill.Bill_ID = GetBillID(strBatchNo, i); bill.OrderFormNumber = dateTable.Rows[i]["订单号"].ToString(); bill.ArriveGoods_Time = ServerTime.Time; // 到货日期 bill.Bill_Time = ServerTime.Time; // 报检日期 bill.BillStatus = CheckInDepotBillStatus.新建单据.ToString(); bill.Buyer = dateTable.Rows[i]["订货人"].ToString(); // 采购员签名 bill.DeclarePersonnelCode = dateTable.Rows[i]["订货人编号"].ToString(); // 报检员编码 bill.DeclarePersonnel = dateTable.Rows[i]["订货人"].ToString(); // 报检员签名 bill.DeclareCount = Convert.ToInt32(dateTable.Rows[i]["到货数量"]); // 报检数 bill.Provider = dateTable.Rows[i]["供应商"].ToString(); // 供应商编码 bill.ProviderBatchNo = ""; // 供应商批次 bill.GoodsID = (int)dateTable.Rows[i]["物品ID"]; bill.BatchNo = strBatchNo + "Auto"; // xsy, 没有废除OA前暂用 bill.Remark = "由自动订单自动生成的报检入库单"; bill.CheckOutGoodsType = 1; bill.OnlyForRepairFlag = false; bill.UnitPrice = dcUnitPrice; bill.Price = decimal.Round(bill.UnitPrice * Convert.ToDecimal(dateTable.Rows[i]["到货数量"]), 2); bill.PlanUnitPrice = Convert.ToDecimal(lnqGoods.GoodsUnitPrice); bill.PlanPrice = decimal.Round(bill.PlanUnitPrice * Convert.ToDecimal(dateTable.Rows[i]["到货数量"]), 2); bill.TotalPrice = CalculateClass.GetTotalPrice(bill.Price); bill.StorageID = storageID; bill.Version = version; bill.IsExigenceCheck = false; bill.UnitInvoicePrice = 0; bill.InvoicePrice = 0; if (UniversalFunction.GetStorageInfo_View(bill.StorageID).零成本控制) { throw new Exception("【零成本】库房,无法通过【报检入库单】入库"); } dataContext.S_CheckOutInDepotBill.InsertOnSubmit(bill); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }