| | |
| | | double FHQty = Convert.ToDouble(model.GetValue("FHQty")); |
| | | if (e.Field.Key.Contains("FUseRateNew")) |
| | | { |
| | | if (e.OldValue == e.NewValue||e.NewValue==null) |
| | | if (e.OldValue == e.NewValue || e.NewValue == null) |
| | | return; |
| | | |
| | | |
| | | double FNumerator = Convert.ToDouble(model.GetValue("FNumerator", e.Row));//分子 |
| | | double FDenominator = Convert.ToDouble(model.GetValue("FDenominator", e.Row));//分母 |
| | | double FUseRateNew = Convert.ToDouble(model.GetValue("FUseRateNew", e.Row));//使用比例 |
| | |
| | | } |
| | | Hqty = Math.Ceiling((FNumerator / FDenominator) * FHQty * (FUseRateNew / 100)); |
| | | this.View.Model.SetValue("FHQtyMustNew", Hqty, e.Row);//新计划数量 |
| | | |
| | | var m = e.Row; |
| | | //项次 |
| | | var pro = model.GetValue("FReplaceGroup", m).ToString(); |
| | |
| | | //查找到的同批项次 |
| | | var finds = entrys.Where(entry => entry.GetValue<string>("FReplaceGroup") == pro && entry.GetValue<int>("Seq") != (m + 1)); |
| | | if (finds.Count() == 0) return; |
| | | |
| | | var seq = finds.First().GetValue<int>("Seq"); |
| | | model.SetValue("FUseRateNew", 100 - Convert.ToDouble(e.NewValue), seq - 1); |
| | | //int FentryID = Convert.ToInt32(model.GetEntryPKValue("FEntity",e.Row));//明细表id |
| | | ////查询同项次的序号 |
| | | //string sql = |
| | | // $"select top 1 FSEQ from Sc_DayPlanPPBomBillSubBG where FReplaceGroup in(select FReplaceGroup from Sc_DayPlanPPBomBillSubBG where FEntryID = {FentryID} )and FEntryID<> { FentryID} "; |
| | | //int Fseq = DBServiceHelper.ExecuteScalar<int>(Context,sql,0); |
| | | //if (Fseq > 0) { |
| | | // this.View.Model.SetValue("FUseRateNew", 100 - FUseRateNew, Fseq - 1);//新计划数量 |
| | | //} |
| | | } |
| | | if (e.Field.Key.Contains("FHQtyMustNew")) |
| | | { |
| | | if (e.OldValue == e.NewValue) |
| | | if (e.OldValue == e.NewValue || e.NewValue == null) |
| | | return; |
| | | var m = e.Row; |
| | | double FNumerator = Convert.ToDouble(model.GetValue("FNumerator", e.Row));//分子 |
| | |
| | | Hqty = Math.Ceiling(FHQtyMustNew / FHQty * 100); |
| | | } |
| | | Hqty = Math.Ceiling(FHQtyMustNew / ((FNumerator / FDenominator) * FHQty) * 100); |
| | | this.View.Model.SetValue("FUseRateNew", Hqty, e.Row);//新计划数量 |
| | | |
| | | //int FentryID = Convert.ToInt32(model.GetEntryPKValue("FEntity", e.Row));//明细表id |
| | | ////查询同项次的序号 |
| | | //string sql = |
| | | // $"select top 1 FSEQ from Sc_DayPlanPPBomBillSubBG where FReplaceGroup in(select FReplaceGroup from Sc_DayPlanPPBomBillSubBG where FEntryID = {FentryID} )and FEntryID<> { FentryID} "; |
| | | //int Fseq = DBServiceHelper.ExecuteScalar<int>(Context, sql, 0); |
| | | //if (Fseq > 0) |
| | | //{ |
| | | // double FUseRateNew = Convert.ToDouble(model.GetValue("FUseRateNew", e.Row));//使用比例 |
| | | // this.View.Model.SetValue("FUseRateNew", 100 - FUseRateNew, Fseq - 1);//新计划数量 |
| | | //} |
| | | this.View.Model.SetValue("FUseRateNew", Hqty, e.Row);//新用料比例 |
| | | } |
| | | } |
| | | |
| | | //public override void BeforeSave(BeforeSaveEventArgs e) |
| | | //{ |
| | | // base.BeforeSave(e); |
| | | public override void BeforeSave(BeforeSaveEventArgs e) |
| | | { |
| | | base.BeforeSave(e); |
| | | var entrys = this.View.Model.DataObject.GetValue<DynamicObjectCollection>("FEntity"); |
| | | string resultMes = ""; |
| | | foreach (var entry in entrys) |
| | | { |
| | | var fReplaceGroup = entry["FReplaceGroup"].ToString(); |
| | | //LogService.WriteAsync(entrys); |
| | | //查找到的同批项次 |
| | | var finds = entrys.Where(trys => trys.GetValue<string>("FReplaceGroup") == fReplaceGroup); |
| | | if (finds.Count() > 1) return; |
| | | |
| | | // e.Cancel = true; |
| | | //} |
| | | string sql = string.Format(@"/*dialect*/ |
| | | select count(*) from Sc_DayPlanPPBomBillSub a |
| | | join Sc_DayPlanPPBomBillMain b on a.FID = b.FID |
| | | where FREPLACEGROUP = '{0}' and FHMaterSubID<> '{1}' and(FPickedQty + FTranslateQty) > FHQty * ((100 - {2}) / 100.0) * FDwyl and a.FID = {3}", entry["FReplaceGroup"].ToString(), entry["FHMaterSubID_Id"].ToString(), entry["FUseRateNew"].ToString(), entry["FDayPlanId"].ToString()); |
| | | int result = DBServiceHelper.ExecuteScalar<int>(Context, sql, 0); |
| | | if (result > 0) |
| | | resultMes += $"行号:" + entry["Seq"].ToString() + ",存在替代料关系,使用比例变更后超出了领用数量"; |
| | | } |
| | | if (resultMes != "") |
| | | { |
| | | e.Cancel = true; |
| | | this.View.ShowErrMessage(resultMes); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |