コード例 #1
0
        // Метод записи в БД
        public int AddResumeSaveBD(ResumeModel resume, int idTipZan)
        {
            using (var ugtu_db = new UGTU_DBDataContext())
            {
                Models.ugtuRealTest.File F = null;
                if (resume.upload != null)
                {
                    F = new Models.ugtuRealTest.File();
                    F.ExtensionFile = Path.GetExtension(resume.upload.FileName);
                    byte[] byteFile = null;
                    // считываем переданный файл в массив байтов
                    using (var binaryReader = new BinaryReader(resume.upload.InputStream))
                    {
                        byteFile = binaryReader.ReadBytes(resume.upload.ContentLength);
                    }
                    F.bFile = byteFile;

                    ugtu_db.File.InsertOnSubmit(F);
                    ugtu_db.SubmitChanges();
                }

                Resume res = new Resume()
                {
                    DataPrinytiya = resume.DataPrinytiya,
                    idStatus = 1,//StatusResumeOpen,
                    idStud = resume.idStud,
                    DopInfo = resume.DopInfo,
                    Otmetki=resume.Otmetki
                };
                if (F != null) { res.idFile = F.idFile; } else {
                    var fileres = ugtu_db.Resume.Where(m => m.idStud == resume.idStud && m.idFile != null).Select(m => m.idFile).FirstOrDefault();
                    res.idFile = fileres;
                }
                ugtu_db.Resume.InsertOnSubmit(res);
                if (F != null)
                {
                    foreach (var r in ugtu_db.Resume.Where(r => r.idStud == resume.idStud))
                    {
                        if (ugtu_db.File.Where(m => m.idFile == r.idFile).Count() > 0)
                        {
                            ugtu_db.File.DeleteOnSubmit(ugtu_db.File.Where(m => m.idFile == r.idFile).First());
                        }
                        r.idFile = F.idFile;
                    }
                }
                var person = ugtu_db.Person.Where(m => m.nCode == resume.idStud).First();
                person.cEmail = resume.mail;
                person.cSotTel = resume.Tel;
                ugtu_db.SubmitChanges();
                Param_Resume PR = new Param_Resume()
                {
                    idResumeZnachParam = idTipZan,
                    idParam = ConstRep.idParamTipZan,
                    idResume = res.idResume
                };
                ugtu_db.Param_Resume.InsertOnSubmit(PR);
                ugtu_db.SubmitChanges();
                return res.idResume;
            }
        }
コード例 #2
0
ファイル: Repository.cs プロジェクト: ulyashevivan/czs
        public int AddTrudoustrSave(TrudoustrModel Trud)
        {
            using (var ugtu_db = new UGTU_DBDataContext())
            {
                Models.ugtuRealTest.File F = null;
                if (Trud.upload != null)
                {
                    F = new Models.ugtuRealTest.File();
                    F.ExtensionFile = Path.GetExtension(Trud.upload.FileName);
                    byte[] byteFile = null;
                    // считываем переданный файл в массив байтов
                    using (var binaryReader = new BinaryReader(Trud.upload.InputStream))
                    {
                        byteFile = binaryReader.ReadBytes(Trud.upload.ContentLength);
                    }
                    F.bFile = byteFile;

                    ugtu_db.File.InsertOnSubmit(F);
                    ugtu_db.SubmitChanges();
                }
                Trudoustr Tr = new Trudoustr()
                {
                    DataBegin = Trud.DataNachTrudoustr,
                    DataObzvon = Trud.DataObzvon,
                    DataEnd = Trud.DataOkonTrudoustr,
                    IDDolznost = Trud.idDolzhnost,
                    IDPredpriyatie = Trud.idPredpr,
                    RabotaPoSpec = Trud.RabPoSpec,
                    ZarPlata = Trud.ZarPlata,
                    IDStudent = Trud.idStud,
                    Spravka = Trud.BitSpravka,
                    Otdel=Trud.Otdel,
                    DopInfo=Trud.DopInfo
                };
                if (F != null) Tr.IDFile = F.idFile;
                ugtu_db.Trudoustr.InsertOnSubmit(Tr);
                ugtu_db.SubmitChanges();
                return Tr.IDTrudoustr;
            }
        }
コード例 #3
0
        public ActionResult EditTrudoustrSave(TrudoustrModel Trud, string Path)
        {
            using (var ugtu_db = new UGTU_DBDataContext())
            {
                var Trudostr = ugtu_db.Trudoustr.Where(tr => tr.IDTrudoustr == Trud.idTrud).First();
                if (Path == "Vipusknik")
                {
                    Models.ugtuRealTest.File F = null;

                    if (Trudostr.Spravka == true && Trud.BitSpravka == false)//если справка была и её не стало
                    {
                        ugtu_db.File.DeleteOnSubmit(ugtu_db.File.Where(f => f.idFile == Trudostr.IDFile).SingleOrDefault());
                        Trudostr.IDFile = null;
                        ugtu_db.SubmitChanges();
                    }
                    else
                    {
                        if (Trud.BitSpravka == true && Trud.upload != null)
                        {
                            if (Trudostr.Spravka == true) F = new Models.ugtuRealTest.File();
                            else F = ugtu_db.File.Where(f => f.idFile == Trudostr.IDFile).SingleOrDefault();
                            F.ExtensionFile = System.IO.Path.GetExtension(Trud.upload.FileName);
                            byte[] byteFile = null;
                            // считываем переданный файл в массив байтов
                            using (var binaryReader = new BinaryReader(Trud.upload.InputStream))
                            {
                                byteFile = binaryReader.ReadBytes(Trud.upload.ContentLength);
                            }
                            F.bFile = byteFile;

                            if (Trudostr.Spravka == true) ugtu_db.File.InsertOnSubmit(F);
                            ugtu_db.SubmitChanges();

                            if (F != null) Trudostr.IDFile = F.idFile;
                            if (Path == "Vipusknik" && F == null) Trudostr.IDFile = null;
                        }
                    }
                }
                //var Trudostr = ugtu_db.Trudoustr.Where(tr => tr.IDTrudoustr == Trud.idTrud).First();
                Trudostr.DataBegin = Trud.DataNachTrudoustr;
                Trudostr.DataObzvon = Trud.DataObzvon;
                Trudostr.DataEnd = Trud.DataOkonTrudoustr;
                Trudostr.IDDolznost = AddDolgnost(Trud.NameDolzhnost);
                Trudostr.IDPredpriyatie =GetIdPredpr(Trud.NamePred);
                Trudostr.RabotaPoSpec = Trud.RabPoSpec;
                Trudostr.Otdel = Trud.Otdel;
                Trudostr.ZarPlata = Trud.ZarPlata;
                Trudostr.IDStudent = Trud.idStud;
                Trudostr.Spravka = Trud.BitSpravka;
                Trudostr.DopInfo = Trud.DopInfo;

                ugtu_db.SubmitChanges();
            }
            return RedirectToAction("InfoTrudoustr", Path, new { idTrud = Trud.idTrud, idStud = Trud.idStud });
        }