Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
        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");
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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"));
        }
Ejemplo n.º 6
0
 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));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        // 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));
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        //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();
            }
        }
Ejemplo n.º 16
0
 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");
     }
 }
Ejemplo n.º 17
0
 public void addExpert(specialization s) //add specialisation
 {
     dal.addExpert(s);                   //call the dal method to add specialisation
 }
Ejemplo n.º 18
0
 public void addExpert(specialization e)//add specialization :save in list of specialization in data source
 {
     DS.DataSource.specializationList.Add(e);
 }
Ejemplo n.º 19
0
 public void updateExpert(specialization s)
 {
     dal.updateExpert(s);
 }
Ejemplo n.º 20
0
 public void addExpert(specialization s)
 {
     dal.addExpert(s);
 }
Ejemplo n.º 21
0
 public void addExpert(specialization e)
 {
     DS.DataSource.specializationList.Add(e);
 }
Ejemplo n.º 22
0
 public void updateExpert(specialization s) //update specialisation
 {
     dal.updateExpert(s);                   //call the dal method to update from the xeleement file
 }