public ActionResult DeleteFiles(string Id)
        {
            DBDataContext db = new DBDataContext();
            int IdCur = Convert.ToInt32(Id);
            fileContaner fd = db.fileContaner.FirstOrDefault(u => u.Id == IdCur);
            int? predmetId = fd.predmetId;
            db.ExecuteCommand("DELETE FROM Files WHERE Id=" + fd.docsId.ToString());
            db.ExecuteCommand("DELETE FROM Files WHERE Id=" + fd.programId.ToString());
            db.ExecuteCommand("DELETE FROM Files WHERE Id=" + fd.scanId.ToString());

            db.ExecuteCommand("DELETE FROM fileContaner WHERE Id=" + Id);
            return RedirectToAction("Downloads", new { id = predmetId });
        }
Exemplo n.º 2
0
 public static void WriteArchive(String pathProg, String pathScan, String pathDocs)
 {
     DBDataContext db = new DBDataContext();
     db.ExecuteCommand("insert into fileContaner (whoUserId, data, program, scan, docs) VALUES ({0}, {1}, {2}, {3}, {4})", 1);
 }
Exemplo n.º 3
0
        //[AllowAnonymous]
        //Create new seeds with person
        public ActionResult AddNewEnrollment(WebScanner.Models.EBTS.Person person)
        {
            string strSQL;
            var    ViewModelPerson = new WebScanner.ViewModels.Enrollment.NewEnrollmentFormViewModel
            {
                Person = person
            };

            if (!ModelState.IsValid)
            {
                TempData["Error"] = "";
                var modelErrors = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        TempData["Error"] = TempData["Error"] + "<li>" + modelError.ErrorMessage + "</li>";
                    }
                }

                return(RedirectToAction("Index", "EBTS", ViewModelPerson));
            }
            var RandomNumber = new Random();

            DBDataContext db = new DBDataContext();
            //var fld = db.vw_Fileds.Where(f => f.Identifier == person.IdentifierCode).Select(f => new { f.Identifier, f.TotTypeId });

            string NewRandomNumber = RandomNumber.Next(10000000, 99999999).ToString();

            var vwDistinctLogicalRecordType = db.vw_LogicalRecordTypes.Where(col => col.Identifier == person.IdentifierCode).Select(col => new { col.TransactionTypeId }).Distinct();

            foreach (var row in vwDistinctLogicalRecordType)
            {
                strSQL = @"INSERT INTO [dbo].[tlbTransaction_Master]
                           ([Transaction_ID]
                            ,[Transaction_TypeId]
                           ,[Transaction_Desc])
                     VALUES
                           (" + NewRandomNumber + "," + row.TransactionTypeId + ",'')";
                try
                {
                    db.ExecuteCommand(strSQL);
                }
                catch (Exception ex)
                {
                    return(Content("Error saving data!"));
                }
            }
            string DisplayFieldName    = "";
            int    FieldNumber         = 0;
            var    vwLogicalRecordType = db.vw_LogicalRecordTypes.Where(col => col.Identifier == person.IdentifierCode).Select(col => new { col.Identifier, col.TotTypeId });

            foreach (var row in vwLogicalRecordType)
            {
                var vwFields = db.vw_Fileds.Where(col => col.Identifier == person.IdentifierCode && col.TotTypeId == row.TotTypeId && col.IsAutoGenerated == false).Select(col => new { col.TotTypeId, col.FieldId });
                FieldNumber = 0;
                foreach (var fieldRow in vwFields)
                {
                    DisplayFieldName = "Field[" + FieldNumber.ToString() + "].FieldList";
                    strSQL           = @"INSERT INTO [dbo].[tlbTransaction_Detail]
                               ([Transaction_ID]
                               ,[Transaction_TotTypeId]
                               ,[Transaction_FieldID]
                               ,[Transaction_Value]
                               ,[Transaction_DisplayFieldName])
                         VALUES
                               (" + NewRandomNumber + ","
                                       + fieldRow.TotTypeId + ","
                                       + fieldRow.FieldId + ",'"
                                       + "" + "','"
                                       + DisplayFieldName + "')";
                    FieldNumber = FieldNumber + 1;
                    db.ExecuteCommand(strSQL);
                }
            }
            //Aliases FieldID= 33
            //Name FieldID= 31
            int TOTTyepeID = 0;
            var fieldlist  = db.vw_Fileds.Where(col => col.Identifier == person.IdentifierCode && col.FieldId == 31).Select(col => new { col.TotTypeId }).SingleOrDefault();

            strSQL = @"UPDATE [dbo].[tlbTransaction_Detail]
                        SET [Transaction_Value]='" + person.FullName + "' "
                     + "WHERE [Transaction_ID]=" + NewRandomNumber + " "
                     + "AND [Transaction_FieldID]=" + 31 + ""
                     + "AND Transaction_TotTypeId=" + fieldlist.TotTypeId;
            db.ExecuteCommand(strSQL);

            return(RedirectToAction("NewEnrollment/" + person.IdentifierCode, "EBTS", new { transactionid = NewRandomNumber }));
        }
Exemplo n.º 4
0
        //save/Update data
        //EBTS/NewEnrollment/CNA?TotType=8&transactionid=48650597
        public ActionResult NewEnrollment(string Identifier, PersonViewModel model)
        {
            int TOTTypeNumber; //= Request.QueryString["TotType"];
            int transactionid; // = Request.QueryString["transactionid"];

            if (IsNumeric(Request.QueryString["transactionid"]))
            {
                transactionid = Convert.ToInt32(Request.QueryString["transactionid"]);
            }
            else
            {
                return(Content("Error: transactionid"));
            }

            if (IsNumeric(Request.QueryString["TotType"]))
            {
                TOTTypeNumber = Convert.ToInt32(Request.QueryString["TotType"]);
            }
            else
            {
                return(Content("Error: TOTType"));
            }


            //return View(ViewModelFieldList);
            //return RedirectToAction("Index", "EBTS", ViewModelPerson);
            //return RedirectToAction("NewEnrollment", new { TotType = TOTTypeNumber, transactionid = transactionid });

            //string forminvalue = string.Join(",", frm.AllKeys);
            DBDataContext db      = new DBDataContext();
            string        fldname = "";
            //frm.AllKeys.ToList().Contains(fld.FieldName)
            //db.ExecuteQuery<Customer>("select * from dbo.Customers where City = {0}", "London");
            //int rccount = db.tlbTransaction_Masters.Where(m => m.Transaction_ID == Convert.ToInt32(Session["Transaction_ID"])).Count();

            var fldlist = from fld in db.vw_Fileds.Where(f => f.IsAutoGenerated == false).OrderBy(f => f.FieldId) select(fld);
            //where fld.TypeNumber == tempInt && fld.Identifier == Identifier ));

            //foreach (var row in fldlist.ToList())
            //{
            //    rccount = db.tlbTransaction_Details.Where(fldrow => fldrow.Transaction_ID == Convert.ToInt32(Session["Transaction_ID"]) && fldrow.Transaction_FieldID == row.FieldId).Count();
            //    fldname = "frm[row.FieldName]";

            //    string strSQL = @"UPDATE [dbo].[tlbTransaction_Detail]
            //                    SET [Transaction_Value]='" + fldname + "'"
            //                    + "WHERE [Transaction_ID]=" + Session["Transaction_ID"] + " "
            //                    + "AND [Transaction_FieldID]=" + row.FieldId;
            //    db.ExecuteCommand(strSQL);

            //}

            string uservalu = "";
            //foreach (var value in model.Field)
            //{
            //    uservalu = value.FieldList;
            //}



            //int TOTTypeNumber; //= Request.QueryString["TotType"];
            //int transactionid;// = Request.QueryString["transactionid"];

            var    fieldview         = db.vw_TranactionFileds.Where(f => f.Transaction_ID == transactionid && f.Transaction_TotTypeId == TOTTypeNumber);
            string RunningFieldValue = "";

            foreach (var row in fieldview.ToList())
            {
                for (int i = 0; i <= model.Field.Count - 1; i++)
                {
                    //uservalu = model.Field[i].FieldList;
                    if (row.FieldName == "Field[" + i.ToString() + "].FieldList")
                    {
                        RunningFieldValue = model.Field[i].FieldList;

                        string strSQL = @"UPDATE [dbo].[tlbTransaction_Detail]
                                            SET [Transaction_Value]='" + RunningFieldValue + "'"
                                        + "WHERE [Transaction_ID]=" + transactionid + " "
                                        + "AND [Transaction_FieldID]=" + row.FieldId + " "
                                        + "AND [Transaction_TotTypeId]=" + TOTTypeNumber + "";

                        db.ExecuteCommand(strSQL);

                        break;
                    }
                }
            }

            return(Content("Data saved!"));

            //return RedirectToAction("NewEnrollment");
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Попытка зарегистрировать пользователя
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);

                    DBDataContext db = new DBDataContext();
                    UserProfile user = db.UserProfile.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());

                    db.ExecuteCommand("insert into webpages_UsersInRoles (UserId, RoleId) VALUES ({0}, {1})", user.UserId, 1);

                    if (user != null)
                    {
                        user.FIOShort = model.FIOUserName;
                        db.SubmitChanges();
                    }

                    return RedirectToAction("Index", "Main");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return View(model);
        }
Exemplo n.º 6
0
 public ActionResult Remove(int id)
 {
     try
     {
         DBDataContext db = new DBDataContext();
         int response = db.ExecuteCommand(@"DELETE FROM PredmetForUser WHERE PredmetForUser.Id={0}", id);
         if (response == 1)
         {
             return RedirectToAction("Index");
         }
     }
     catch (Exception)
     {
         return RedirectToAction("Index");
         //return RedirectToAction("Remove", new { id = id, saveChangesError = true });
     }
     return RedirectToAction("Index");
 }