public void updateExpert(specialization e)//update the parameter of this specialisation { if (e.minWage > e.maxWage) { throw new Exception("the minwage is bigger than the maxwage"); } if (e.specialization_id == 0) { throw new Exception("the specialization doesn't have a id"); } else if (e.minWage == 0) { throw new Exception("the specialization doesn't have a min wage"); } else if (e.maxWage == 0) { throw new Exception("the specialization doesn't have a max age"); } else if (seaurchID_existspecialization(e.specialization_id)) //if the specialization exist { XElement ex = (from p in SPECIALIZATION_ROOT.Elements() //linq to xml where Convert.ToInt32(p.Element("specialization_id").Value) == e.specialization_id select p).FirstOrDefault(); //select the XELEMENT //change the value of this XELEMENT ex.Element("discipline").Value = e.discipline.ToString(); ex.Element("expertise").Value = e.expertise.ToString(); ex.Element("minWage").Value = e.minWage.ToString(); ex.Element("maxWage").Value = e.maxWage.ToString(); SPECIALIZATION_ROOT.Save(specialization_path); } else { throw new Exception("the specialization id :" + e.specialization_id + " doesn't exist"); } }
private void dgv_spec_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i = dgv_spec.CurrentRow.Index; int id = int.Parse(dgv_spec.Rows[i].Cells["ID"].Value.ToString()); spec = DBAccess.get_specialization(id); if (spec != null) { try { txtID.Text = spec.Id.ToString(); txtTitle.Text = spec.Name; cmbSector.Text = spec.Sector; txtsec.Text = spec.Sector; txtTitle.Enabled = true; lblerror1.Visible = false; temp_name = txtTitle.Text.Trim(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Null"); } }
static void Main(string[] args) { BL.IBL bl; bl = BL.FactoryBL.GetBL(); /* specialization S = new specialization(); * S.specialization_id = 333; * S.minWage = 33; * S.maxWage = 55; * bl.addExpert(S); * * specialization t = new specialization(); * t.specialization_id = 336; * t.minWage = 33; * t.maxWage = 55; * bl.addExpert(t); */ // bl.removeExpert(333); specialization P = new specialization(); P.specialization_id = 336; P.minWage = 100; P.maxWage = 55; bl.updateExpert(P); }
public void addExpert(specialization e)//receive a specialization ,convert it in XELEMENT ,add in the files and save the file { if (e.minWage > e.maxWage) { throw new Exception("the minwage is bigger than the maxwage"); } if (e.specialization_id == 0) { throw new Exception("the specialization doesn't have a id"); } else if (e.minWage == 0) { throw new Exception("the specialization doesn't have a min wage"); } else if (e.maxWage == 0) { throw new Exception("the specialization doesn't have a max age"); } else if (seaurchID_existspecialization(e.specialization_id)) { throw new Exception("the specialization id :" + e.specialization_id + " doesn't exist"); } else { SPECIALIZATION_ROOT.Add(ConvertSpecialization(e)); //convert and add to the files SaveFiles(); //save the files } }
public ActionResult DeleteConfirmed(int id) { specialization specialization = db.specializations.Find(id); db.specializations.Remove(specialization); db.SaveChanges(); return(RedirectToAction("Index")); }
public BSTUStudent(string name, int group, specialization specialization, int mark1, int mark2, int mark3, int mark4) { this.name = name; this.group = group; this.specialization = specialization; this.mark1 = mark1; this.mark2 = mark2; this.mark3 = mark3; this.mark4 = mark4; }
public ActionResult Edit([Bind(Include = "Id,name")] specialization specialization) { if (ModelState.IsValid) { db.Entry(specialization).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(specialization)); }
public ActionResult Create([Bind(Include = "Id,name")] specialization specialization) { if (ModelState.IsValid) { db.specializations.Add(specialization); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(specialization)); }
public static int AddSpecialization(string name, bool isL, int complexity) { var entity = new sovadb001Entities0(); specialization spec = new specialization(); spec.name = name; spec.isLanguage = isL; spec.complexity = complexity; entity.specializations.Add(spec); entity.SaveChanges(); return(entity.specializations.First(t => t.name == name).IdSpecialization); }
// GET: /Specializations/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } specialization specialization = db.specializations.Find(id); if (specialization == null) { return(HttpNotFound()); } return(View(specialization)); }
public static void AddTranslator(int[] idSpec, int idUser) { var entity = new sovadb001Entities0(); translator nt = new translator(); nt.countOfComplitedOrders = 0; nt.IdUser = idUser; entity.translators.Add(nt); entity.SaveChanges(); double[] p = new double[idSpec.Length]; int x = 0; foreach (int i in idSpec) { price pr = GetSpecialization(i).prices.First(t => t.IdTranslator == entity.translators.First(q => q.IdUser == idUser).IdTranslator); specialization s = GetSpecialization(i); if (pr != null) { p[x] = (double)(pr.price1 / s.complexity); } else { p[x] = 0; } x++; } double sum = 0; for (int i = 0; i < p.Length; i++) { sum += p[i]; } sum /= p.Length; double sum1 = 0; for (int i = 0; i < p.Length; i++) { if (p[i] != 0) { p[i] -= sum; p[i] = Math.Abs(p[i]); sum1 += p[i]; } } entity.translators.First(q => q.IdUser == idUser).reputation = (int)sum1; entity.SaveChanges(); }
private void btnUpdate_Click(object sender, EventArgs e) { try { if (txtID.Text == string.Empty || txtID.Text == "(Auto Generated)") { MessageBox.Show("Please select user to update!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty.Trim()) { MessageBox.Show("Please input specilization!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (lblerror1.Visible == true) { MessageBox.Show("Specialization Title is in use!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int sector = DBAccess.get_cmb_data(cmbSector.Text, "sp_get_cmb_sector", "sector_id"); spec = new specialization(int.Parse(txtID.Text), sector.ToString(), txtTitle.Text); DBAccess.update_specialization(spec); dgv_spec.DataSource = DBAccess.dataTableLoad("sp_load_specialization"); logs = new auditTrail(frm_login.UserName, "Updated Specialization id " + txtID.Text); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Updated!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } // clear(); }
private void btnSave_Click(object sender, EventArgs e) { try { if (lblerror1.Visible == true) { MessageBox.Show("Sector title is already in use!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty) { MessageBox.Show("Please complete the required data!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int sector = DBAccess.get_cmb_data(cmbSector.Text, "sp_get_cmb_sector", "sector_id"); spec = new specialization(sector.ToString(), txtTitle.Text); DBAccess.insert_specialization(spec); logs = new auditTrail(frm_login.UserName, "Added a Specialization "); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); dgv_spec.DataSource = DBAccess.dataTableLoad("sp_load_specialization"); btnUpdate.Visible = true; btnAdd.Visible = true; btnUpdate.Visible = true; btnSave.Visible = false; btnCancel.Visible = false; dgv_spec.Enabled = true; clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
public void updateExpert(specialization e)// receive an objet specialization and update his parameters { int id = e.specialization_id; if (DS.DataSource.specializationList.Exists(c => c.specialization_id == e.specialization_id)) { int index = DS.DataSource.specializationList.FindIndex(x => x.specialization_id == e.specialization_id); if (index != -1) { DataSource.specializationList[index] = e; } else { throw new KeyNotFoundException(" The Specialization Id doesn't exist : " + id); } } else { throw new KeyNotFoundException("The Specialization Id doesn't exist : " + id); } }
//autre #endregion #region specialization public void addExpert(specialization e) { if (e.specialization_id == 0) { throw new Exception("the specialization doesn't have a id"); } else if (e.minWage == 0) { throw new Exception("the specialization doesn't have a min wage"); } else if (e.maxWage == 0) { throw new Exception("the specialization doesn't have a max age"); } else if (seaurchID_existspecialization(e.specialization_id)) { throw new Exception("the specialization id :" + e.specialization_id + " doesn't exist"); } else { SPECIALIZATION_ROOT.Add(ConvertSpecialization(e)); SaveFiles(); } }
public void updateExpert(specialization e) { if (e.specialization_id == 0) { throw new Exception("the specialization doesn't have a id"); } else if (e.minWage == 0) { throw new Exception("the specialization doesn't have a min wage"); } else if (e.maxWage == 0) { throw new Exception("the specialization doesn't have a max age"); } else if (seaurchID_existspecialization(e.specialization_id)) { removeExpert(e.specialization_id); this.addExpert(e); } else { throw new Exception("the specialization id :" + e.specialization_id + " doesn't exist"); } }
public void addExpert(specialization s) //add specialisation { dal.addExpert(s); //call the dal method to add specialisation }
public void addExpert(specialization e)//add specialization :save in list of specialization in data source { DS.DataSource.specializationList.Add(e); }
public void updateExpert(specialization s) { dal.updateExpert(s); }
public void addExpert(specialization s) { dal.addExpert(s); }
public void addExpert(specialization e) { DS.DataSource.specializationList.Add(e); }
public void updateExpert(specialization s) //update specialisation { dal.updateExpert(s); //call the dal method to update from the xeleement file }