Example #1
0
        public void SaveOldRow(TblJournalViewModel oldRow)
        {
            if (oldRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid)
                {
                    var save = oldRow.Iserial == 0;
                    if (AllowUpdate != true && !save)
                    {
                        MessageBox.Show(strings.AllowUpdateMsg);
                        return;
                    }
                    var saveRow = new TblJournal();
                    saveRow.InjectFrom(oldRow);
                    if (!Loading)
                    {
                        Loading = true;
                        Glclient.UpdateOrInsertTblJournalsAsync(saveRow, save, MainRowList.IndexOf(oldRow),
                                                                LoggedUserInfo.DatabasEname);
                    }
                }
            }
        }
Example #2
0
 private string HandelSequence(string code, TblJournal journal, string table, string company, int no, int month, int year, out int seqq)
 {
     using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
     {
         return(HandelSequence(code, journal, table, no, month, year, entity, out seqq));
     }
 }
Example #3
0
        private int DeleteTblJournal(TblJournal row, int index, string company)
        {
            using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
            {
                var query = (from e in entity.TblJournals
                             where e.Iserial == row.Iserial
                             select e).SingleOrDefault();
                if (query != null)
                {
                    entity.DeleteObject(query);
                }

                entity.SaveChanges();
            }
            return(row.Iserial);
        }
Example #4
0
 private TblJournal UpdateOrInsertTblJournals(TblJournal newRow, bool save, int index, out int outindex, string company)
 {
     outindex = index;
     using (var entity = new ccnewEntities(GetSqlConnectionString(company)))
     {
         if (save)
         {
             entity.TblJournals.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in entity.TblJournals
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, entity);
             }
         }
         entity.SaveChanges();
         return(newRow);
     }
 }
Example #5
0
        public SearchJournalViewModel()
        {
            if (!IsDesignTime)
            {
                Glclient = new GlServiceClient();

                MainRowList     = new SortableCollectionView <TblJournal>();
                SelectedMainRow = new TblJournal();

                Glclient.GetTblJournalCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        MainRowList.Add(row);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                };

                GetMaindata();
            }
        }
Example #6
0
        private string HandelSequence(string code, TblJournal journal, string table, int no, int month, int year, ccnewEntities entity, out int seqq)
        {
            seqq = 0;
            var        temp       = "";
            var        tempFormat = "";
            const char aa         = '0';

            if (table == "TblLedgerHeader")
            {
                if (journal.TblSequence.UseDateTime)
                {
                    for (var i = 0; i < journal.TblSequence.NumberOfInt; i++)
                    {
                        tempFormat = tempFormat + aa;
                    }
                    var seq = 0;
                    try
                    {
                        var tblLedgerHeader = entity.TblLedgerHeaders.Where(
                            x => x.TblSequence == journal.HeaderSequence && x.DocDate.Value.Month == month && x.DocDate.Value.Year == year).OrderByDescending(x => x.Sequence).FirstOrDefault();
                        if (tblLedgerHeader !=
                            null)
                        {
                            seq = tblLedgerHeader.Sequence;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    seqq = seq + 1;
                    temp = seqq.ToString(tempFormat) + month.ToString("00") + year.ToString().Substring(2, 2) + journal.TblSequence.Format;
                }
                else
                {
                    if (journal.TblSequence.Manual)
                    {
                        if (Find(table, code, entity))
                        {
                            throw new Exception("Already Exists");
                        }
                    }
                    else
                    {
                        for (var i = 0; i < journal.TblSequence.NumberOfInt; i++)
                        {
                            tempFormat = tempFormat + aa;
                        }
                        temp = journal.TblSequence.NextRec.ToString(tempFormat) + journal.TblSequence.Format;
                        var seq = entity.TblSequences.FirstOrDefault(x => x.Iserial == journal.HeaderSequence);

                        if (seq != null)
                        {
                            seq.NextRec = seq.NextRec + 1;
                        }
                    }
                }
            }
            else
            {
                if (journal.TblSequence1.Manual)
                {
                    if (Find(table, code, entity))
                    {
                        throw new Exception("Already Exists");
                    }
                }
                else
                {
                    for (var i = 0; i < journal.TblSequence1.NumberOfInt; i++)
                    {
                        tempFormat = tempFormat + aa;
                    }
                    var tempno = journal.TblSequence1.NextRec + no;
                    temp = tempno.ToString(tempFormat) + journal.TblSequence1.Format;
                    var seq = entity.TblSequences.FirstOrDefault(x => x.Iserial == journal.DetailSequence);

                    if (seq != null)
                    {
                        seq.NextRec = seq.NextRec + 1 + no;
                    }
                }
            }
            try
            {
                entity.SaveChanges();
            }
            catch (Exception e) { throw new Exception(e.Message); }

            return(temp);
        }