コード例 #1
0
ファイル: Dashboard.cs プロジェクト: aliyura/smartsales_v1-
        private void  InitilizeCurrentUser()
        {
            if (service.isConnencted())
            {
                System.Drawing.Drawing2D.GraphicsPath gp1 = new System.Drawing.Drawing2D.GraphicsPath();
                gp1.AddEllipse(0, 0, userProfilePicture1.Width - 3, userProfilePicture1.Height - 3);
                Region rg1 = new Region(gp1);
                userProfilePicture1.Region = rg1;


                System.Drawing.Drawing2D.GraphicsPath gp2 = new System.Drawing.Drawing2D.GraphicsPath();
                gp2.AddEllipse(0, 0, userProfilePicture1.Width + 60, userProfilePicture1.Height + 60);
                Region rg2 = new Region(gp2);
                userProfilePicture2.Region = rg2;



                try
                {
                    User session = app.getSession();
                    if (session.name.Contains(" "))
                    {
                        usernameLabel1.Text = session.name.Substring(0, session.name.IndexOf(" "));
                        usernameLabel2.Text = session.name.Substring(0, session.name.IndexOf(" "));
                    }
                    else
                    {
                        usernameLabel1.Text = session.name;
                        usernameLabel2.Text = session.name;
                    }

                    User user = getService.getUserByUsername(session.username);
                    if (user.picture != null && user.picture.Length > 0)
                    {
                        userProfilePicture1.Image = app.byteArrayToImage(user.picture);
                        userProfilePicture2.Image = app.byteArrayToImage(user.picture);
                    }
                }
                catch (Exception ex)
                {
                    app.showWarning(ex.Message);
                }
            }
            else
            {
                app.showWarning("Oops! Unable to connect to the database");
            }
        }
コード例 #2
0
        public int addUser(User user)
        {
            SSGetService getService = new SSGetService();

            User numberCheck   = getService.getUserByMobileNumber(user.mobile_number);
            User usernameCheck = getService.getUserByUsername(user.username);

            if (usernameCheck.username == null)
            {
                if (numberCheck.mobile_number == null)
                {
                    using (SqlCommand command = new SqlCommand("INSERT INTO ss_users(bid,name, username, password, mobile_number,picture)VALUES(@bid,@name,@username,@password, @mobile_number,@picture)"))
                    {
                        command.Parameters.AddWithValue("@bid", user.bid);
                        command.Parameters.AddWithValue("@name", user.name);
                        command.Parameters.AddWithValue("@username", user.username);
                        command.Parameters.AddWithValue("@password", user.password);
                        command.Parameters.AddWithValue("@mobile_number", user.mobile_number);
                        if (user.picture != null)
                        {
                            command.Parameters.Add("@picture", SqlDbType.Image, user.picture.Length).Value = user.picture;
                        }


                        int response = service.execute(command);
                        if (response > 0)
                        {
                            this.addLog(new Log()
                            {
                                type        = "Add User",
                                statement   = command.CommandText,
                                description = "Created user " + user.name,
                            });
                        }

                        return(response);
                    }
                }
                else
                {
                    return(-3);
                }
            }
            else
            {
                return(-2);
            }
        }