private void FullViewForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { List <int> skillIdList = new List <int>(); var query = (from table in myJob.Employees where table.EmployeeId == id select table).SingleOrDefault(); lblFullName.Text += string.Format("{0} {1}", query.FirstName, query.LastName); lblAlias.Text += query.Alias; lblEmail.Text += query.Email; foreach (var skill in query.Skills) { cbSkills.Items.Add(skill.SkillName); skillIdList.Add(skill.SkillId); } cbSkills.Tag = skillIdList.ToArray(); foreach (var reference in query.Reference) { cbReferences.Items.Add(reference.FirstName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void cbSkills_SelectedIndexChanged(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { rtbSkillInfo.Text = ""; int[] arrayForData = (int[])cbSkills.Tag; int selectedIndex = arrayForData[cbSkills.SelectedIndex]; var query = from table in myJob.SkillsInfo where table.SkillId == selectedIndex select table; foreach (var item in query) { rtbSkillInfo.Text += string.Format("{0}\n", item.URL); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void FullViewSkillsForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Skills where table.SkillId == id select table).SingleOrDefault(); lblSkillName.Text += query.SkillName; rtbDescription.Text += query.BriefDescription; lblSkillOf.Text += string.Format("{0} {1}", query.Employees.FirstName, query.Employees.LastName); foreach (var urls in query.SkillsInfo) { cbUrl.Items.Add(urls.URL); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (ValidateOfNull()) { using (MyJobEntities myJob = new MyJobEntities()) { try { int[] idArray = (int[])cbRecommand.Tag; var query = (from table in myJob.Reference where table.ReferenceId == id select table).SingleOrDefault(); if (DetectAddOrUpdate(id)) { query.FirstName = txtFistName.Text; query.LastName = txtLastName.Text; query.Alias = txtAlias.Text; query.Position = txtPosition.Text; query.Email = txtEmail.Text; query.EmployeeId = idArray[cbRecommand.SelectedIndex]; myJob.SaveChanges(); MessageBox.Show("updated Successfuly"); } else { myJob.Reference.Add(new Reference { FirstName = txtFistName.Text, LastName = txtLastName.Text, Alias = txtAlias.Text, Position = txtPosition.Text, Email = txtEmail.Text, EmployeeId = idArray[cbRecommand.SelectedIndex] }); myJob.SaveChanges(); MessageBox.Show("added Successfuly"); } ucReferenceTable.RefreshTable(1); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("please fill all fileds"); } }
private void AddOrEditReferenceForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { List <int> employeeId = new List <int>(); var query = (from table in myJob.Employees select new { table.EmployeeId, table.FirstName, table.LastName }).ToList(); foreach (var employee in query) { cbRecommand.Items.Add(string.Format("{0} {1} ", employee.FirstName, employee.LastName)); employeeId.Add(employee.EmployeeId); } cbRecommand.Tag = employeeId.ToArray(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (DetectAddOrUpdate(this.id)) //true = update, false = add { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Reference where table.ReferenceId == id select table).SingleOrDefault(); txtFistName.Text = query.FirstName; txtLastName.Text = query.LastName; txtAlias.Text = query.Alias; txtPosition.Text = query.Position; txtEmail.Text = query.Email; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (ValidateOfNull()) { using (MyJobEntities myJob = new MyJobEntities()) { try { int[] idArray = (int[])cbSkillOf.Tag; var query = (from table in myJob.Skills where table.SkillId == id select table).SingleOrDefault(); if (DetectAddOrUpdate(id)) { query.SkillName = txtSkillName.Text; query.BriefDescription = rtbDescription.Text; query.EmployeeId = idArray[cbSkillOf.SelectedIndex]; myJob.SaveChanges(); MessageBox.Show("updated Successfuly"); } else { myJob.Skills.Add(new Skills { SkillName = txtSkillName.Text, BriefDescription = rtbDescription.Text, EmployeeId = idArray[cbSkillOf.SelectedIndex] }); myJob.SaveChanges(); MessageBox.Show("added Successfuly"); } ucSkillsTable.RefreshTable(1); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("please fill all fileds"); } }
private void RefreshTableSearch(int page) { using (MyJobEntities myJob = new MyJobEntities()) { try { //insert user controls to array(for looping the by for loop) ucSkills[] skillsArray = new ucSkills[] { instance.ucSkills1, instance.ucSkills2, instance.ucSkills3, instance.ucSkills4 }; int startPosition = page * skillsArray.Length - skillsArray.Length; // find the starting position of employee int endPosition; int skillsArrayindex = 0; // index for skills array for (int i = 0; i < skillsArray.Length; i++)//make all user control unvisibled { skillsArray[i].Visible = false; } //linq query of all the employees var query = (from table in myJob.Skills where table.SkillName == txtSearch.Text select table).ToArray(); //find the end position acourding to employee array if (startPosition + skillsArray.Length > query.Length) { endPosition = query.Length; } else { endPosition = startPosition + skillsArray.Length; } //insert data to usercontrols for (int i = startPosition; i < endPosition; i++) { skillsArray[skillsArrayindex].InsertParmeters(query[i].SkillId, query[i].SkillName, string.Format("{0} {1}", query[i].Employees.FirstName, query[i].Employees.LastName), query[i].BriefDescription); skillsArrayindex++; } // fix the view page bar instance.ChangePage(query.Length, page, skillsArray.Length); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void RefreshTableSearch(int page) { using (MyJobEntities myJob = new MyJobEntities()) { try { //insert user controls to array(for looping the by for loop) ucSkillInfo[] skillInfoArray = new ucSkillInfo[] { instance.ucSkillInfo1, instance.ucSkillInfo2, instance.ucSkillInfo3, instance.ucSkillInfo4, }; int startPosition = page * skillInfoArray.Length - skillInfoArray.Length; // find the starting position of employee int endPosition; int EmployeeArrayindex = 0; // index for employee array only for (int i = 0; i < skillInfoArray.Length; i++)//make all user control unvisibled { skillInfoArray[i].Visible = false; } //linq query of all the employees var query = (from table in myJob.SkillsInfo where table.URL == txtSearch.Text select table).ToArray(); //find the end position acourding to employee array if (startPosition + skillInfoArray.Length > query.Length) { endPosition = query.Length; } else { endPosition = startPosition + skillInfoArray.Length; } //insert data to usercontrols for (int i = startPosition; i < endPosition; i++) { skillInfoArray[EmployeeArrayindex].InsertParmeters(query[i].SkillInfoId, query[i].URL, query[i].Skills.SkillName); EmployeeArrayindex++; } // fix the view page bar instance.ChangePage(query.Length, page, skillInfoArray.Length); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void RefreshTableSearch(int page) { using (MyJobEntities myJob = new MyJobEntities()) { try { //insert user controls to array(for looping the by for loop) ucEmployee[] employeeArray = new ucEmployee[] { instance.ucEmployeeOne, instance.ucEmployeeTwo, instance.ucEmployeeThree, instance.ucEmployeeFour }; int startPosition = page * employeeArray.Length - employeeArray.Length; // find the starting position of employee int endPosition; int employeeArrayindex = 0; // index for employee array only for (int i = 0; i < employeeArray.Length; i++)//make all user control unvisibled { employeeArray[i].Visible = false; } //linq query to search employee by first name var query = (from table in myJob.Employees where table.FirstName == txtSearch.Text select new { table.EmployeeId, table.FirstName, table.LastName, table.Alias, table.Email }).ToArray(); //find the end position acourding to employee array if (startPosition + employeeArray.Length > query.Length) { endPosition = query.Length; } else { endPosition = startPosition + employeeArray.Length; } //insert data to usercontrols for (int i = startPosition; i < endPosition; i++) { employeeArray[employeeArrayindex].InsertParmeters(query[i].EmployeeId, query[i].FirstName, query[i].LastName, query[i].Alias, query[i].Email); employeeArrayindex++; } // fix the view page bar instance.ChangePage(query.Length, page, employeeArray.Length); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (ValidateOfNull()) { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Employees where table.EmployeeId == id select table).SingleOrDefault(); if (DetectAddOrUpdate(id)) { query.FirstName = txtFistName.Text; query.LastName = txtLastName.Text; query.Alias = txtAlias.Text; query.Email = txtEmail.Text; myJob.SaveChanges(); MessageBox.Show("updated Successfuly"); } else { myJob.Employees.Add(new Employees { FirstName = txtFistName.Text, LastName = txtLastName.Text, Alias = txtAlias.Text, Email = txtEmail.Text }); myJob.SaveChanges(); MessageBox.Show("added Successfuly"); } ucEmployeesTable.RefreshTable(1); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("please fill all fields"); } }
public static void RefreshTable(int page) { using (MyJobEntities myJob = new MyJobEntities()) { try { //insert user controls to array(for looping the by for loop) ucReferance[] referenceArray = new ucReferance[] { instance.ucReferance1, instance.ucReferance2, instance.ucReferance3, instance.ucReferance4 }; int startPosition = page * referenceArray.Length - referenceArray.Length; // find the starting position of employee int endPosition; int EmployeeArrayindex = 0; // index for employee array only instance.txtSearch.Text = ""; for (int i = 0; i < referenceArray.Length; i++)//make all user control unvisibled { referenceArray[i].Visible = false; } //linq query of all the employees var query = (from table in myJob.Reference select new { table.ReferenceId, table.FirstName, table.LastName, table.Alias, table.Email }).ToArray(); //find the end position acourding to employee array if (startPosition + referenceArray.Length > query.Length) { endPosition = query.Length; } else { endPosition = startPosition + referenceArray.Length; } //insert data to usercontrols for (int i = startPosition; i < endPosition; i++) { referenceArray[EmployeeArrayindex].InsertParmeters(query[i].ReferenceId, query[i].FirstName, query[i].LastName, query[i].Alias, query[i].Email); EmployeeArrayindex++; } // fix the view page bar instance.ChangePage(query.Length, page, referenceArray.Length); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void AddOrEditSkillForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { List <int> employeeId = new List <int>(); var query = (from table in myJob.Employees select new { table.EmployeeId, table.FirstName, table.LastName }).ToList(); foreach (var employee in query) { cbSkillOf.Items.Add(string.Format("{0} {1} ", employee.FirstName, employee.LastName)); employeeId.Add(employee.EmployeeId); } cbSkillOf.Tag = employeeId.ToArray(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (DetectAddOrUpdate(this.id)) //true = update, false = add { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Skills where table.SkillId == id select table).SingleOrDefault(); txtSkillName.Text = query.SkillName; rtbDescription.Text = query.BriefDescription; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void AddOrEditSkillInfoForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { List <int> skillsId = new List <int>(); var query = (from table in myJob.Skills select table).ToList(); foreach (var skill in query) { cbSkillInfoOf.Items.Add(skill.SkillName); skillsId.Add(skill.SkillId); } cbSkillInfoOf.Tag = skillsId.ToArray(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (DetectAddOrUpdate(this.id)) //true = update, false = add { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.SkillsInfo where table.SkillInfoId == id select table).SingleOrDefault(); txtUrl.Text = query.URL; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void FullViewReferenceForm_Load(object sender, EventArgs e) { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Reference where table.ReferenceId == id select table).SingleOrDefault(); lblFullName.Text += string.Format("{0} {1}", query.FirstName, query.LastName); lblAlias.Text += query.Alias; lblEmail.Text += query.Email; lblPosition.Text += query.Position; lblRecommand.Text += string.Format("{0} {1}", query.Employees.FirstName, query.Employees.LastName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void DeleteById(int id) { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Reference where table.ReferenceId == id select table).SingleOrDefault(); myJob.Reference.Remove(query); myJob.SaveChanges(); MessageBox.Show("Deleting is done"); ucReferenceTable.RefreshTable(1); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void EditUserForm_Load(object sender, EventArgs e) { if (DetectAddOrUpdate(this.id)) //true = update, false = add { using (MyJobEntities myJob = new MyJobEntities()) { try { var query = (from table in myJob.Employees where table.EmployeeId == id select table).SingleOrDefault(); txtFistName.Text = query.FirstName; txtLastName.Text = query.LastName; txtAlias.Text = query.Alias; txtEmail.Text = query.Email; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }