}//edit // GET: Contractors/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Contractors contractordetail = db.Contractors.Find(id); if (contractordetail == null) { return(HttpNotFound()); } ContractorsViewModel view = new ContractorsViewModel(); view.Id_Contractor = contractordetail.Id_Contractor; view.CompanyName = contractordetail.CompanyName; view.ContactPerson = contractordetail.ContactPerson; view.PhoneNumber = contractordetail.PhoneNumber; view.EmailAddress = contractordetail.EmailAddress; view.VatId = contractordetail.VatId; view.HourlyRate = contractordetail.HourlyRate; view.CreatedAt = contractordetail.CreatedAt; view.LastModifiedAt = DateTime.Now; view.DeletedAt = DateTime.Now; view.Active = contractordetail.Active; return(View(view)); }
public ActionResult Create(ContractorsViewModel model) { MobileWorkDataEntities db = new MobileWorkDataEntities(); Contractors con = new Contractors(); con.CompanyName = model.CompanyName; con.ContactPerson = model.ContactPerson; con.PhoneNumber = model.PhoneNumber; con.EmailAddress = model.EmailAddress; con.VatId = model.VatId; con.HourlyRate = model.HourlyRate; con.CreatedAt = DateTime.Now; con.LastModifiedAt = DateTime.Now; con.DeletedAt = model.DeletedAt; con.Active = model.Active; db.Contractors.Add(con); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }//create
private void Initialize() { Contractors = new Contractors(); CategoriesMenu.ItemsDataTable = Contractors.CategoriesDataTable; CategoriesMenu.InitializeItems(); if (Contractors.CategoriesDataTable.Rows.Count > 0) { CategoriesMenu.Selected = 0; } SubCategoriesMenu.ItemsDataTable = Contractors.SubCategoriesDataTable; SubCategoriesMenu.InitializeItems(); ContractorsList.ItemsDataTable = Contractors.ContractorsDataTable; ContractorsList.CitiesDataTable = Contractors.CitiesDataTable; ContractorsList.CountriesDataTable = Contractors.CountriesDataTable; ContractorsList.ContactsDataTable = Contractors.ContactsDataTable; DataTable PermissionsDataTable = RolesAndPermissionsManager.GetPermissions(Security.CurrentUserID, "ContractorsForm"); if (PermissionsDataTable.Rows.Count > 0) { ContractorsList.bCanEdit = true; EditButtonsPanel.Visible = true; } if (Contractors.SubCategoriesDataTable.Rows.Count > 0) { Contractors.FillContractors(SubCategoriesMenu.SelectedContractorSubCategoryID); ContractorsList.InitializeItems(); } }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["view"])) { if (Request.QueryString["view"].Equals("available")) { rptContractor.DataSource = Contractors.GetContractors(String.Empty, true); } else { rptContractor.DataSource = Contractors.GetContractors(String.Empty); } } else { rptContractor.DataSource = Contractors.GetContractors(String.Empty); } rptContractor.DataBind(); if (Functions.CanEdit()) { btnNewContractor.Visible = true; } }
/// <summary> /// Adding Contractor details into Contractors Table /// </summary> /// <param name="usertables"></param> public void AddUser(ContractorRegistrationViewModel usertables) { try { // AspNetUserRoles asp = new AspNetUserRoles { }; UserTables njp = new UserTables { IsActive = true, CreatedBy = usertables.ContractorName }; usertableRepository.Add(njp); unitOfWork.Commit(); Contractors cts = new Contractors { UserTableId = usertables.UserTableId, StateId = usertables.StateId, CityId = usertables.CityId, ContractorName = usertables.ContractorName, ContractorAge = usertables.ContractorAge, ContractorPhone = usertables.ContractorPhone, IsActive = true, CreatedBy = usertables.CreatedBy }; contractorRepository.Add(cts); unitOfWork.Commit(); } catch (Exception) { throw; } }
public virtual ObservableCollection <Contractor> GetAllContractors() { Contractors allContractors = new Contractors(); Contractors = new ObservableCollection <Contractor>(allContractors); return(Contractors); }
private async Task loadBuildingUsers() { try { var bUsers = await _buildingService.GetBuildingUsers(BuildingId, false); List <BuildingUser> users = (List <BuildingUser>)bUsers; if (users != null && users.Count > 0) { for (var i = 0; i < users.Count; i++) { if (users[i].UserPrivileges.Contains("CN")) { Contractors.Add(users[i]); } if (users[i].UserPrivileges.Contains("ES")) { Supervisors.Add(users[i]); } } } } catch (Exception e) { //Dialogs.ShowError(e?.Message); } }
public WorkModel GetContractorModel(string contractorName) { panconDatabaseEntities entities = new panconDatabaseEntities(); try { string chosenContractor = contractorName; Contractors contractor = (from co in entities.Contractors where (co.Active == true) && (co.CompanyName == chosenContractor) select co).FirstOrDefault(); WorkModel chosenContractorModel = new WorkModel() { ContractorId = contractor.ContractorId, ContractorName = contractor.CompanyName, ContractorContactPerson = contractor.ContactPerson, ContractorPhone = contractor.Phone, ContractorEmail = contractor.Email, VatId = contractor.VatId, HourlyRate = contractor.HourlyRate.ToString(), }; return(chosenContractorModel); } finally { entities.Dispose(); } }
public ActionResult DeleteConfirmed(int id) { Contractors contractors = db.Contractors.Find(id); db.Contractors.Remove(contractors); db.SaveChanges(); return(RedirectToAction("Index")); }
public void CancelMethod() { Contractors allContractors = new Contractors(); Contractors = new ObservableCollection <Contractor>(allContractors); logger.Info("Contractor's Cancel is pressed"); }
public void Transfer(Contractors contractor, decimal amount) { var wallet = contractor.Wallets.FirstOrDefault(); if (wallet != null) { wallet.Balance += amount; } }
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { Contractors contractors = new Contractors(); //The collection that holds the data. List <Customer> customers = contractors.GetAllCustomers(); //Set the maximum amount of items the Grid will display. RadGrid1.VirtualItemCount = customers.Count; //Set the datasource to the Grid instance. RadGrid1.DataSource = customers.Skip(RadGrid1.PageSize * RadGrid1.CurrentPageIndex).Take(RadGrid1.PageSize); }
private void SetContractorsCheckedText(object param) { try { List <string> checkedContractors = new List <string>(); Contractors.Where(s => s.IsChecked).Distinct().ToList().ForEach(s => checkedContractors.Add(s.Name)); ContractorsText = string.Join(", ", checkedContractors); } catch (Exception ex) { MessageBox.Show("Error", ex.Message, MessageBoxButton.OK, MessageBoxImage.Error); } }
protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridDataItem item = (GridDataItem)e.Item; //Get the primary key value using the DataKeyValue. string customerID = item.OwnerTableView.DataKeyValues[item.ItemIndex][RadGrid1.MasterTableView.DataKeyNames[0]].ToString(); Contractors contractors = new Contractors(); //Query the model for the element that should be deleted. Customer customerToDelete = (from customer in contractors.GetAllCustomers() where customer.CustomerID == customerID select customer).FirstOrDefault(); //Delete the element. contractors.DeleteCustomer(customerToDelete); }
public ActionResult Edit(PinCodesViewModel model) { PinCodes pin = new PinCodes(); pin.Id_PinCode = model.Id_PinCode; pin.PinCode = model.PinCode; pin.CreatedAt = model.CreatedAt; pin.LastModifiedAt = DateTime.Now; pin.DeletedAt = model.DeletedAt; pin.Active = model.Active; int customerId = model.Id_Customer ?? 0; if (customerId > 0) { Customers cus = db.Customers.Find(customerId); pin.Id_Customer = customerId; pin.Id_Customer = cus.Id_Customer; } ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", pin.Id_Customer); int contractorId = model.Id_Contractor ?? 0; if (contractorId > 0) { Contractors con = db.Contractors.Find(contractorId); pin.Id_Contractor = customerId; pin.Id_Contractor = con.Id_Contractor; } ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", pin.Id_Contractor); int employeeId = model.Id_Employee ?? 0; if (employeeId > 0) { Employees emp = db.Employees.Find(employeeId); pin.Id_Employee = employeeId; pin.Id_Employee = emp.Id_Employee; } ViewBag.FirstName = new SelectList((from c in db.Employees select new { Id_Employee = c.Id_Employee, FirstName = c.FirstName }), "Id_Employee", "FirstName", pin.Id_Employee); ViewBag.LastName = new SelectList((from c in db.Employees select new { Id_Employee = c.Id_Employee, LastName = c.LastName }), "Id_Employee", "LastName", pin.Id_Employee); db.SaveChanges(); return(RedirectToAction("Index")); }//edit
public ActionResult Create(EmployeesViewModel model) { MobileWorkDataEntities entities = new MobileWorkDataEntities(); Employees emp = new Employees(); emp.Id_Employee = model.Id_Employee; emp.FirstName = model.FirstName; emp.LastName = model.LastName; emp.PhoneNumber = model.PhoneNumber; emp.EmailAddress = model.EmailAddress; emp.EmployeeReference = model.EmployeeReference; emp.DeletedAt = model.DeletedAt; emp.Active = model.Active; emp.EmployeePicture = model.EmployeePicture; db.Employees.Add(emp); int contractorId = int.Parse(model.CompanyName); if (contractorId > 0) { Contractors con = db.Contractors.Find(contractorId); emp.Id_Contractor = con.Id_Contractor; } int departmentId = int.Parse(model.DepartmentName); if (departmentId > 0) { Departments dep = db.Departments.Find(departmentId); emp.Id_Department = dep.Id_Department; } try { db.SaveChanges(); } catch (Exception ex) { } ViewBag.DepartmentName = new SelectList((from d in db.Departments select new { Id_Department = d.Id_Department, DepartmentName = d.DepartmentName }), "Id_Department", "DepartmentName", null); ViewBag.CompanyName = new SelectList((from c in db.Contractors select new { Id_Contractor = c.Id_Contractor, CustomerName = c.CompanyName }), "Id_Contractor", "CompanyName", null); return(RedirectToAction("Index")); }//create
public Shipment ReserveShipment(Guid id) { var shipment = Shipments.Include(s => s.Driver).Where(s => s.ShipmentID == id).First(); //Check to make sure it is not already reserved if (shipment.Driver != null) { throw new InvalidOperationException("This shipment is already reserved"); } var driver = Contractors.First(d => d.ContractorID == WebApiApplication.CurrentUser); shipment.Driver = driver; SaveChanges(); return(shipment); }
protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridEditFormItem item = (GridEditFormItem)e.Item; Contractors contractors = new Contractors(); //Create the empty element that should be inserted. Customer customerToAdd = new Customer(); int customerID; int.TryParse(contractors.GetAllCustomers().Last().CustomerID, out customerID); //Increment the PK field. customerToAdd.CustomerID = (++customerID).ToString(); //Apply the vlaues from the editor controls. item.UpdateValues(customerToAdd); //Add the element. contractors.AddCustomer(customerToAdd); }
protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridEditFormItem item = (GridEditFormItem)e.Item; //The collection that should be traversed. Contractors contractors = new Contractors(); List <Customer> customers = contractors.GetAllCustomers(); //Get the PK of the element that should be updated. string customerID = item.OwnerTableView.DataKeyValues[item.ItemIndex][RadGrid1.MasterTableView.DataKeyNames[0]].ToString(); //Query the model for the element that should be updated. Customer customerToUpdate = (from customer in customers where customer.CustomerID == customerID.ToString() select customer).FirstOrDefault(); item.UpdateValues(customerToUpdate); contractors.UpdateCustomer(customerToUpdate); }
private Contractors GetModelFromJson() { var resolveRequest = HttpContext.Request; Contractors model = new Contractors(); resolveRequest.InputStream.Seek(0, SeekOrigin.Begin); string jsonString = new StreamReader(resolveRequest.InputStream).ReadToEnd(); if (jsonString != null) { JavaScriptSerializer serializer = new JavaScriptSerializer(); model = (Contractors)serializer.Deserialize(jsonString, typeof(Contractors)); } return(model); }
public Contractors ToDTO() { var sourceProperties = this.GetType().GetProperties(); var destinationProperties = typeof(Contractors).GetProperties(); var result = new Contractors(); foreach (var src in sourceProperties) { if (destinationProperties.Contains(src, PropertyInfoComparer.OrdinalName)) { destinationProperties.Single(x => x.Name.Equals(src.Name)).SetValue(result, src.GetValue(this)); } } return(result); }
protected void imgDelete_Click(object sender, EventArgs e) { ImageButton btn = sender as ImageButton; int ID = Convert.ToInt32(btn.Attributes["PhoneID"]); QCTLinqDataContext db = new QCTLinqDataContext(); ContractorsPhone p = (from c in db.ContractorsPhones where c.ID == ID select c).SingleOrDefault(); if (p != null) { db.ContractorsPhones.DeleteOnSubmit(p); db.SubmitChanges(); rptPhones.DataSource = Contractors.GetPhoneNumbers(int.Parse(Request.QueryString["ID"])); rptPhones.DataBind(); } }
protected void lnkRemoveJob_Click(object sender, EventArgs e) { LinkButton btn = sender as LinkButton; int ID = Convert.ToInt32(btn.Attributes["ItemID"]); QCTLinqDataContext db = new QCTLinqDataContext(); Tag tag = (from t in db.Tags where t.ID == ID select t).Single(); db.Tags.DeleteOnSubmit(tag); db.SubmitChanges(); int cID = Int32.Parse(Request.QueryString["ID"]); rptJobs.DataSource = Contractors.GetJobs(cID); rptJobs.DataBind(); }
public ActionResult Edit(ContractorsViewModel model) { Contractors con = new Contractors(); con.CompanyName = model.CompanyName; con.ContactPerson = model.ContactPerson; con.PhoneNumber = model.PhoneNumber; con.EmailAddress = model.EmailAddress; con.VatId = model.VatId; con.HourlyRate = model.HourlyRate; con.CreatedAt = model.CreatedAt; con.LastModifiedAt = DateTime.Now; con.DeletedAt = model.DeletedAt; con.Active = model.Active; db.SaveChanges(); return(View("Index")); }//edit
public ActionResult Edit(EmployeesViewModel model) { Employees emp = new Employees(); emp.FirstName = model.FirstName; emp.LastName = model.LastName; emp.PhoneNumber = model.PhoneNumber; emp.EmailAddress = model.EmailAddress; emp.EmployeeReference = model.EmployeeReference; emp.DeletedAt = model.DeletedAt; emp.Active = model.Active; emp.EmployeePicture = model.EmployeePicture; int contractorId = int.Parse(model.CompanyName); if (contractorId > 0) { Contractors con = db.Contractors.Find(contractorId); emp.Id_Contractor = con.Id_Contractor; } int departmentId = int.Parse(model.DepartmentName); if (departmentId > 0) { Departments dep = db.Departments.Find(departmentId); emp.Id_Department = dep.Id_Department; } ViewBag.DepartmentName = new SelectList((from d in db.Departments select new { Id_Department = d.Id_Department, DepartmentName = d.DepartmentName }), "Id_Department", "DepartmentName", null); ViewBag.CompanyName = new SelectList((from c in db.Contractors select new { Id_Contractor = c.Id_Contractor, CompanyName = c.CompanyName }), "Id_Contractor", "CompanyName", null); try { db.SaveChanges(); } catch (Exception ex) { } return(View("Index")); }//edit
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != "") { int ID; if (int.TryParse(Request.QueryString["ID"], out ID)) { InsurancePolicy ins = Insurance.GetPolicy(ID); lblCertReq.Text = ins.CertReqFor; lblTypeOfPolicy.Text = ins.TypeOfPolicy1.Type; lblTenantsLegalLiability.Text = ins.TenantsLegalLiability.ToYesNoString(); lblPerOccurance.Text = ins.PerOccurance.ToYesNoString(); lblProductsCompletedOps.Text = ins.ProductsCompletedOps.ToYesNoString(); lblNonOwnedAuto.Text = ins.NonOwnedAuto.HasValue ? ins.InsuranceNonOwnedAuto.Value : String.Empty; lblCrossLiability.Text = ins.CrossLiability.ToYesNoString(); lblNorCountAddIns.Text = ins.NCasAddIns.ToYesNoString(); lblPolicyNumber.Text = ins.PolicyNumber; lblPolicyLimit.Text = ins.PolicyLimit1.Value.Equals("Other") ? ins.PolicyLimitOther : ins.PolicyLimit1.Value; lblExpiryDate.Text = ins.ExpiryDate.DisplayDate(); lblInsComp.Text = ins.insID.HasValue ? ins.InsuranceCompany1.Name : String.Empty; lblInsEmail.Text = ins.insID.HasValue ? "<a href='mailto:" + ins.InsuranceCompany1.Email + "'>" + ins.InsuranceCompany1.Email + "</a>" : String.Empty; lblBroker.Text = ins.BrokerID.HasValue ? ins.InsuranceBroker.Name : String.Empty; lblBrokerEmail.Text = ins.BrokerEmailID.HasValue ? "<a href='mailto:" + ins.InsuranceBrokerEmail.Email + "'>" + ins.InsuranceBrokerEmail.Email + "</a>" : String.Empty; lblCertSigned.Text = ins.CertSigned.ToYesNoString(); // build the paths for the file and the link to it. String filelnk = "uploads/" + ID.ToString() + "/attachment.pdf"; String directory = Server.MapPath("uploads"); String filepath = directory + "/" + ID.ToString() + "/attachment.pdf"; if (File.Exists(filepath)) // only show it if there is an attached file. { lnkFiles.NavigateUrl = filelnk; lnkFiles.Text = "View attachment"; } ltContractorName.Text = Contractors.GetContractorName(ins.cID); } else { Response.Redirect("~/Default.aspx"); } } }
public ActionResult Delete(int id) { try { Contractors Contractor = new Contractors() { keyId = id }; using (var context = new DbEntities()) { context.Contractors.Attach(Contractor); context.Contractors.Remove(Contractor); context.SaveChanges(); } return(GenerateJsonResponse("Удаление произведено успешно!")); } catch (Exception ex) { return(GenerateJsonResponse("error : + " + ex)); } }
protected void btnSavePhone_Click(object sender, EventArgs e) { int cID = Int32.Parse(Request.QueryString["ID"]); QCTLinqDataContext db = new QCTLinqDataContext(); ContractorsPhone phone = new ContractorsPhone { cID = cID, PhoneType = int.Parse(ddPhoneType.SelectedValue), PhoneNumber = txtPhoneNumber.Text }; db.ContractorsPhones.InsertOnSubmit(phone); db.SubmitChanges(); rptPhones.DataSource = Contractors.GetPhoneNumbers(cID); rptPhones.DataBind(); ddPhoneType.SelectedIndex = 0; ddPhoneType.Visible = false; txtPhoneNumber.Text = String.Empty; txtPhoneNumber.Visible = false; btnSavePhone.Visible = false; btnAddPhone.Visible = true; }
protected void btnSaveJobs_Click(object sender, EventArgs e) { int cID = Int32.Parse(Request.QueryString["ID"]); QCTLinqDataContext db = new QCTLinqDataContext(); lookupTag job = (from j in db.lookupTags where j.Job == txtJobs.Text select j).SingleOrDefault(); int jID; if (job == null) { lookupTag newJob = new lookupTag { Job = txtJobs.Text }; db.lookupTags.InsertOnSubmit(newJob); db.SubmitChanges(); jID = newJob.ID; } else { jID = job.ID; } Tag tag = new Tag { cID = cID, tID = jID }; db.Tags.InsertOnSubmit(tag); db.SubmitChanges(); rptJobs.DataSource = Contractors.GetJobs(cID); rptJobs.DataBind(); txtJobs.Text = String.Empty; }
private void AddLabourCmd(object model) { ErrorMessage = ""; var labour = model as Labour; if (labour.Payment < 1 || labour.PaymentDate == default(DateTime) || SelectedContractor.ContractorId == 0 || labour.WorkType.WorkTypeId == 0) { ErrorMessage = "*Please check the entry. Some field's Values are missing."; return; } labour.SiteId = SiteId; labour.CreateDate = DateTime.Now; labour.Contractor = Contractors.Single(x => x.ContractorId == SelectedContractor.ContractorId); _repositoryManager.AddLabourPayment(labour); LabourToAdd = new Labour(); LabourToAdd.Contractor = Contractors.First(); LabourToAdd.WorkType = WorkTypes.First(); SelectedContractor = ContractorList.First(); Labours = new ObservableCollection <Labour>(_repositoryManager.GetLabourPayments(SiteId)); OnPropertyChanged(nameof(LabourToAdd)); OnPropertyChanged(nameof(SelectedContractor)); }