public bool SaveServiceNorms(bool isSaveNull, System.DateTime normDate, 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 serviceNormId = service.ServiceNormId;
         if ((num == 0M) && !isSaveNull)
         {
             bool flag = false;
             foreach (System.Data.DataRow row2 in this.dtServiceNormTypes.Rows)
             {
                 if (serviceNormId == ((long) row2.get_Item("serviceNormId")))
                 {
                     decimal num3 = (decimal) row2.get_Item("rate");
                     if ((num3 != 0M) || isSaveNull)
                     {
                         flag = true;
                     }
                 }
             }
             foreach (System.Data.DataRow row3 in this.dtServiceNormTypesByProperty.Rows)
             {
                 if (serviceNormId == ((long) row3.get_Item("serviceNormId")))
                 {
                     decimal num4 = (decimal) row3.get_Item("rate");
                     if ((num4 != 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 row4 in (System.Collections.IEnumerable) this.dgvServices.Rows)
     {
         object obj3 = row4.Cells.get_Item("NewRateColumn").get_Value();
         decimal num5 = this.ObjectParseDecimal(ref obj3);
         if ((num5 != 0M) || isSaveNull)
         {
             Service service2 = row4.get_DataBoundItem() as Service;
             long num6 = service2.ServiceNormId;
             ServiceNorm norm = new ServiceNorm();
             ServiceNorm norm2 = ServiceNorm.FindById(service2.ServiceNormId);
             norm.ServiceId = service2.Id;
             norm.ByUnit = norm2.ByUnit;
             norm.Unit = norm2.Unit;
             norm.Datec = now;
             norm.Dateb = normDate;
             norm.FromDate = normDate;
             norm.Rate = num5;
             norm.OrgDocumentId = docId;
             norm.SaveChanges();
             foreach (System.Data.DataRow row5 in this.dtServiceNormTypes.Rows)
             {
                 if (num6 == ((long) row5.get_Item("serviceNormId")))
                 {
                     decimal num7 = (decimal) row5.get_Item("rate");
                     if ((num7 != 0M) || isSaveNull)
                     {
                         new ServiceNormType { ServiceNormId = norm.Id, ApartmentPropertyId = (int) ((int) row5.get_Item("apartmentPropertyId")), Rate = (decimal) row5.get_Item("rate") }.SaveChanges();
                     }
                 }
             }
             foreach (System.Data.DataRow row6 in this.dtServiceNormTypesByProperty.Rows)
             {
                 if (num6 == ((long) row6.get_Item("serviceNormId")))
                 {
                     decimal num8 = (decimal) row6.get_Item("rate");
                     if ((num8 != 0M) || isSaveNull)
                     {
                         new ServiceNormType { ServiceNormId = norm.Id, ApartmentPropertyId = (int) ((int) row6.get_Item("apartmentPropertyId")), Rate = (decimal) row6.get_Item("rate") }.SaveChanges();
                     }
                 }
             }
         }
     }
     return true;
 }
Example #2
0
 public ObjectWithId AddNorm(ServiceNormDTO dto)
 {
     ServiceNorm norm = new ServiceNorm();
     norm.SaveChanges(dto);
     return norm;
 }