Ejemplo n.º 1
0
 public ActionResult AddVakansiya(int id = 0)
 {
     var SpecsList = (from Gr in ugtu_db.Grup
                      join RSF in ugtu_db.Relation_spec_fac on Gr.ik_spec_fac equals RSF.ik_spec_fac
                      join FE in ugtu_db.Form_ed on RSF.Ik_form_ed equals FE.Ik_form_ed
                      join S in ugtu_db.Spec_stud on RSF.ik_spec equals S.ik_spec
                      join F in ugtu_db.Fac on RSF.ik_fac equals F.Ik_fac
                      join StGr in ugtu_db.StudGrup on Gr.Ik_grup equals StGr.Ik_grup
                      where FE.Ik_form_ed == ConstRep.FormEd && (S.ik_direction == ConstRep.Direction_bak
                      || S.ik_direction == ConstRep.Direction_spec
                      || S.ik_direction == ConstRep.Direction_magistr
                      || S.ik_direction == ConstRep.Direction_spo)
                      && S.Sh_spec != null && S.Cshort_spec != null && S.FullName != null
                      select new
                      {
                          idSpec = S.ik_spec,
                          NameSpec = S.Cshort_spec,
                          BigNameSpec = S.Cname_spec,
                          kodSpec = S.Sh_spec
                      }).Distinct().OrderBy(m => m.NameSpec).ToList();
     VakansiyaModel VM = new VakansiyaModel();
     VM.specs = new List<VakansiyaSpecs>();
     foreach (var sp in SpecsList)
     {
         VM.specs.Add(new VakansiyaSpecs(sp.BigNameSpec, false, sp.NameSpec, sp.kodSpec, sp.idSpec));
     }
     if (id == 0) ViewBag.Predpr = new SelectList(ugtu_db.Predpriyatie.OrderBy(n => n.Name), "IDPredpriyatie", "Name");
     else ViewBag.Predpr = new SelectList(ugtu_db.Predpriyatie.Where(s => s.IDPredpriyatie == id).OrderBy(n => n.Name), "IDPredpriyatie", "Name");
     ViewBag.Dolzhnost = new SelectList(ugtu_db.Dolznost.OrderBy(n => n.NameDolznost), "IDDolznost", "NameDolznost");
     ViewBag.Status = new SelectList(ugtu_db.Status.OrderBy(n => n.StatusName), "IDStatus", "StatusName");
     ViewBag.TipZan = new SelectList(ugtu_db.ZnachParam.Where(param => param.idParam == idParamTipZan).OrderBy(n => n.ZnachParamName), "idZnachParam", "ZnachParamName");
     ViewBag.specs = new SelectList(ugtu_db.Spec_stud.OrderBy(n => n.Cshort_spec), "", "");
     ViewBag.idSpecs = new SelectList(SpecsList, "idSpec", "NameSpec");
     return View("AddVakansiya", VM);
 }
Ejemplo n.º 2
0
        public ActionResult AddVakansiyaSave(VakansiyaModel VM, int KolChel)
        {
            if (ModelState.IsValid)
            {

                //DateTime DataObzvon = VM.DataPostVakans;
                int Status = 1;//открыта
                int? lastid = null;
                Vakans res = new Vakans()
                {
                    // VakansName = VM.VakansName,
                    idPredpr = GetIdPredpr(VM.NamePred),
                    DolgnostnObyazan = VM.DolgnObyaz,
                    InfoGrafikRab = VM.InfoGrafikRab,
                    Lgoty = VM.Lgoty,
                    DopInfo = VM.DopInfo,
                    DataPostVakans = VM.DataPostVakans,
                    DataObzvon = VM.DataPostVakans,// костыль
                    idDolznost = (int)AddDolgnost(VM.Dolgnost),
                    idStatus = Status,
                    KolChel = KolChel,
                    TrebKandidat = VM.TrebKandidat,
                    ZarPlata = VM.Zarplata,
                    OtdelName = VM.OtdelName
                };
                ugtu_db.Vakans.InsertOnSubmit(res);
                ugtu_db.SubmitChanges();
                lastid = res.idVakans;
                Param_Vakans PV = new Param_Vakans()
                    {
                        idParamZnachVakans = VM.idTipZan,
                        idParam =
                            ugtu_db.ZnachParam.Where(param => param.idZnachParam == VM.idTipZan)
                                   .Select(param => param.idParam)
                                   .First(),
                        idVakans = (int)lastid
                    };
                ugtu_db.Param_Vakans.InsertOnSubmit(PV);
                ugtu_db.SubmitChanges();
                for (int i = 0; i < VM.specs.Count(); i++)
                {
                    if (VM.specs[i].ValSpec)
                    {
                        Vakans_Specs VS = new Vakans_Specs()
                        {
                            idSpecs = VM.specs[i].idSpec,
                            idVakans = (int)lastid
                        };
                        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                        ugtu_db.SubmitChanges();
                    }
                }

                return RedirectToAction("VakansiyaInfo", new { id = res.idVakans });
            }
            else { return RedirectToAction("AddVakansiya"); }
        }
Ejemplo n.º 3
0
        public ActionResult EditVakansiyaSave(VakansiyaModel VM, int KolChel)
        {
            if (ModelState.IsValid)
            {
                var Vak = ugtu_db.Vakans.Where(vakans => vakans.idVakans == VM.ID).Single();

                // V.VakansName = VM.VakansName;
                Vak.idDolznost = (int)AddDolgnost(VM.Dolgnost);
                Vak.idPredpr = GetIdPredpr(VM.NamePred);
                Vak.DataPostVakans = VM.DataPostVakans;
                Vak.KolChel = KolChel;
                Vak.DolgnostnObyazan = VM.DolgnObyaz;
                Vak.InfoGrafikRab = VM.InfoGrafikRab;
                Vak.DopInfo = VM.DopInfo;
                Vak.Lgoty = VM.Lgoty;
                Vak.idStatus = VM.idStatus;
                Vak.DataObzvon = VM.DataObzvon;
                Vak.TrebKandidat = VM.TrebKandidat;
                Vak.ZarPlata = VM.Zarplata;
                Vak.OtdelName = VM.OtdelName;
                var ParVakans = ugtu_db.Param_Vakans.Where(vakans => vakans.idVakans == VM.ID && vakans.idParam == idParamTipZan);
                foreach (var PV in ParVakans)
                {
                    PV.idParamZnachVakans = VM.idTipZan;
                }
                var SpecsVakans = ugtu_db.Vakans_Specs.Where(vakans => vakans.idVakans == VM.ID).ToList();
                foreach (var c in SpecsVakans)
                {
                    ugtu_db.Vakans_Specs.DeleteOnSubmit(c);
                }
                ugtu_db.SubmitChanges();
                for (int j = 0; j < VM.specs.Count(); j++)
                {
                    if (VM.specs[j].ValSpec)
                    {
                        Vakans_Specs VS = new Vakans_Specs()
                        {
                            idSpecs = VM.specs[j].idSpec,
                            idVakans = VM.ID
                        };
                        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                    }
                }
                ugtu_db.SubmitChanges();

                //if (VM.Specs.Count() == SpecsVakans.Count())
                //{
                //    int i = 0;
                //    foreach(var c in SpecsVakans)
                //    {
                //        c.idSpecs = VM.Specs[i];
                //        c.idVakans = VM.ID;
                //        i++;
                //    }
                //}

                //if (VM.Specs.Count() > SpecsVakans.Count())
                //{
                //    int i = 0;
                //    foreach (var c in SpecsVakans)
                //    {
                //        c.idSpecs = VM.Specs[i];
                //        c.idVakans = VM.ID;
                //        i++;
                //    }
                //    for (int j = 0; j < VM.Specs.Count() - SpecsVakans.Count(); j++)
                //    {
                //        Vakans_Specs VS = new Vakans_Specs()
                //        {
                //            idSpecs = VM.Specs[j+i],
                //            idVakans = VM.ID
                //        };
                //        ugtu_db.Vakans_Specs.InsertOnSubmit(VS);
                //    }
                //}

                //if (VM.Specs.Count() < SpecsVakans.Count())
                //{
                //    for (int j = 0; j < SpecsVakans.Count()-VM.Specs.Count(); j++)
                //    {
                //        ugtu_db.Vakans_Specs.DeleteOnSubmit(SpecsVakans.ToList()[j]);
                //    }
                //    for (int j = 0; j <  VM.Specs.Count(); j++)
                //    {
                //        SpecsVakans.ToList()[j].idSpecs = VM.Specs[j];
                //        SpecsVakans.ToList()[j].idVakans = VM.ID;
                //    }
                //}

                return RedirectToAction("VakansiyaInfo", new { id = VM.ID });
            }
            else { return RedirectToAction("VakansiyaEdit", new { id = VM.ID }); };
        }