Ejemplo n.º 1
0
        public void SaveArea(string Id, string Address, string Comment)
        {
            string comm  = Globals.StringIsEmpty(Comment) ? "NULL" : "'" + Comment + "'";
            string query = "UPDATE Areas SET Address='" + Address + "', Comment=" + comm + " WHERE IdArea=" + Id;

            DbMess.DoAction(query);
        }
Ejemplo n.º 2
0
 public void AddArea(string Id, string Address, string Comment)
 {
     if (!Globals.StringIsEmpty(Address))
     {
         string comm  = Globals.StringIsEmpty(Comment) ? "NULL" : "'" + Comment + "'";
         string query = "INSERT INTO Areas VALUES('" + Address + "'," + comm + ", 0)";
         DbMess.DoAction(query);
     }
 }
Ejemplo n.º 3
0
        public void AddOrganization(string Id, string Name, string Mail, string Phone, string Fio)
        {
            string mail  = Globals.StringIsEmpty(Mail) ? "NULL" : "'" + Mail + "'";
            string phone = Globals.StringIsEmpty(Phone) ? "NULL" : "'" + Phone + "'";
            string fio   = Globals.StringIsEmpty(Fio) ? "NULL" : "'" + Fio + "'";

            string query = "INSERT INTO Organizations VALUES('" + Name + "'," + mail + "," + phone + "," + fio + ", 0)";

            DbMess.DoAction(query);
        }
Ejemplo n.º 4
0
        public void SaveOrganization(string Id, string Name, string Mail, string Phone, string Fio)
        {
            string mail  = Globals.StringIsEmpty(Mail) ? "NULL" : "'" + Mail + "'";
            string phone = Globals.StringIsEmpty(Phone) ? "NULL" : "'" + Phone + "'";
            string fio   = Globals.StringIsEmpty(Fio) ? "NULL" : "'" + Fio + "'";

            string query = "UPDATE Organizations SET Name='" + Name + "', Email=" + mail + ",Phone=" + phone + ", ContactFio=" + fio + " WHERE IdOrganization=" + Id;

            DbMess.DoAction(query);
        }
Ejemplo n.º 5
0
        public ActionResult SaveLecturer(string Id, string FIO, string OrganizationId, string Email, string Phone, HttpPostedFileBase newAvatar)
        {
            Console.WriteLine("bp");

            //1) сохранить фотографию

            string query = "";

            if (newAvatar != null)
            {
                string fileName        = Globals.GetRandomName(10);
                string avatarExtension = "." + newAvatar.FileName.Split('.').Last();
                string picturePath     = null;

                string normalPath = "/Files/Avatars/" + fileName + avatarExtension;

                picturePath = Server.MapPath("~/Files/Avatars/" + fileName + avatarExtension);
                newAvatar.SaveAs(picturePath);

                //2) проверить, есть ли уже у этого препода фотография
                query = "SELECT AvatarFileId FROM Lecturers WHERE IdLecturer=" + Id;
                string fileId = DbMess.GetValue(query);
                if (!Globals.StringIsEmpty(fileId))
                {
                    //3.a) если есть, заменить путь
                    query = "UPDATE Files SET Path='" + picturePath + "' WHERE IdFile=" + fileId;
                    DbMess.DoAction(query);
                }
                else
                {
                    //3.b) если нет, инсёртнуть, забрать айдишник, и обновить поле у проеподавателя
                    query = "INSERT INTO FILES VALUES('" + picturePath + "', '" + normalPath + "', GETDATE())";
                    DbMess.DoAction(query);

                    query = "SELECT MAX(IdFile) FROM Files";

                    query = "UPDATE Lecturers SET AvatarFileId=" + DbMess.GetValue(query);
                    DbMess.DoAction(query);
                }
            }

            string org   = Globals.StringIsEmpty(OrganizationId) ? "NULL" : OrganizationId;
            string mail  = Globals.StringIsEmpty(Email) ? "NULL" : "'" + Email + "'";
            string phone = Globals.StringIsEmpty(Phone) ? "NULL" : "'" + Phone + "'";

            //теперь обновить остальные поля ))
            query = "UPDATE Lecturers SET FIO='" + FIO + "', OrganizationId=" + org + ", Email=" + mail + ", ContactPhone=" + phone + " WHERE IdLecturer=" + Id;
            DbMess.DoAction(query);

            return(Redirect("/catalog/lecturers"));
        }
Ejemplo n.º 6
0
        public void addCouse(string Id, string Name, bool IsRemote, string Length, string Type)
        {
            double finalLength = 0;
            string length      = "";

            if (double.TryParse(Length, out finalLength))
            {
                length = finalLength.ToString();
            }
            else
            {
                length = "NULL";
            }

            string query = "INSERT INTO Courses VALUES('" + Name + "', " + Convert.ToInt32(IsRemote) + ", " + length + ", " + Type + ", 0)";

            DbMess.DoAction(query);
        }
Ejemplo n.º 7
0
        public void SaveCouse(string Id, string Name, bool IsRemote, string Length, string Type)
        {
            double finalLength = 0;
            string length      = "";

            if (double.TryParse(Length, out finalLength))
            {
                length = finalLength.ToString();
            }
            else
            {
                length = "NULL";
            }

            string query = "UPDATE Courses SET Name='" + Name + "', IsRemote=" + Convert.ToInt32(IsRemote) + ", LengthInHours=" + length + ", ResultType=" + Type + " WHERE IdCourse=" + Id;

            DbMess.DoAction(query);
        }
Ejemplo n.º 8
0
        public void DeleteArea(string Id)
        {
            string query = "UPDATE Areas SET IsDeleted=1 WHERE IdArea=" + Id;

            DbMess.DoAction(query);
        }
Ejemplo n.º 9
0
        public void DeleteOrganization(string id)
        {
            string query = "UPDATE Organizations SET IsDeleted=1 WHERE IdOrganization=" + id;

            DbMess.DoAction(query);
        }
Ejemplo n.º 10
0
        public void DeleteCourse(string Id)
        {
            string query = "UPDATE Courses SET IsDeleted=1 WHERE IdCourse=" + Id;

            DbMess.DoAction(query);
        }