Ejemplo n.º 1
0
        public JsonResult Edit(UserTB use)
        {
            ViewData["GenderList"] = LoadGender();
            ViewData["StatusList"] = LoadStatus();
            ViewData["typeList"]   = Loadtype();
            DBContext DB   = new DBContext();
            UserTB    user = (from us in DB.UserTBs
                              where us.Id == use.Id
                              select us).FirstOrDefault();

            user.FullName      = use.FullName;
            user.UserName      = use.UserName;
            user.Password      = use.Password;
            user.Email         = use.Email;
            user.Mobile1       = use.Mobile1;
            user.Mobile2       = use.Mobile2;
            user.Gender_Id     = use.Gender_Id;
            user.National_Id   = use.National_Id;
            user.Address       = use.Address;
            user.Remarks       = use.Remarks;
            user.UserStatus_Id = use.UserStatus_Id;
            user.UserType_Id   = use.UserType_Id;
            DB.SaveChanges();

            return(Json("true", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        private void UserDataGrid_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                String UserID = UserDataGrid[1, e.RowIndex].Value.ToString();
                if (e.ColumnIndex == 0)
                {
                    if (MessageBox.Show("Do you want to delete this user?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        UserManagement.DeleteUser(UserID);
                        UserDataGrid.Rows.RemoveAt(e.RowIndex);
                    }
                }
                else
                {
                    UserModification ObjUserModification = new UserModification(UserID);
                    ObjUserModification.ShowDialog(this);

                    UserTB ThisUser = UserManagement.GetUserByID(UserID);
                    UserDataGrid[2, e.RowIndex].Value = ThisUser.UserName;
                    UserDataGrid[3, e.RowIndex].Value = ThisUser.UserLoginName;
                    UserDataGrid[4, e.RowIndex].Value = ThisUser.UserPermissionType;
                    UserDataGrid[5, e.RowIndex].Value = ThisUser.UserStationPermission;
                }
            }
        }
 public ActionResult Registration(UserTB usertable)
 {
     db.UserTBs.Add(usertable);
     db.SaveChanges();
     ViewBag.Successfulmessage = "You are successfully Register";
     return(View());
 }
Ejemplo n.º 4
0
        public JsonResult Create(UserTB user)
        {
            ViewData["GenderList"] = LoadGender();
            ViewData["StatusList"] = LoadStatus();
            ViewData["typeList"]   = Loadtype();
            //HttpPostedFileBase file = null;
            //try { file = Request.Files[0]; } catch { }

            //if (file != null && file.ContentLength > 0)
            //{
            //    string extension = Path.GetExtension(Request.Files[0].FileName).ToLower();
            //    if (extension != ".jpg")
            //    {
            //        ViewData["msg"] = "Failed to Save User Information! Allowed image format is .jpg";
            //        return View();
            //    }

            //}
            DBContext DB = new DBContext();

            //  user.Image = file != null && file.ContentLength > 0 ? true : false;
            DB.UserTBs.Add(user);
            DB.SaveChanges();
            //if (file != null && file.ContentLength > 0)
            //{
            //    string extension = Path.GetExtension(Request.Files[0].FileName).ToLower();
            //    string path = Path.Combine(Server.MapPath("~/Images/User"), "U_" + user.Id + extension);
            //    file.SaveAs(path);/// file save
            //}

            return(Json("true", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> PutUserTB(int id, UserTB userTB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userTB.ID)
            {
                return(BadRequest());
            }

            db.Entry(userTB).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserTBExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 6
0
        private void GetUserInformation()
        {
            if (UserID != null)
            {
                UserTB ThisUser = UserManagement.GetUserByID(UserID);

                if (ThisUser != null)
                {
                    UserName.Text          = ThisUser.UserName;
                    UserLoginName.Text     = ThisUser.UserLoginName;
                    UserLoginPassword.Text = ThisUser.UserLoginPassword;

                    String PermissionStr = ThisUser.UserPermissionType;
                    if (PermissionStr != null)
                    {
                        String[] PermissionArr = PermissionStr.Split(new char[] { ',' });
                        for (int i = 0; i < UserPermissionType.RowCount; i++)
                        {
                            UserPermissionType[0, i].Value = false;
                        }

                        foreach (String ThisPermission in PermissionArr)
                        {
                            for (int i = 0; i < UserPermissionType.RowCount; i++)
                            {
                                if (UserPermissionType[1, i].Value.ToString() == ThisPermission)
                                {
                                    UserPermissionType[0, i].Value = true;
                                    break;
                                }
                            }
                        }
                    }

                    String StationStr = ThisUser.UserStationPermission;
                    if (StationStr != null)
                    {
                        String[] StationArr = StationStr.Split(new char[] { ',' });
                        for (int i = 0; i < UserStationPermission.RowCount; i++)
                        {
                            UserStationPermission[0, i].Value = false;
                        }

                        foreach (String ThisStation in StationArr)
                        {
                            for (int i = 0; i < UserStationPermission.RowCount; i++)
                            {
                                if (UserStationPermission[1, i].Value.ToString() == ThisStation)
                                {
                                    UserStationPermission[0, i].Value = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static void AddToBuffer(UserTB NewUser, DATAACTION UserAction)
        {
            TransectionBuffer NewTransection = new TransectionBuffer();

            NewTransection.UserAction      = UserAction;
            NewTransection.UserInformation = NewUser;

            BufferList.Enqueue(NewTransection);
        }
Ejemplo n.º 8
0
        public ActionResult UserDetails(int id)
        {
            DBContext DB     = new DBContext();
            UserTB    client = (from u in DB.UserTBs
                                where u.Id == id
                                select u).FirstOrDefault();

            return(View(client));
        }
Ejemplo n.º 9
0
        public static UserTB GetUserByID(String UserID)
        {
            if (UserID != null)
            {
                UserTB ThisUser = db.UserTBs.FirstOrDefault(Item => Item.UserID == UserID);
                return(ThisUser);
            }

            return(null);
        }
Ejemplo n.º 10
0
        private static void UpdateUser(List <Object[]> TableField, STATIONNAME StationName)
        {
            db = RefreshDB();
            UserTB CheckUser = new UserTB();

            CheckUser.UserID             = TableField.ElementAt(0)[0].ToString();
            CheckUser.UserName           = TableField.ElementAt(0)[1].ToString();
            CheckUser.UserLoginName      = TableField.ElementAt(0)[2].ToString();
            CheckUser.UserLoginPassword  = TableField.ElementAt(0)[3].ToString();
            CheckUser.UserPermissionType = TableField.ElementAt(0)[4].ToString();

            UserTB ThisUser = db.UserTBs.FirstOrDefault(Item => Item.UserID == CheckUser.UserID);

            if (ThisUser == null)
            {
                ThisUser                       = new UserTB();
                ThisUser.UserID                = CheckUser.UserID;
                ThisUser.UserName              = CheckUser.UserName;
                ThisUser.UserLoginName         = CheckUser.UserLoginName;
                ThisUser.UserLoginPassword     = CheckUser.UserLoginPassword;
                ThisUser.UserPermissionType    = CheckUser.UserPermissionType;
                ThisUser.UserStationPermission = StationName.ToString();

                db.UserTBs.Add(ThisUser);
            }
            else
            {
                ThisUser.UserName           = CheckUser.UserName;
                ThisUser.UserLoginName      = CheckUser.UserLoginName;
                ThisUser.UserLoginPassword  = CheckUser.UserLoginPassword;
                ThisUser.UserPermissionType = CheckUser.UserPermissionType;

                if (ThisUser.UserStationPermission == null)
                {
                    ThisUser.UserStationPermission = StationName.ToString();
                }
                else
                {
                    if (ThisUser.UserStationPermission.Trim() != "")
                    {
                        if (ThisUser.UserStationPermission != "All Station")
                        {
                            ThisUser.UserStationPermission = "," + StationName.ToString();
                        }
                    }
                    else
                    {
                        ThisUser.UserStationPermission = StationName.ToString();
                    }
                }
            }

            db.SaveChangesAsync();
        }
Ejemplo n.º 11
0
        public async Task <IHttpActionResult> PostUserTB(UserTB userTB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.UserTBs.Add(userTB);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = userTB.ID }, userTB));
        }
Ejemplo n.º 12
0
        public ActionResult Edit(int id)
        {
            ViewData["GenderList"] = LoadGender();
            ViewData["StatusList"] = LoadStatus();
            ViewData["typeList"]   = Loadtype();
            DBContext DB   = new DBContext();
            UserTB    user = (from use in DB.UserTBs
                              where use.Id == id
                              select use).FirstOrDefault();

            return(View(user));
        }
Ejemplo n.º 13
0
        public ActionResult Index(UserTB user)
        {
            int data = wc.Login(user.Username, user.Password);

            if (data == 1)
            {
                return(RedirectToAction("Index", "Employee"));
            }
            else
            {
                ViewBag.err1 = "Wrong Username & Password";
                return(View());
            }
        }
Ejemplo n.º 14
0
        public static Boolean DeleteUser(String UserID)
        {
            try
            {
                UserTB ThisUser = db.UserTBs.FirstOrDefault(Item => Item.UserID == UserID);
                db.UserTBs.Remove(ThisUser);
                db.SaveChanges();

                AddToBuffer(ThisUser, DATAACTION.DELETE);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 15
0
        public ActionResult Signup(Signup su)
        {
            UserTB ut = new UserTB();

            ut.UserName = su.UserName;
            ut.Email    = su.Email;
            ut.Password = su.Password;
            _db.UserTBs.Add(ut);
            _db.SaveChanges();

            UserRole ur = new UserRole();

            ur.UserId = ut.UserId;
            ur.RoleId = 2;
            _db.UserRoles.Add(ur);
            _db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 16
0
        public static Boolean UpdateUser(String UserID, String UserName, String UserLoginName, String UserLoginPassword, String UserPermissionType, String UserStationPermission)
        {
            UserTB ExistingUser = db.UserTBs.FirstOrDefault(Item => Item.UserID == UserID);

            if (ExistingUser != null)
            {
                ExistingUser.UserName              = UserName;
                ExistingUser.UserLoginName         = UserLoginName;
                ExistingUser.UserLoginPassword     = UserLoginPassword;
                ExistingUser.UserPermissionType    = UserPermissionType;
                ExistingUser.UserStationPermission = UserStationPermission;
                db.SaveChanges();

                AddToBuffer(ExistingUser, DATAACTION.UPDATE);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 17
0
        public ActionResult GoBuy(FormCollection collection)
        {
            UserTB user = new UserTB();

            user.Address   = collection["Address"];
            user.ContactNo = collection["ContactNo"];
            dc.UserTBs.InsertOnSubmit(user);
            dc.SubmitChanges();
            var     uid   = int.Parse(Session["userid"].ToString());
            var     cdata = /* from x in dc.CartTBs where x.UserId == uid select x;*/ dc.CartTBs.Where(o => o.UserId == uid).ToList();
            OrderTB otb   = new OrderTB();

            otb.UserId     = uid;
            otb.OrderDate  = DateTime.Now;
            otb.GrandTotal = Convert.ToDecimal(collection["Total"]);

            dc.OrderTBs.InsertOnSubmit(otb);
            dc.SubmitChanges();
            int oid = otb.OrderId;

            foreach (var d in cdata)
            {
                OrderDetailTB odetail = new OrderDetailTB();
                odetail.OrderId   = oid;
                odetail.ProductId = d.ProductId;
                odetail.Qty       = d.Qty;
                odetail.Price     = d.Price;

                dc.OrderDetailTBs.InsertOnSubmit(odetail);
                dc.SubmitChanges();
            }
            foreach (var s in cdata)
            {
                dc.CartTBs.DeleteOnSubmit((from m in dc.CartTBs where m.UserId == uid select m).FirstOrDefault());

                dc.SubmitChanges();
            }



            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
        protected void btnSubmitM_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text != null) //will have to take out the if else statement until we figure it out?????
            {                          //this works now, but I'm just going to leave this if section in to show what it is supposed to do
                //using (UserDatabaseEntities dbcon = new UserDatabaseEntities())
                //{
                MessageTB myMsg = new MessageTB();
                //UserTB myUser = new UserTB();
                //query for student user name
                UserTB myUser = (from x in dbcontext.UserTBs.Local
                                 where x.UserName.Equals(User.Identity.Name.ToString())
                                 select x).First();

                //AdvisorTB myAdvisor = new AdvisorTB();
                //add data to the myMsg
                myMsg.EmailDate = DateTime.Now.Date;
                //time
                myMsg.EmailTime = DateTime.Now.TimeOfDay;// System.TimeSpan.Now.ToShortString();
                myMsg.EmailTo   = txtEmail.Text;
                // myMsg.EmailFrom = myUser.UserName.ToString();
                myMsg.EmailFrom = myUser.UserEmail;
                //myMsg.EmailFrom = TextBox1.Text;
                myMsg.EmailText = txtMessage.Text;

                //add data to the Database table
                dbcontext.MessageTBs.Add(myMsg);
                dbcontext.SaveChanges();
                //clear data
                txtEmail.Text   = "";
                txtMessage.Text = "";
                Label2.Text     = "";
                Label3.Text     = "";
                //reload tables
                ReloadMessages();
                ReloadSent();
                //}
            }
            else
            {
                Label2.Text = "Please enter an email address and message before selecting the 'Send' button.";
            }
        }
    public ActionResult Login(UserTB usertable)
    {
        var userLoggedIn = db.UserTBs.Where(m => m.user_name == usertable.user_name && m.user_password == usertable.user_password).FirstOrDefault();

        if (userLoggedIn != null)
        {
            ViewBag.message   = "loggedin";
            ViewBag.tryiedOne = "Yes";
            Session["ID"]     = usertable.user_id.ToString();
            Session["Name"]   = usertable.user_name.ToString();
            return(RedirectToAction("mainPage", "Account", new { username = usertable.user_name }));
        }
        else
        {
            FormsAuthentication.SetAuthCookie(usertable.user_name, false);
            ViewBag.triedOne = "Yes";
            ViewBag.notlogin = "******";
            return(View());
        }
    }
Ejemplo n.º 20
0
        public static Boolean AddUser(String UserID, String UserName, String UserLoginName, String UserLoginPassword, String UserPermissionType, String UserStationPermission)
        {
            try
            {
                UserTB NewUser = new UserTB();
                NewUser.UserID                = UserID;
                NewUser.UserName              = UserName;
                NewUser.UserLoginName         = UserLoginName;
                NewUser.UserLoginPassword     = UserLoginPassword;
                NewUser.UserPermissionType    = UserPermissionType;
                NewUser.UserStationPermission = UserStationPermission;

                db.UserTBs.Add(NewUser);
                db.SaveChanges();

                AddToBuffer(NewUser, DATAACTION.INSERT);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 21
0
        private static Object SyncExistingUser(List <Object[]> TableField)
        {
            db = RefreshDB();
            List <UserTB> UserList     = db.UserTBs.ToList();
            List <UserTB> NewUser      = new List <UserTB>();
            List <UserTB> StationUsers = new List <UserTB>();

            foreach (Object[] ThisObject in TableField)
            {
                UserTB NewStationUser = new UserTB();
                NewStationUser.UserID             = ThisObject[0].ToString();
                NewStationUser.UserLoginName      = ThisObject[1].ToString();
                NewStationUser.UserLoginPassword  = ThisObject[2].ToString();
                NewStationUser.UserPermissionType = ThisObject[3].ToString();
                StationUsers.Add(NewStationUser);
            }

            foreach (UserTB ServerUser in UserList)
            {
                Boolean IsFound = false;
                foreach (UserTB StationUser in StationUsers)
                {
                    if (StationUser.UserID == ServerUser.UserID)
                    {
                        IsFound = true;
                        break;
                    }
                }

                if (!IsFound)
                {
                    NewUser.Add(ServerUser);
                }
            }

            return(NewUser);
        }
Ejemplo n.º 22
0
 private void textBox1_Click(object sender, EventArgs e)
 {
     label1.Visible = true;
     UserTB.Clear();
 }
Ejemplo n.º 23
0
        protected void EneterBT_Click(object sender, EventArgs e)
        {
            string database = ((TextBox)DatabaseTB.FindControl("DatabaseTB")).Text;
            string catalog  = ((TextBox)CatalogTB.FindControl("CatalogTB")).Text;
            string user     = ((TextBox)UserTB.FindControl("UserTB")).Text;
            string password = ((TextBox)PasswordTB.FindControl("PasswordTB")).Text;

            try
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
                builder.DataSource     = database;
                builder.UserID         = user;
                builder.Password       = password;
                builder.InitialCatalog = catalog;
                builder.ConnectTimeout = 10;

                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    connection.Open();
                    if ((connection.State & ConnectionState.Open) > 0)
                    {
                        string url = "Popup_ConnectionOK.aspx";
                        string s   = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
                        ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
                        connection.Close();
                    }
                    else
                    {
                        string url = "Popup_ConnectionFail.aspx";
                        string s   = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
                        ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
                    }


                    /*
                     * String sql = "SELECT * from Autorzy";
                     *
                     * using (SqlCommand command = new SqlCommand(sql, connection))
                     * {
                     *     connection.Open();
                     *
                     *
                     *
                     *     using (SqlDataReader reader = command.ExecuteReader())
                     *     {
                     *         while (reader.Read())
                     *         {
                     *             Response.Write($"{reader.GetInt32(0)}");
                     *             Response.Write($"\t{reader.GetString(1)}");
                     *             Response.Write($"\t{reader.GetString(2)}" + "<br/>");
                     *
                     *         }
                     *     }
                     * }
                     *
                     * connection.Close();
                     */
                }
            }
            catch (SqlException exc)
            {
                Response.Write($"{exc.Message}");
            }
        }