예제 #1
0
        public void SaveSubDetailRow()
        {
            if (SelectedSubDetailRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedSubDetailRow,
                                                          new ValidationContext(SelectedSubDetailRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = SelectedSubDetailRow.Iserial == 0;
                    if (SelectedSubDetailRow.TblJournalSetting == 0)
                    {
                        SelectedSubDetailRow.TblJournalSetting = SelectedDetailRow.Iserial;
                    }


                    if (AllowUpdate != true)
                    {
                        return;
                    }


                    var rowToSave = new TblJournalSettingCostCenter();
                    rowToSave.InjectFrom(SelectedSubDetailRow);
                    if (!Loading)
                    {
                        Loading = true;

                        Glclient.UpdateOrInsertTblJournalSettingCostCentersAsync(rowToSave, save,
                                                                                 SelectedMainRow.SubDetailList.IndexOf(SelectedSubDetailRow), LoggedUserInfo.DatabasEname);
                    }
                }
            }
        }
예제 #2
0
 private TblJournalSettingCostCenter UpdateOrInsertTblJournalSettingCostCenters(TblJournalSettingCostCenter newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var CostCenter = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             CostCenter.TblJournalSettingCostCenters.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in CostCenter.TblJournalSettingCostCenters
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, CostCenter);
             }
         }
         CostCenter.SaveChanges();
         return(newRow);
     }
 }