protected void FCGrid_OnRowCommand(object sender, GridViewCommandEventArgs e) { try { int rowIndex = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "Edit") { hdnFCId.Value = e.CommandArgument.ToString(); txtCategoryName.Value = FCGrid.Rows[rowIndex - 1].Cells[1].Text; txtCategoryNamedesc.Value = FCGrid.Rows[rowIndex - 1].Cells[2].Text; btnsubmit.InnerText = "Update"; } else if (e.CommandName == "Delete") { using (FileTrackingContainer container = new FileTrackingContainer()) { var agentToRemove = container.FileCategories.Find(rowIndex); container.FileCategories.Remove(agentToRemove); container.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('Deleted sucessfully');", true); BindData(); } } } catch (Exception exception) { } }
protected void F_OnRowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "Edit") { hdnFileId.Value = e.CommandArgument.ToString(); //txtname.Value = AgentGrid.Rows[rowIndex - 1].Cells[1].Text; //var agentType = AgentGrid.Rows[rowIndex - 1].Cells[2].Text; //ddlagenttype.Items[0].Selected = false; //ddlagenttype.Items.FindByText(agentType).Selected = true; //txtAgentEmployeeName.Value = AgentGrid.Rows[rowIndex - 1].Cells[3].Text; //var access = AgentGrid.Rows[rowIndex - 1].Cells[4].Text; //ddlagentaccess.Items[0].Selected = false; //ddlagentaccess.Items.FindByText(access).Selected = true; //txtagentmobile.Value = AgentGrid.Rows[rowIndex - 1].Cells[5].Text; //txtemail.Value = AgentGrid.Rows[rowIndex - 1].Cells[6].Text; //txtagentscanpref.Value = AgentGrid.Rows[rowIndex - 1].Cells[7].Text; //txtagentsec.Value = AgentGrid.Rows[rowIndex - 1].Cells[8].Text; btnSubmit.InnerText = "Update"; } else if (e.CommandName == "Delete") { using (FileTrackingContainer container = new FileTrackingContainer()) { var agentToRemove = container.FileDatas.Find(rowIndex); container.FileDatas.Remove(agentToRemove); container.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('Deleted sucessfully');", true); BuildFilesGrid(); } } }
protected void btn_submit_ServerClick(object sender, EventArgs e) { if (btn_submit.InnerText == "Submit") { Status status = new Status { StatusName = txtstatusName.Value, CreatedDate = DateTime.Now, CreatedBy = 1 }; FileTrackingContainer entities = new FileTrackingContainer(); entities.Status.Add(status); entities.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('Add Status sucessfull');", true); resetcontrols(); } else if (btn_submit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { var id = int.Parse(hdnFCId.Value); var resultToUpdate = container.Status.SingleOrDefault(item => item.StatusId == id); if (resultToUpdate != null) { resultToUpdate.StatusName = txtstatusName.Value; resultToUpdate.ModifiedDate = DateTime.Now; } container.SaveChanges(); BindData(); } } }
void BindData() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.ClientCategories select new { query.ClientCategoryName, query.ClientCategoryDescription, query.ClientId, query.dateadded }).ToList(); if (data.Count > 0) { CCGrid.DataSource = data; CCGrid.DataBind(); } else { CCGrid.DataSource = new List <DAL.ClientCategory>(); CCGrid.DataBind(); } } } catch (Exception e) { } }
void BindData() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.Status select new { query.StatusId, query.CreatedDate, query.StatusName }).ToList(); if (data.Count > 0) { FCGrid.DataSource = data; FCGrid.DataBind(); } else { FCGrid.DataSource = new List <DAL.Status>(); FCGrid.DataBind(); } } } catch (Exception e) { } }
void BindGrid() { try { var searchValue = txtSearch.Value.Split(','); using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.FileDatas join stat in container.Status on query.CurrentStatus equals stat.StatusName join ag in container.Agents on query.CurrentAgentId equals ag.AgentId into leftAg from agents in leftAg.DefaultIfEmpty(new DAL.Agent()) where (agents.AgentName.Contains(txtSearch.Value) || stat.StatusName.Contains(txtSearch.Value)) select new { query.FileId, query.FileCode, query.FileEntredOn, query.CurrentStatus, agents.AgentName, agents.AgentMobile }).ToList(); SRGrid.DataSource = data; SRGrid.DataBind(); } } catch (Exception e) { } }
void BindData() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.FilePriorities select new { query.FilePriorityId, query.FilePriorityName, query.FilePriorityIntervalAlert, query.FilePriorityIntervalCrit, query.FilePriorityIntervalNotif, query.CreatedDate }).ToList(); if (data.Count > 0) { FPGrid.DataSource = data; FPGrid.DataBind(); } else { FPGrid.DataSource = new List <DAL.Agent>(); FPGrid.DataBind(); } } } catch (Exception e) { } }
void BuildFilesGrid() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.FileDatas join c in container.Clients on query.ClientId equals c.ClientId join fc in container.FileCategories on query.FileCategoryId equals fc.FileCategoryId join fp in container.FilePriorities on query.FilePriorityId equals fp.FilePriorityId join a in container.Agents on query.CurrentAgentId equals a.AgentId //into ag //from b in ag.DefaultIfEmpty(new DAL.Agent()) select new { query.FileDataId, query.FileId, query.FileNoExt, query.FileNoInt, c.ClientName, fc.FileCategoryName, fp.FilePriorityName, query.CurrentStatus, a.AgentName, query.FileEntredOn, query.FileDeliveredOn, query.SubjectBrief, query.SubjectDesc, query.CmoSection, query.LastUpdated, query.FileCode, query.ContactPersonName, query.ContactPersonNumber, query.FundType, query.FundSource, query.Scheme, query.Year, query.AmountProposed, query.AmountApproved, query.AmountMisc }).ToList(); if (data.Count > 0) { FGrid.DataSource = data; FGrid.DataBind(); } else { FGrid.DataSource = new List <FileData>(); FGrid.DataBind(); } } } catch (Exception e) { } }
protected void btnsubmit_ServerClick(object sender, EventArgs e) { try { if (btnsubmit.InnerText == "Submit") { FilePriority filePriorities = new FilePriority { FilePriorityIntervalAlert = string.IsNullOrEmpty(txtintervalAlert.Value) ? 0 : Convert.ToDecimal(txtintervalAlert.Value), FilePriorityIntervalCrit = string.IsNullOrEmpty(txtPriorityIntervalCrit.Value) ? 0 : Convert.ToDecimal(txtPriorityIntervalCrit.Value), FilePriorityIntervalNotif = string.IsNullOrEmpty(txtintervalNotif.Value) ? 0 : Convert.ToDecimal(txtintervalNotif.Value), FilePriorityName = txtpriorityname.Value, CreatedBy = 1, CreatedDate = DateTime.Now }; FileTrackingContainer entities = new FileTrackingContainer(); entities.FilePriorities.Add(filePriorities); entities.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('FilePriority added sucessfully');", true); BindData(); } else if (btnsubmit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { var id = int.Parse(hdnFPId.Value); var resultToUpdate = container.FilePriorities.SingleOrDefault(item => item.FilePriorityId == id); if (resultToUpdate != null) { resultToUpdate.FilePriorityName = txtpriorityname.Value; resultToUpdate.FilePriorityIntervalAlert = Convert.ToDecimal(txtintervalAlert.Value); resultToUpdate.FilePriorityIntervalCrit = Convert.ToDecimal(txtPriorityIntervalCrit.Value); resultToUpdate.FilePriorityIntervalNotif = Convert.ToDecimal(txtintervalNotif.Value); resultToUpdate.ModifiedBy = 1; resultToUpdate.ModifiedDate = DateTime.Now; } container.SaveChanges(); BindData(); } } ResetControls(); } catch (Exception exception) { Console.WriteLine(exception); } }
protected void btnsubmit_ServerClick(object sender, EventArgs e) { try { if (btnsubmit.InnerText == "Submit") { FileCategory fileCategory = new FileCategory { FileCategoryName = txtCategoryName.Value, FileCategoryDescription = txtCategoryNamedesc.Value, CreatedDate = DateTime.Now, CreatedBy = 1 }; FileTrackingContainer entities = new FileTrackingContainer(); entities.FileCategories.Add(fileCategory); entities.SaveChanges(); resetcontrols(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('FileCategory Added sucessfully');", true); BindData(); } else if (btnsubmit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { var id = int.Parse(hdnFCId.Value); var resultToUpdate = container.FileCategories.SingleOrDefault(item => item.FileCategoryId == id); if (resultToUpdate != null) { resultToUpdate.FileCategoryDescription = txtCategoryNamedesc.Value; resultToUpdate.FileCategoryName = txtCategoryName.Value; resultToUpdate.ModifiedBy = 1; resultToUpdate.ModifiedDate = DateTime.Now; } container.SaveChanges(); resetcontrols(); BindData(); } } } catch (Exception exception) { } }
protected void btn_submit_ServerClick(object sender, EventArgs e) { try { if (btn_submit.InnerText == "Submit") { ClientCategory clientCategory = new ClientCategory { Active = true, ClientCategoryDescription = txtclientCategoryNamedesc.Value, ClientCategoryName = txtclientCategoryName.Value, dateadded = DateTime.Now, UserID = 1 }; FileTrackingContainer entities = new FileTrackingContainer(); entities.ClientCategories.Add(clientCategory); entities.SaveChanges(); ResetCotrols(); BindData(); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "toastr.success('ClientCategory Added Sucessfully');", true); } else if (btn_submit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { var id = int.Parse(hdnClientId.Value); var resultToUpdate = container.ClientCategories.SingleOrDefault(item => item.ClientId == id); if (resultToUpdate != null) { resultToUpdate.ClientCategoryDescription = txtclientCategoryNamedesc.Value; resultToUpdate.ClientCategoryName = txtclientCategoryName.Value; resultToUpdate.dateLastModified = DateTime.Now; } container.SaveChanges(); ResetCotrols(); BindData(); } } } catch (Exception ex) { } }
private void BindAgentsData() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.Agents join al in container.AgentAccessLevels on query.AgentAccessLevelId equals al.AgentAccessLevelId join at in container.AgentTypes on query.AgentTypeID equals at.AgentTypeId select new { query.AgentName, query.AgentId, AgentType = at.Description, EmployeeName = query.AgentEmployeeName, AccessLevels = al.AccessLevel, Mobile = query.AgentMobile, Email = query.AgentEmail, ScanPref = query.AgentScanPref, Section = query.AgentSection, query.AgentMisc1, query.AgentMisc2, query.AgentMisc3, query.CreatedDate }).ToList(); if (data.Count > 0) { AgentGrid.DataSource = data; AgentGrid.DataBind(); } else { AgentGrid.DataSource = new List <DAL.Agent>(); AgentGrid.DataBind(); } } } catch (Exception e) { } }
void FillDropdowns() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.FileCategories select new { query.FileCategoryId, query.FileCategoryName }).ToList(); if (data.Count > 0) { foreach (var t in data) { ddlfilecategory.Items.Add(new ListItem { Text = t.FileCategoryName, Value = Convert.ToString(t.FileCategoryId) }); } } var data1 = (from query in container.FilePriorities select new { query.FilePriorityId, query.FilePriorityName, query.FilePriorityIntervalAlert }).ToList(); if (data1.Count > 0) { foreach (var t in data1) { ddlfilepriority.Items.Add(new ListItem { Text = t.FilePriorityName, Value = Convert.ToString(t.FilePriorityId) + "_" + Convert.ToString(t.FilePriorityIntervalAlert) }); } } var data2 = (from query in container.Clients select new { query.ClientId, query.ClientName, }).ToList(); if (data2.Count > 0) { foreach (var t in data2) { ddlclientname.Items.Add(new ListItem { Text = t.ClientName, Value = Convert.ToString(t.ClientId) }); } } } } catch (Exception e) { } }
protected void btnSubmit_OnServerClick(object sender, EventArgs e) { try { if (btnSubmit.InnerText == "Submit") { using (FileTrackingContainer container = new FileTrackingContainer()) { container.FileDatas.Add(new DAL.FileData { FileId = fileCode, FileCategoryId = Convert.ToInt32(ddlfilecategory.Items[ddlfilecategory.SelectedIndex].Value), FileCode = fileCode, FilePriorityId = Convert.ToInt32(ddlfilepriority.Items[ddlfilepriority.SelectedIndex].Value.Split('_')[0]), FileDeliveredOn = null, FileEntredOn = null, FileNoExt = "2", FileNoInt = "2", CreatedBy = 1, CreatedDate = DateTime.Now, AmountApproved = Convert.ToDecimal(txtamountApproved.Value), AmountMisc = Convert.ToDecimal(txtamountmisc.Value), AmountProposed = Convert.ToDecimal(txtamountApproved.Value), ClientId = Convert.ToInt32(ddlclientname.Items[ddlclientname.SelectedIndex].Value), CmoSection = txtcmosection.Value, ContactPersonName = txtcontactpersonname.Value, ContactPersonNumber = Convert.ToInt32(txtcontactpersonnumber.Value), CurrentAgentId = 3, CurrentStatus = "Active", FundSource = "By Hand", FundType = "Cash" } ); container.SaveChanges(); fileCode = ""; MailClass.SendMail("", ""); } } else if (btnSubmit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { //var id = int.Parse(AgentId.Value); //var resultToUpdate = // container.Agents.SingleOrDefault(item => item.AgentId == id); //if (resultToUpdate != null) //{ // resultToUpdate.AgentName = txtname.Value; // resultToUpdate.AgentTypeID = // Convert.ToInt32(ddlagenttype.Items[ddlagenttype.SelectedIndex].Value); // resultToUpdate.AgentEmployeeName = txtAgentEmployeeName.Value; // resultToUpdate.AgentAccessLevelId = // Convert.ToInt32(ddlagentaccess.Items[ddlagentaccess.SelectedIndex].Value); // resultToUpdate.AgentMobile = Convert.ToInt64(txtagentmobile.Value); // resultToUpdate.AgentEmail = txtemail.Value; // resultToUpdate.AgentScanPref = txtagentscanpref.Value; // resultToUpdate.AgentSection = txtagentsec.Value; // resultToUpdate.ModifiedBy = 1; // resultToUpdate.ModifiedDate = DateTime.Now; //} container.SaveChanges(); } } BuildFilesGrid(); } catch (Exception exception) { } }
protected void btn_addagent_Click(object sender, EventArgs e) { try { if (btnSubmit.InnerText == "Submit") { using (FileTrackingContainer container = new FileTrackingContainer()) { container.Agents.Add(new DAL.Agent { AgentName = txtname.Value, AgentTypeID = Convert.ToInt32(ddlagenttype.Items[ddlagenttype.SelectedIndex].Value), AgentEmployeeName = txtAgentEmployeeName.Value, AgentAccessLevelId = Convert.ToInt32(ddlagentaccess.Items[ddlagentaccess.SelectedIndex].Value), AgentMobile = Convert.ToInt64(txtagentmobile.Value), AgentEmail = txtemail.Value, AgentScanPref = txtagentscanpref.Value, AgentSection = txtagentsec.Value, CreatedBy = 1, CreatedDate = DateTime.Now } ); container.SaveChanges(); } } else if (btnSubmit.InnerText == "Update") { using (FileTrackingContainer container = new FileTrackingContainer()) { var id = int.Parse(AgentId.Value); var resultToUpdate = container.Agents.SingleOrDefault(item => item.AgentId == id); if (resultToUpdate != null) { resultToUpdate.AgentName = txtname.Value; resultToUpdate.AgentTypeID = Convert.ToInt32(ddlagenttype.Items[ddlagenttype.SelectedIndex].Value); resultToUpdate.AgentEmployeeName = txtAgentEmployeeName.Value; resultToUpdate.AgentAccessLevelId = Convert.ToInt32(ddlagentaccess.Items[ddlagentaccess.SelectedIndex].Value); resultToUpdate.AgentMobile = Convert.ToInt64(txtagentmobile.Value); resultToUpdate.AgentEmail = txtemail.Value; resultToUpdate.AgentScanPref = txtagentscanpref.Value; resultToUpdate.AgentSection = txtagentsec.Value; resultToUpdate.ModifiedBy = 1; resultToUpdate.ModifiedDate = DateTime.Now; } container.SaveChanges(); } } //clear values txtname.Value = string.Empty; ddlagenttype.SelectedIndex = 0; txtAgentEmployeeName.Value = string.Empty; ddlagentaccess.SelectedIndex = 0; txtagentmobile.Value = string.Empty; txtemail.Value = string.Empty; txtagentscanpref.Value = string.Empty; txtagentsec.Value = string.Empty; BindAgentsData(); } catch (Exception exception) { } }