public ObjectWithId AddTariff(ServiceTariffDTO dto) { ServiceTariff tariff = new ServiceTariff(); tariff.SaveChanges(dto); return tariff; }
public bool SaveTariff(bool isSaveNull, System.DateTime tariffDate, long docId) { string str = string.Empty; foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvServices.Rows) { object ob = row.Cells.get_Item("NewRateColumn").get_Value(); decimal num = this.ObjectParseDecimal(ref ob); Service service = row.get_DataBoundItem() as Service; long lastRateId = service.LastRateId; if ((num == 0M) && !isSaveNull) { bool flag = false; foreach (System.Data.DataRow row2 in this.dtServiceTariffTypes.Rows) { if (lastRateId == ((long) row2.get_Item("serviceTariffId"))) { decimal num3 = (decimal) row2.get_Item("rate"); if ((num3 != 0M) || isSaveNull) { flag = true; } } } if (flag) { str = str + ((long) service.Code) + ","; } } } if ((str != string.Empty) && (Messages.QuestionYesNo(this, string.Concat((string[]) new string[] { "Для услуг с кодом:", str, System.Environment.get_NewLine(), "заданы подчиненные тарифы,но не заданы сами тарифы,", System.Environment.get_NewLine(), "поэтому подчиненные тарифы для этих услуг не сохраняться,продолжить?" })) != System.Windows.Forms.DialogResult.Yes)) { return false; } System.DateTime now = System.DateTime.Now; foreach (System.Windows.Forms.DataGridViewRow row3 in (System.Collections.IEnumerable) this.dgvServices.Rows) { object obj3 = row3.Cells.get_Item("NewRateColumn").get_Value(); decimal num4 = this.ObjectParseDecimal(ref obj3); if ((num4 != 0M) || isSaveNull) { Service service2 = row3.get_DataBoundItem() as Service; long num5 = service2.LastRateId; ServiceTariff tariff = new ServiceTariff { ServiceId = service2.Id, FromDate = tariffDate, Created = now, OrgDocumentId = docId, Rate = num4 }; tariff.SaveChanges(); foreach (System.Data.DataRow row4 in this.dtServiceTariffTypes.Rows) { if (num5 == ((long) row4.get_Item("serviceTariffId"))) { decimal num6 = (decimal) row4.get_Item("rate"); if ((num6 != 0M) || isSaveNull) { new ServiceTariffType { ServiceTariffId = tariff.Id, TariffTypeId = (int) ((int) row4.get_Item("typeId")), Rate = num6 }.SaveChanges(); } } } } } return true; }