Example #1
0
        private void FormFiscalPeriod_Load(object sender, EventArgs e)
        {
            contxt = new PMModel();
            period = new FiscalPeriod();
            LoadPeriods();
            LoadStatus();
            isNew = false; isEdit = false;

            isFormLoading = false;
        }
Example #2
0
 private void dgvFP_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (!isFormLoading)
     {
         period = (FiscalPeriod)dgvFP.Rows[e.RowIndex].DataBoundItem;
         isNew  = false; isEdit = true;
         state  = FORMSTATE.EDIT;
         SetButtons();
         ShowObject();
     }
 }
Example #3
0
        private bool CheckValidityPeriod()
        {
            bool validity = false;

            period = contxt.FiscalPeriods.FirstOrDefault(o => o.FromDate.Value.Month == dtM.Value.Month &&
                                                         o.FromDate.Value.Year == dtM.Value.Year);
            if (period != null)
            {
                if (period.Status == 0)
                {
                    validity = true;
                }
            }
            return(validity);
        }
Example #4
0
 private void OpenClosePeriod()
 {
     period = contxt.FiscalPeriods.FirstOrDefault(o => o.FromDate.Value.Month == dtM.Value.Month &&
                                                  o.FromDate.Value.Year == dtM.Value.Year);
     if (period == null)
     {
         period          = new FiscalPeriod();
         period.FromDate = new DateTime(dtM.Value.Year, dtM.Value.Month, 1);
         period.Todate   = period.FromDate.Value.AddMonths(1).AddDays(period.FromDate.Value.Day * -1);
         period.Status   = chkClose.Checked ? 1 : 0;;
         contxt.FiscalPeriods.Add(period);
         contxt.Entry(period).State = System.Data.Entity.EntityState.Added;
         contxt.SaveChanges();
     }
     else
     {
         period.Status = chkClose.Checked ? 1 : 0;
         contxt.Entry(period).State = System.Data.Entity.EntityState.Modified;
         contxt.SaveChanges();
     }
 }
Example #5
0
 private void Save()
 {
     if (isNew)
     {
         contxt.FiscalPeriods.Add(period);
         contxt.Entry(period).State = System.Data.Entity.EntityState.Added;
         contxt.SaveChanges();
         contxt.Entry(period).Reload();
     }
     if (isEdit)
     {
         FiscalPeriod ptemp = contxt.FiscalPeriods.FirstOrDefault(o => o.id == period.id);
         if (ptemp != null)
         {
             ptemp.FromDate            = period.FromDate;
             ptemp.Todate              = period.Todate;
             ptemp.Status              = period.Status;
             contxt.Entry(ptemp).State = System.Data.Entity.EntityState.Modified;
             contxt.SaveChanges();
             contxt.Entry(period).Reload();
         }
     }
     //throw new NotImplementedException();
 }