protected void SaveButton_Click(object sender, EventArgs e) { //Local variables int id = -1; string name, desc, days, hours; List<JobTypeControlCookie> data; //Validate data //If there's an id, pull it from the hidden field on the form if (JobTypeID.Value != "") id = int.Parse(JobTypeID.Value); name = JobTypeNameTextBox.Text.Trim(); //Construct the estimatetimetocomplete string if (EstDaysTextbox.Text.Trim().Length == 1) days = "0" + EstDaysTextbox.Text.Trim(); else days = EstDaysTextbox.Text.Trim(); if (EstHoursTextbox.Text.Trim().Length == 1) hours = "0" + EstHoursTextbox.Text.Trim(); else hours = EstHoursTextbox.Text.Trim(); desc = DescriptionTextBox.Text.Trim(); //Create the job type object JobType jt = new JobType(); jt.JobTypeID = id; jt.Name = name; if (days == "") days = "00"; if (hours == "") hours = "00"; jt.EstimatedTimeToComplete = days + "d" + hours + "h"; jt.JobTypeDescription = desc; try { //Populate the controls list data = JobTypeControlCart.RetrieveCart(); List<JobControl> controls = JobTypeUtils.ConvertFromCartClass(data); //If ID = -1, then it's a new object if (id == -1) { //Commit this data to the database Brentwood.ProcessJobType(jt, controls); FormMessage.Text = "Job type successfully created!"; FormMessage.ForeColor = Color.Black; } else { //Update current job type //Commit this data to the database Brentwood.ProcessJobTypeUpdate(jt, controls); FormMessage.Text = "Job type successfully updated!"; FormMessage.ForeColor = Color.Black; } JobTypeControlCart.DestroyCart(); } catch (Exception ex) { FormMessage.ForeColor = Color.Red; FormMessage.Text = ex.Message + " " + ex.InnerException.Message; } }
/// <summary> /// Deprecated Method for adding a new object to the JobTypes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToJobTypes(JobType jobType) { base.AddObject("JobTypes", jobType); }
/// <summary> /// Create a new JobType object. /// </summary> /// <param name="jobTypeID">Initial value of the JobTypeID property.</param> /// <param name="name">Initial value of the Name property.</param> public static JobType CreateJobType(global::System.Int32 jobTypeID, global::System.String name) { JobType jobType = new JobType(); jobType.JobTypeID = jobTypeID; jobType.Name = name; return jobType; }
public static void ProcessJobTypeUpdate(JobType item, List<JobControl> controls) { UpdateJobType(item); JobControlsAuthority.ProcessJobControlsListUpdate(item.JobTypeID, controls); }
public static void ProcessJobType(JobType item, List<JobControl> controls) { int jtid = AddJobType(item); JobControlsAuthority.ProcessJobControlsList(jtid, controls); }
public static int ArchiveJobType(JobType Item) { return (new Entities()).JobType_Archive(Item.JobTypeID); }
public static int AddJobType(JobType Item) { int? rval = (new Entities()).JobType_Insert(Item.Name, Item.EstimatedTimeToComplete, Item.JobTypeDescription).FirstOrDefault<int?>(); return rval ?? default(int); }
public static int UpdateJobType(JobType Item) { int? rval = (new Entities()).JobType_Update(Item.Name, Item.EstimatedTimeToComplete, Item.JobTypeDescription, Item.JobTypeID).FirstOrDefault(); return rval ?? default(int); }