コード例 #1
0
        public ActionResult edit()
        {
            Models.users user = new Models.users();
            SqlConnectionStringBuilder constr = new SqlConnectionStringBuilder("Data Source=DESKTOP-N9AAJ82\\SKERDI;Initial Catalog=KEMBIM_VALUTOR;Integrated Security=True");
            string qrstr = "select name,surname,username,birthday,email,password from users where user_id = '" + Session["user_id"] + "'";

            using (SqlConnection con = new SqlConnection(constr.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(qrstr, con);
                con.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    try
                    {
                        user.Name = (string)reader[0];
                    }
                    catch (Exception)
                    { }
                    try
                    {
                        user.Surname = (string)reader[1];
                    }
                    catch (Exception)
                    { }
                    try
                    {
                        user.Username = (string)reader[2];
                    }
                    catch (Exception)
                    { }
                    try
                    {
                        user.Birthday = (string)reader[3];
                    }
                    catch (Exception) { }

                    try
                    {
                        user.Email = (string)reader[4];
                    }
                    catch (Exception)
                    { }
                    try
                    {
                        user.Password = (string)reader[5];
                    }
                    catch (Exception)
                    { }
                    reader.Close();
                }
            }
            return(View(user));
        }
コード例 #2
0
        public ActionResult edit(Models.users user)
        {
            SqlConnectionStringBuilder constr = new SqlConnectionStringBuilder("Data Source=DESKTOP-N9AAJ82\\SKERDI;Initial Catalog=KEMBIM_VALUTOR;Integrated Security=True");
            string qrstr = "update users set name = '" + user.Name + "', surname = '" + user.Surname + "', username = '******', password = '******', birthday = " + user.Birthday + ", email = '" + user.Email + "' where user_id = " + Session["user_id"] + "";

            using (SqlConnection con = new SqlConnection(constr.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(qrstr, con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
            return(RedirectToAction("userdetails"));
        }
コード例 #3
0
        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (thirdPArty_serviceCmb.IsChecked == true)
            {
                if (clientCmb.SelectedItem == null || brandCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || string.IsNullOrEmpty(commercial_invoiceTextBox.Text) || purchase_dateDatePicker.DisplayDate.ToString() == "" || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString()))
                {
                    MessageBox.Show("Los campos cliente, marca, imei o serie, factura, fecha de compra, tecnico encargado y fecha de entrada no deben ser nulas");
                    return;
                }
            }
            else
            {
                if (clientCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString()))
                {
                    MessageBox.Show("Los campos cliente, imei o serie, tecnico encargado y fecha de entrada no deben estar vacios");
                    return;
                }
            }

            using (context)
            {
                Models.services  newService  = new Models.services();
                Models.customers newCustomer = (Models.customers)clientCmb.SelectedItem;
                Models.users     newUser     = (Models.users)userCmb.SelectedItem;
                newService.id_customer = newCustomer.id_customer;
                if (thirdPArty_serviceCmb.IsChecked == true)
                {
                    Models.brands newBrand = (Models.brands)brandCmb.SelectedItem;
                    newService.id_brand           = newBrand.id_brand;
                    newService.is_warranty        = true;
                    newService.purchase_date      = purchase_dateDatePicker.DisplayDate;
                    newService.commercial_invoice = commercial_invoiceTextBox.Text;
                }
                else
                {
                    newService.is_warranty = false;
                }
                newService.unique_reference   = unique_referenceTextBox.Text;
                newService.model              = modelTextBox.Text;
                newService.technical_operator = newUser.id_user;
                newService.in_date            = in_dateDatePicker.DisplayDate;
                context.services.Add(newService);
                context.SaveChanges();
                disableAll();
                mainw.Succesful("service");
                lblNotification.Content    = "Nuevo servicio registrado correctamente";
                lblNotification.Visibility = Visibility.Visible;
            }
        }
コード例 #4
0
        private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
        {
            if (thirdPArty_serviceCmb.IsChecked == true)
            {
                if (clientCmb.SelectedItem == null || brandCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || string.IsNullOrEmpty(commercial_invoiceTextBox.Text) || purchase_dateDatePicker.DisplayDate.ToString() == "" || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString()))
                {
                    MessageBox.Show("Los campos cliente, marca, imei o serie, factura, fecha de compra, tecnico encargado y fecha de entrada no deben ser nulas");
                    return;
                }
            }
            else
            {
                if (clientCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString()))
                {
                    MessageBox.Show("Los campos cliente, imei o serie, tecnico encargado y fecha de entrada no deben estar vacios");
                    return;
                }
            }

            var mservice = new Models.services {
                id_service = service.id_service
            };

            using (var context = new Models.solutecEntities())
            {
                Models.customers newCustomer = (Models.customers)clientCmb.SelectedItem;
                Models.users     newUser     = (Models.users)userCmb.SelectedItem;
                context.services.Attach(mservice);
                if (thirdPArty_serviceCmb.IsChecked == true)
                {
                    Models.brands newBrand = (Models.brands)brandCmb.SelectedItem;
                    mservice.id_brand           = newBrand.id_brand;
                    mservice.is_warranty        = true;
                    mservice.purchase_date      = purchase_dateDatePicker.DisplayDate;
                    mservice.commercial_invoice = commercial_invoiceTextBox.Text;
                }
                else
                {
                    mservice.is_warranty = false;
                }
                mservice.unique_reference   = unique_referenceTextBox.Text;
                mservice.model              = modelTextBox.Text;
                mservice.technical_operator = newUser.id_user;
                mservice.in_date            = in_dateDatePicker.DisplayDate;
                context.Configuration.ValidateOnSaveEnabled = false;
                context.SaveChanges();
            }
            mainw.Succesful("service");
        }
コード例 #5
0
        public ActionResult register(Models.users user)
        {
            SqlConnectionStringBuilder constr = new SqlConnectionStringBuilder("Data Source=DESKTOP-N9AAJ82\\SKERDI;Initial Catalog=KEMBIM_VALUTOR;Integrated Security=True");
            string qrstr = "insert into users (username, password, name, surname, email, type) values('" + user.Username + "','" + user.Password + "','" + user.Name + "','" + user.Surname + "','" + user.Email + "','U')";

            using (SqlConnection con = new SqlConnection(constr.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(qrstr, con);
                con.Open();
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    ViewBag.Ex = ex;
                }
                con.Close();
                return(View("../Account/login"));
            }
        }
コード例 #6
0
        public ActionResult login(Models.users user)
        {
            SqlConnectionStringBuilder constr = new SqlConnectionStringBuilder("Data Source=DESKTOP-N9AAJ82\\SKERDI;Initial Catalog=KEMBIM_VALUTOR;Integrated Security=True");
            string qrstr = "select user_id from users where username = '******' and password = '******'";

            using (SqlConnection con = new SqlConnection(constr.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(qrstr, con);

                con.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    if (reader.HasRows)
                    {
                        Session["user_id"] = int.Parse(reader[0].ToString());

                        reader.Close();
                        string     qrstrwl = "insert into wallet(user_id) values('" + Session["user_id"] + "')";
                        SqlCommand cmdw    = new SqlCommand(qrstrwl, con);
                        try
                        {
                            cmdw.ExecuteNonQuery();
                        }
                        catch (Exception)
                        { }

                        return(RedirectToAction("../Home/Index"));
                    }
                    else
                    {
                        //e ndryshoj m vone
                        reader.Close();
                        ViewBag.valMsg = "Your username or password is incorrect";
                        return(View());
                    }
                }
            }
        }
コード例 #7
0
        private void SaveCommandHandler(Object sender, ExecutedRoutedEventArgs e)
        {
            if (userTextBox.Text == "" || password.Password == "")
            {
                MessageBox.Show("Los campos usuario y contraseña no deben estar vacios");
                return;
            }

            try
            {
                using (Models.solutecEntities context = new Models.solutecEntities())
                {
                    Models.users newUser = new Models.users();
                    newUser.user      = userTextBox.Text;
                    newUser.is_active = true;
                    newUser.password  = mainw.GetSHA1(password.Password);
                    short user_type = 0;
                    switch (user_typeComboBox.Text)
                    {
                    case "Administrador":
                        user_type = 1;

                        break;

                    case "Atencion al cliente":
                        user_type = 2;
                        break;

                    case "Tecnico":
                        user_type = 3;
                        break;

                    default:
                        user_type = 1;
                        break;
                    }
                    newUser.user_type = user_type;
                    context.users.Add(newUser);
                    context.SaveChanges();
                    lblNotification.Content     = "Usuario registrado correctamente";
                    notification.Visibility     = Visibility.Visible;
                    userTextBox.IsEnabled       = false;
                    password.IsEnabled          = false;
                    user_typeComboBox.IsEnabled = false;
                    btnSave.IsEnabled           = false;

                    mainw.Succesful("user");
                }
            }
            catch (DbEntityValidationException i)
            {
                foreach (var eve in i.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
コード例 #8
0
        public ActionResult userdetails()
        {
            if (Session["user_id"] != null)
            {
                Models.users user = new Models.users();
                SqlConnectionStringBuilder constr = new SqlConnectionStringBuilder("Data Source=DESKTOP-N9AAJ82\\SKERDI;Initial Catalog=KEMBIM_VALUTOR;Integrated Security=True");
                string qrstr = "select name,surname,username,birthday,email,password from users where user_id = '" + Session["user_id"] + "'";
                using (SqlConnection con = new SqlConnection(constr.ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand(qrstr, con);
                    con.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        reader.Read();
                        try
                        {
                            user.Name = (string)reader[0];
                        }
                        catch (Exception)
                        { }
                        try
                        {
                            user.Surname = (string)reader[1];
                        }
                        catch (Exception)
                        { }
                        try
                        {
                            user.Username = (string)reader[2];
                        }
                        catch (Exception)
                        { }
                        try
                        {
                            user.Birthday = (string)reader[3];
                        }
                        catch (Exception) { }

                        try
                        {
                            user.Email = (string)reader[4];
                        }
                        catch (Exception)
                        { }

                        reader.Close();
                    }


                    //------------------------------------Favorites------------------------------------------------------------------------

                    List <Models.rates> ratesf = new List <Models.rates>();
                    string     qrFavStr        = "SELECT RATES.RATE_ID AS rate_id,CURR1 AS curr1,CURR2 AS curr2,RATE AS rate FROM RATES INNER JOIN FAVORITES ON RATES.RATE_ID = FAVORITES.RATE_ID WHERE USER_ID = '" + Session["user_id"] + "'";
                    SqlCommand cmdFav          = new SqlCommand(qrFavStr, con);
                    using (SqlDataReader readerf = cmdFav.ExecuteReader(System.Data.CommandBehavior.SingleResult))
                    {
                        while (readerf.Read())
                        {
                            Models.rates ratef = new Models.rates();

                            ratef.RateId = (int)readerf["rate_id"];
                            ratef.Curr1  = (string)readerf["curr1"];
                            ratef.Curr2  = (string)readerf["curr2"];
                            ratef.Rate   = (double)readerf["rate"];
                            ratesf.Add(ratef);
                        }
                    }
                    ViewBag.fav = ratesf;
                }
                return(View("userdetails", user));
            }
            return(RedirectToAction("../Home/Index"));
        }
コード例 #9
0
 public static bool setLoginSession(Models.users entity)
 {
     HttpContext.Current.Session.Timeout = 360;//会话时间 单位分钟 6小时
     HttpContext.Current.Session[globalValue.SESSION_ADMIN_LOGININFO] = entity;
     return(isLogin);
 }