protected void btnSetPurchase_Click(object sender, EventArgs e)
 {
     if (Page.IsPostBack && ddlFiscalYear.SelectedValue != "-1")
     {
         string[]           GetDates = ddlFiscalYear.SelectedItem.Text.Split('-');
         DateTime           from     = Convert.ToDateTime(GetDates[0]);
         DateTime           to       = Convert.ToDateTime(GetDates[1]);
         Models.MFiscalYear mf       = new Models.MFiscalYear();
         mf.fiscalFrom = from;
         mf.fiscalTo   = to;
         int fiscalYearId       = Convert.ToInt32(ddlFiscalYear.SelectedValue);
         Classes.CFiscalYear cf = new Classes.CFiscalYear();
         if (cf.UpdateDefaultFiscalYear(fiscalYearId) < 0)
         {
             ShowFailMessage();
         }
         else
         {
             ShowSuccessMessage();
         }
     }
     else
     {
         ShowErrorModal("Please select a fiscal year");
     }
 }
Beispiel #2
0
 public int Update(Models.MFiscalYear model)
 {
     try
     {
         var query = from o in obj.FiscalYears where model.id == o.id select o;
         foreach (var item in query)
         {
             item.fiscalFrom = model.fiscalFrom;
             item.fiscalTo   = model.fiscalTo;
         }
         obj.SubmitChanges();
         return(1);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Beispiel #3
0
        public List <Models.MFiscalYear> GetAllById(int FiscalYear)
        {
            List <Models.MFiscalYear> Get = new List <Models.MFiscalYear>();
            var query = from o in obj.FiscalYears
                        where o.id == FiscalYear
                        select
                        o;

            foreach (var item in query)
            {
                Models.MFiscalYear mf = new Models.MFiscalYear();
                mf.fiscalFrom = Convert.ToDateTime(item.fiscalFrom);
                mf.fiscalTo   = Convert.ToDateTime(item.fiscalTo);
                Get.Add(mf);
            }

            return(Get);
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid && IsPostBack)
     {
         DateTime           from = Convert.ToDateTime(txtFrom.Text);
         DateTime           to   = Convert.ToDateTime(txtTo.Text);
         Models.MFiscalYear mf   = new Models.MFiscalYear();
         mf.fiscalFrom = from;
         mf.fiscalTo   = to;
         Classes.CFiscalYear cf = new Classes.CFiscalYear();
         if (cf.Save(mf) > 0)
         {
             ShowSuccessMessage();
         }
         else
         {
             ShowFailMessage();
         }
     }
 }
Beispiel #5
0
        public int Save(Models.MFiscalYear model)
        {
            try
            {
                DB.FiscalYear fy = new DB.FiscalYear();
                fy.fiscalFrom = model.fiscalFrom;
                fy.fiscalTo   = model.fiscalTo;
                obj.FiscalYears.InsertOnSubmit(fy);
                obj.SubmitChanges();


                //Setting the newly added fiscal year as default
                UpdateDefaultFiscalYear(GetLastFiscalYearId());
                return(1);
            }
            catch
            {
                return(-1);
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid && IsPostBack)
     {
         DateTime           from = Convert.ToDateTime(txtFrom.Text);
         DateTime           to   = Convert.ToDateTime(txtTo.Text);
         Models.MFiscalYear mf   = new Models.MFiscalYear();
         mf.fiscalFrom = from;
         mf.fiscalTo   = to;
         Classes.CFiscalYear cf = new Classes.CFiscalYear();
         if (cf.Save(mf) > 0)
         {
             Response.Redirect("~/Pages/Main.aspx");
         }
         else
         {
             ShowErrorModal("there was an error saving the new fiscal year");
         }
     }
 }