private void RecipeComboBox_EditValueChanged(object sender, EventArgs e) { dynamic row = RecipeComboBox.GetSelectedDataRow(); if (RecipeComboBox.ContainsFocus && row != null) { wb.WayBillMake.Amount = row.Amount; MsrLabel.Text = row.MsrName; GetOk(); } }
private decimal CalcTotal() { dynamic row = RecipeComboBox.GetSelectedDataRow(); if (row == null) { return(0); } var real_amount = OrderedEdit.Value - RemainEdit.Value; var tmp_amount = (real_amount / (row.Out == 0 ? 100m : row.Out)) * 100;// real_amount + (real_amount - (real_amount * row.Out / 100)); return(Math.Ceiling(tmp_amount / row.Amount) * row.Amount); }
/* private Decimal? GetRecipePrice(int recipe_id) * { * var result = _db.MatRecDet.Where(w => w.RecId == recipe_id).ToList().Sum(s => s.Amount * _db.PriceListDet.Where(w => w.PlId == _pc.PlId && w.MatId == s.MatId).Select(ss => ss.Price).FirstOrDefault()); * * return result > 0 ? Math.Round(result.Value, 2) : (decimal?)null; * }*/ private void calcEdit2_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Index == 1) { dynamic row = RecipeComboBox.GetSelectedDataRow(); if (row == null) { return; } int rec_id = row.RecId; calcEdit2.EditValue = _db.GetRecipePrice(rec_id, _pc.PlId).FirstOrDefault(); } }
private void AddMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { dynamic row = RecipeComboBox.GetSelectedDataRow(); using (var frm = new frmWriteOffDet(_db, null, wb)) { frm.mat_id = row.MatId; frm.amount = row.Amount; if (frm.ShowDialog() == DialogResult.OK) { // current_transaction = current_transaction.CommitRetaining(_db); // UpdLockWB(); RefreshDeboningDet(true); RefreshDet(); } } }
private void MatComboBox_EditValueChanged(object sender, EventArgs e) { dynamic row = RecipeComboBox.GetSelectedDataRow(); if (row == null) { return; } det.RecId = Convert.ToInt32(RecipeComboBox.EditValue); int mat_id = row.MatId; var mat_remain = _db.v_MatRemains.Where(w => w.MatId == mat_id).OrderByDescending(o => o.OnDate).FirstOrDefault(); det.Remain = mat_remain != null ? mat_remain.Remain : 0; OrderedEdit.EditValue = det.Remain + TotalEdit.Value; // det.Total = CalcTotal(); GetOk(); }
private void RecipeComboBox_EditValueChanged(object sender, EventArgs e) { if (!RecipeComboBox.ContainsFocus) { return; } dynamic row = RecipeComboBox.GetSelectedDataRow(); if (row == null) { return; } int rec_id = row.RecId; int mat_id = row.MatId; decimal RecipeOut = row.Out == 0 ? 100 : row.Out; /* var measure_id = _db.Materials.Find(mat_id).MId; * * var main_sum = _db.MatRecDet.Where(w => w.RecId == rec_id && w.Materials.MId == measure_id).ToList().Sum(s => s.Amount); * * var ext_sum = _db.MatRecDet.Where(w => w.RecId == rec_id && w.Materials.MId != w.MatRecipe.Materials.MId) * .Select(s => new { MaterialMeasures = s.Materials.MaterialMeasures.Where(f => f.MId == measure_id), s.Amount }).ToList() * .SelectMany(sm => sm.MaterialMeasures, (k, n) => new { k.Amount, MeasureAmount = n.Amount }).Sum(su => su.MeasureAmount * su.Amount);*/ /* var main_sum = _db.MatRecDet.Where(w => w.RecId == rec_id && w.Materials.MId == w.MatRecipe.Materials.MId).ToList().Sum(s => s.Amount); * var ext_sum = _db.MatRecDet.Where(w => w.RecId == rec_id && w.Materials.MId != w.MatRecipe.Materials.MId).ToList().Sum(s => (s.Materials.Weight ?? 0) * s.Amount);*/ det.Amount = IHelper.GetAmounRecipe(_db, mat_id, rec_id); // main_sum + ext_sum; det.RecipeOut = RecipeOut; det.SalesPrice = _db.PriceListDet.Where(w => w.PlId == _pc.PlId && w.MatId == mat_id).Select(s => s.Price).FirstOrDefault(); det.RecipePrice = _db.GetRecipePrice(rec_id, _pc.PlId).FirstOrDefault(); GetOk(); }
private void OkButton_Click(object sender, EventArgs e) { if (!DBHelper.CheckInDate(wb, _db, OnDateDBEdit.DateTime)) { return; } // var measure_id = wb.WayBillMake.MatRecipe.Materials.MId; var row = RecipeComboBox.GetSelectedDataRow() as RecipeList; if (row.AutoCalcRecipe) { var main_sum = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId == w.WaybillList.WayBillMake.MatRecipe.Materials.MId).ToList() .Sum(s => s.Amount); var ext_sum = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId != w.WaybillList.WayBillMake.MatRecipe.Materials.MId) .Select(s => new { MaterialMeasures = s.Materials.MaterialMeasures.Where(f => f.MId == s.WaybillList.WayBillMake.MatRecipe.Materials.MId), s.Amount }).ToList() .SelectMany(sm => sm.MaterialMeasures, (k, n) => new { k.Amount, MeasureAmount = n.Amount }).Sum(su => su.MeasureAmount * su.Amount); wb.WayBillMake.Amount = main_sum + ext_sum; var main_sum_rec = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId == w.WaybillList.WayBillMake.MatRecipe.Materials.MId).ToList() .Sum(s => s.Discount); var ext_sum_rec = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId != w.WaybillList.WayBillMake.MatRecipe.Materials.MId) .Select(s => new { MaterialMeasures = s.Materials.MaterialMeasures.Where(f => f.MId == s.WaybillList.WayBillMake.MatRecipe.Materials.MId), s.Discount }).ToList() .SelectMany(sm => sm.MaterialMeasures, (k, n) => new { k.Discount, MeasureAmount = n.Amount }).Sum(su => su.MeasureAmount * su.Discount); var prod_plan = _db.GetRelDocList(wb.Id).FirstOrDefault(a => a.DocType == 20); if (prod_plan != null) { var prod_plan_det = _db.ProductionPlanDet.FirstOrDefault(w => w.ProductionPlanId == prod_plan.Id && w.RecId == wb.WayBillMake.RecId); if (prod_plan_det != null) { wb.WayBillMake.AmountByRecipe = prod_plan_det.Total; wb.WayBillMake.RecipeCount = Convert.ToInt32(Math.Ceiling(wb.WayBillMake.AmountByRecipe.Value / row.Amount)); } } else { wb.WayBillMake.AmountByRecipe = main_sum_rec /* + ext_sum_rec*/; wb.WayBillMake.RecipeCount = Convert.ToInt32(Math.Ceiling(wb.WayBillMake.AmountByRecipe.Value / row.Amount)); } if (wb.WayBillMake.Amount == 0) { MessageBox.Show("Помилка в рецепті ,закладка = 0 " + MsrLabel.Text + " !"); return; } } wb.UpdatedAt = DateTime.Now; _db.SaveChanges(); if (TurnDocCheckBox.Checked) { wbd_list = new BaseEntities().GetWayBillMakeDet(_wbill_id).AsNoTracking().OrderBy(o => o.Num).ToList(); if (wbd_list.Any(w => w.Rsv == 0)) { MessageBox.Show("Не всі позиції зарезервовано"); return; } var ex_wb = _db.ExecuteWayBill(wb.WbillId, null, DBHelper.CurrentUser.KaId).FirstOrDefault(); if (ex_wb.ErrorMessage != "False") { MessageBox.Show(ex_wb.ErrorMessage); return; } } is_new_record = false; Close(); }
private void frmProductionPlanDet_Shown(object sender, EventArgs e) { RecipeComboBox.Focus(); }
private void OkButton_Click(object sender, EventArgs e) { if (!DBHelper.CheckInDate(wb, _db, OnDateDBEdit.DateTime)) { return; } // var measure_id = wb.WayBillMake.MatRecipe.Materials.MId; dynamic row = RecipeComboBox.GetSelectedDataRow(); if (row.AutoCalcRecipe) { var main_sum = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId == w.WaybillList.WayBillMake.MatRecipe.Materials.MId).ToList() .Sum(s => s.Amount); var ext_sum = _db.WaybillDet.Where(w => w.WbillId == _wbill_id && w.Materials.MId != w.WaybillList.WayBillMake.MatRecipe.Materials.MId) .Select(s => new { MaterialMeasures = s.Materials.MaterialMeasures.Where(f => f.MId == s.WaybillList.WayBillMake.MatRecipe.Materials.MId), s.Amount }).ToList() .SelectMany(sm => sm.MaterialMeasures, (k, n) => new { k.Amount, MeasureAmount = n.Amount }).Sum(su => su.MeasureAmount * su.Amount); wb.WayBillMake.Amount = main_sum + ext_sum; if (wb.WayBillMake.Amount == 0) { MessageBox.Show("Помилка в рецепті ,закладка = 0 " + MsrLabel.Text + " !"); return; } } wb.UpdatedAt = DateTime.Now; _db.SaveChanges(); if (TurnDocCheckBox.Checked) { RefreshDet(); if (wbd_list.Any(w => w.Rsv == 0)) { MessageBox.Show("Не всі позиції зарезервовано"); return; } var ex_wb = _db.ExecuteWayBill(wb.WbillId, null, DBHelper.CurrentUser.KaId).FirstOrDefault(); if (ex_wb.ErrorMessage != "False") { MessageBox.Show(ex_wb.ErrorMessage); return; } } is_new_record = false; Close(); }