private void tbSelectItem_KeyDown(object sender, KeyEventArgs e) { //选好单品,并且回车 if (e.KeyCode == Keys.Enter && tbSelectItem.Text != "") { SupplyChainPos scp = SupplyChainPos.FindById(PosId); SupplyChainPosDetail scpd = SupplyChainPosDetail.New; BaseInfoMaterial bim = BaseInfoMaterial.FindById(MaterialId); scpd.IsPaid = false; scpd.MaterialId = bim.Id; scpd.MaterialName = bim.Name; scpd.MaterialCategory = bim.Category; scpd.UnitName = bim.SaleUnitName; if (scp.MemberId != 0) { scpd.UnitPrice = bim.MemberPrice; } else { scpd.UnitPrice = bim.RetailPrice; } scpd.Quantity = 1; scpd.Discount = 0; scpd.Amount = scpd.UnitPrice * scpd.Quantity; scpd.IsReturns = false; scpd.IsGift = false; scpd.OrderDateTime = DateTime.Now; scpd.Save(); scp.SupplyChainPosDetails.Add(scpd); scp.Quantity += 1; scp.UnPaidQuantity += 1; scp.UnPayAmount += scpd.Amount; scp.PosAmount += scpd.Amount; scp.Cashier = UserStatics.ChineseName; scp.Save(); bim.ConvQuantity -= 1; bim.InvQuantity = bim.ConvQuantity / bim.UnitConvValue; bim.Save(); FrmAddEditBindComboBoxText.BindObjectToControls(scp, panelBottom); TableForPosDetail = BllSupplyChainPos.GetPosDetail(PosId); ReloadDgvPosDetail(); foreach (DataGridViewRow row in dgvPosDetail.Rows) { row.Selected = true; } tbSelectItem.Text = ""; ctUnderPay.Text = scp.UnPayAmount.ToString(); } if (e.KeyCode == Keys.Down) { bsSelectItem.MoveNext(); } if (e.KeyCode == Keys.Up) { bsSelectItem.MovePrevious(); } }
override protected void DeleteCurrentRow() { BaseInfoMaterial bim = BaseInfoMaterial.FindById(DeletingRowId); if (bim.BaseInfoMaterialIngredients.Count == 0) { BllBaseInfoMaterial.DelCell(DeletingRowId); } else { MessageBox.Show("请先删除该商品组成耗材关系!"); } }
private void DelIngredient() { //删除记录 if (MessageBox.Show("确认删除这(条/些)记录吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { BaseInfoMaterial bim = BaseInfoMaterial.FindById(long.Parse(BaseParentId)); if (dgvDest.Rows.Count > 0) { int count = 0; foreach (DataGridViewRow row in dgvDest.SelectedRows) { string delId = row.Cells["Id"].Value.ToString(); bim.ConvPrice -= (Decimal)row.Cells["单价"].Value * (Decimal)row.Cells["数量"].Value; BaseInfoMaterialIngredient.DeleteAll(CK.K["Id"] == delId); count++; } MessageBox.Show("已删除" + count + "条记录!"); } else { MessageBox.Show("没有可删除的数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (bim.BaseInfoMaterialIngredients.Count == 0) { bim.IsAddToInventory = true; bim.Save(); } else { bim.Save(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } bsDest.DataSource = null; bsDest.DataSource = BllBaseInfoMaterialIngredients.GetDestTable(UserStatics.OptrType, BaseParentId); dgvDest.DataSource = bsDest; }
protected override void Saving() { if (!IsAdd) { var obj = BaseInfoMaterial.FindById(long.Parse(ItemID)); BindControlsDecimal.BindControlsToObject(obj, tabPage1); BindControlsDecimal.BindControlsToObject(obj, tabPage2); obj.Save(); } else { var obj = BaseInfoMaterial.New; BindControlsDecimal.BindControlsToObject(obj, tabPage1); BindControlsDecimal.BindControlsToObject(obj, tabPage2); obj.OptrType = UserStatics.OptrType; obj.Save(); ItemID = obj.Id.ToString(); IsSaved = true; } }
private void AddIngredients() { //1.判断右边有无该编码 if ( BaseInfoMaterialIngredient.GetCount(CK.K["BaseInfoMaterial_Id"] == BaseParentId && CK.K["IngredientId"] == _itemId) != 0) { MessageBox.Show("该物料已经添加"); } //2.在右边加入该成品 else { BaseInfoMaterial bim = BaseInfoMaterial.FindById(long.Parse(BaseParentId)); BaseInfoMaterial bimChild = BaseInfoMaterial.FindById(long.Parse(_itemId)); BaseInfoMaterialIngredient baseInfoMaterialIngredient = BaseInfoMaterialIngredient.New; baseInfoMaterialIngredient.IngredientId = long.Parse(_itemId); baseInfoMaterialIngredient.MaterialName = bimChild.Name; baseInfoMaterialIngredient.Price = bimChild.ConvPrice; if (tbAmount.Text == "") { baseInfoMaterialIngredient.Quantity = 1; } else { baseInfoMaterialIngredient.Quantity = Decimal.Parse(tbAmount.Text); } baseInfoMaterialIngredient.Cost = baseInfoMaterialIngredient.Price * baseInfoMaterialIngredient.Quantity; baseInfoMaterialIngredient.OptrType = UserStatics.OptrType; baseInfoMaterialIngredient.Save(); bim.BaseInfoMaterialIngredients.Add(baseInfoMaterialIngredient); bim.ConvPrice += baseInfoMaterialIngredient.Price * baseInfoMaterialIngredient.Quantity; bim.IsAddToInventory = false; bim.Save(); } //3.刷新右边的dgv bsDest.DataSource = null; bsDest.DataSource = BllBaseInfoMaterialIngredients.GetDestTable(UserStatics.OptrType, BaseParentId); dgvDest.DataSource = bsDest; //4.更新主物料的成本 }
protected override void Loading() { ctIsAddToInventory.Checked = true; ctUnitConvValue.Value = 1; ctCategory.DataSource = CommonStatics.GetDict(UserStatics.OptrType, "物料分类"); ctCategory.DisplayMember = "Name"; ctPurchaseUnitName.DataSource = CommonStatics.GetDict(UserStatics.OptrType, "单位"); ctPurchaseUnitName.DisplayMember = "Name"; ctSaleUnitName.DataSource = CommonStatics.GetDict(UserStatics.OptrType, "单位"); ctSaleUnitName.DisplayMember = "Name"; if (!IsAdd || IsSaved) { var obj = BaseInfoMaterial.FindById(long.Parse(ItemID)); BindControlsDecimal.BindObjectToControls(obj, tabPage1); BindControlsDecimal.BindObjectToControls(obj, tabPage2); bsIngredients.DataSource = BllBaseInfoMaterialIngredients.GetDestTable(UserStatics.OptrType, ItemID); dgvIngredients.DataSource = bsIngredients; } }