private void GetData() { try { List <AccountCode> data = new AccountCodeDAL().GetAccountCodes().ToList(); if (data.Count == 0) { data = new List <AccountCode>(); data.Add(new AccountCode() { AccountCode1 = string.Empty, ParentAccountCode = string.Empty }); List <DAL.YearUploadSetup> GetData = new YearUploadDAL().GetYearUpload(); DAL.YearUploadSetup curryear = GetData.Where(x => x.BudgetYear == DateTime.Now.Year).FirstOrDefault(); if (curryear.ToString().Count() > 0) { if (!GetData.Where(y => y.BudgetYear == curryear.BudgetYear).Select(z => z.Status.Contains("A")).FirstOrDefault()) { btnFileUpload.HRef = "#"; } } } Session["AccountCodesData"] = data; } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }
public bool InsertYearUpload(YearUploadSetup objYearUpload) { try { db.YearUploadSetups.Add(objYearUpload); db.SaveChanges(); BPEventLog bpe = new BPEventLog(); bpe.Object = "Year Upload Setup"; bpe.ObjectName = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc; bpe.ObjectChanges = "<tr><td>Status</td><td></td><td>" + ((objYearUpload.Status == "A") ? "Active" : "Ended") + "</td></tr>"; bpe.EventMassage = "Success"; bpe.Status = "A"; bpe.CreatedBy = objYearUpload.CreatedBy; bpe.CreatedTimeStamp = objYearUpload.CreatedTimeStamp; new EventLogDAL().AddEventLog(bpe); return(true); } catch (Exception ex) { BPEventLog bpe = new BPEventLog(); bpe.Object = "Year Upload Setup"; bpe.ObjectName = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc; bpe.ObjectChanges = "<tr><td>Status</td><td></td><td>" + ((objYearUpload.Status == "A") ? "Active" : "Ended") + "</td></tr>"; bpe.EventMassage = "Failure"; bpe.Status = "A"; bpe.CreatedBy = objYearUpload.CreatedBy; bpe.CreatedTimeStamp = objYearUpload.CreatedTimeStamp; new EventLogDAL().AddEventLog(bpe); throw ex; } }
private void GetData() { try { selectedSegment = (Segment)Session["SelectedSegment"]; List <SegmentDetail> data = new SegmentDetailsDAL().GetSegmentDetails(selectedSegment.SegmentID); if (data.Count == 0) { data = new List <SegmentDetail>(); data.Add(new SegmentDetail() { SegmentID = 0, SegmentDetailID = 0, ParentDetailID = 0 }); List <DAL.YearUploadSetup> GetData = new YearUploadDAL().GetYearUpload(); DAL.YearUploadSetup curryear = GetData.Where(x => x.BudgetYear == DateTime.Now.Year).FirstOrDefault(); if (curryear.ToString().Count() > 0) { if (!GetData.Where(y => y.BudgetYear == curryear.BudgetYear).Select(z => z.Status.Contains("A")).FirstOrDefault()) { btnFileUpload.HRef = "#"; } } } Session["SegmentDetailsData"] = data; } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }
//protected void btnCancel_Click(object sender, EventArgs e) //{ // ChangePageMode(Helper.PageMode.New); // ClearPageData(); // EditForm.Visible = false; //} protected void gvYearUploadSetup_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "EditRow") { ClearPageData(); GridViewRow selectedRow = gvYearUploadSetup.Rows[Convert.ToInt32(e.CommandArgument)]; selectedRow.Style["background-color"] = "skyblue"; int budgetyearid = Convert.ToInt32(gvYearUploadSetup.DataKeys[selectedRow.RowIndex]["BudgetYearID"]); DAL.YearUploadSetup objYearUpload = ((List <DAL.YearUploadSetup>)Session["YearUploadData"]).Where(x => x.BudgetYearID == budgetyearid).FirstOrDefault(); Session["SelectedYearUpload"] = objYearUpload; ddlYear.SelectedIndex = -1; ddlYear.Items.FindByValue(objYearUpload.BudgetYear.ToString()).Selected = true; ddlStatus.SelectedIndex = -1; ddlStatus.Items.FindByValue(new Helper().GetItemStatusEnumName(Convert.ToChar(objYearUpload.Status))).Selected = true; tbDesc.Text = objYearUpload.BudgetYearDesc; ChangePageMode(Helper.PageMode.Edit); EditForm.Visible = true; } } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }
public bool UpdateYearUpload(YearUploadSetup objYearUpload) { YearUploadSetup obj = db.YearUploadSetups.Where(x => x.BudgetYear == objYearUpload.BudgetYear).FirstOrDefault(); string changes = new EventLogDAL().ObjectDifference(obj, objYearUpload); try { if (obj != null) { obj.BudgetYear = objYearUpload.BudgetYear; obj.BudgetYearDesc = objYearUpload.BudgetYearDesc; obj.Status = objYearUpload.Status; obj.ModifiedBy = objYearUpload.ModifiedBy; obj.ModifiedTimeStamp = objYearUpload.ModifiedTimeStamp; db.SaveChanges(); BPEventLog bpe = new BPEventLog(); bpe.Object = "Year Upload Setup"; bpe.ObjectName = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc;; bpe.ObjectChanges = changes; bpe.EventMassage = "Success"; bpe.Status = "A"; bpe.CreatedBy = objYearUpload.ModifiedBy; bpe.CreatedTimeStamp = objYearUpload.ModifiedTimeStamp; new EventLogDAL().AddEventLog(bpe); } return(true); } catch (Exception ex) { BPEventLog bpe = new BPEventLog(); bpe.Object = "Year Upload Setup"; bpe.ObjectName = objYearUpload.BudgetYear + " - " + objYearUpload.BudgetYearDesc; bpe.ObjectChanges = changes; bpe.EventMassage = "Failure"; bpe.Status = "A"; bpe.CreatedBy = objYearUpload.ModifiedBy; bpe.CreatedTimeStamp = objYearUpload.ModifiedTimeStamp; new EventLogDAL().AddEventLog(bpe); throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { if ((Helper.PageMode)Session["YearUploadPageMode"] == Helper.PageMode.New) { if (new YearUploadDAL().GetYearUpload().Where(x => x.BudgetYear == Convert.ToInt32(ddlYear.SelectedValue)).Count() > 0) { ((SiteMaster)this.Master).ShowMessage("Failure", "Year Upload already exists"); return; } DAL.YearUploadSetup objYearUpload = new DAL.YearUploadSetup(); objYearUpload.BudgetYear = Convert.ToInt32(ddlYear.SelectedValue); objYearUpload.BudgetYearDesc = tbDesc.Text; objYearUpload.Status = new Helper().GetItemStatusEnumValueByName(ddlStatus.SelectedValue); objYearUpload.CreatedBy = LoggedInUser.UserID; objYearUpload.CreatedTimeStamp = DateTime.Now; objYearUpload.ModifiedBy = LoggedInUser.UserID; objYearUpload.ModifiedTimeStamp = DateTime.Now; if (new YearUploadDAL().InsertYearUpload(objYearUpload)) { ((SiteMaster)this.Master).ShowMessage("Success", "Year Upload saved successfully"); } else { ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while processing Year Upload"); } } else if ((Helper.PageMode)Session["YearUploadPageMode"] == Helper.PageMode.Edit) { DAL.YearUploadSetup objYearUpload = (DAL.YearUploadSetup)Session["SelectedYearUpload"]; DAL.YearUploadSetup pm = new YearUploadDAL().GetYearUpload() .Where(x => x.BudgetYear == Convert.ToInt32(ddlYear.SelectedValue)).FirstOrDefault(); if (pm != null) { if (pm.BudgetYearID != objYearUpload.BudgetYearID) { ((SiteMaster)this.Master).ShowMessage("Failure", "Year Upload already exists"); return; } } objYearUpload.BudgetYear = Convert.ToInt32(ddlYear.SelectedValue); objYearUpload.BudgetYearDesc = tbDesc.Text; objYearUpload.Status = new Helper().GetItemStatusEnumValueByName(ddlStatus.SelectedValue); objYearUpload.ModifiedBy = LoggedInUser.UserID; objYearUpload.ModifiedTimeStamp = DateTime.Now; if (new YearUploadDAL().UpdateYearUpload(objYearUpload)) { ((SiteMaster)this.Master).ShowMessage("Success", "Year Upload updated successfully"); } else { ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Year Upload"); } } GetData(); ClearPageData(); EditForm.Visible = false; } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }