示例#1
0
        public TOProduct LoadRecent(TOUser user, int recent)
        {
            TOProduct i = new TOProduct();

            try
            {
                string sql = "select * from tbl_product where product_id = (select (max(product_id)-" + recent + ") from tbl_product) and product_status = true;";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                MySqlDataReader dtreader = cmd.ExecuteReader();

                while (dtreader.Read())    //If there's any data.
                {
                    i.Id         = dtreader.GetInt16("product_id");
                    i.Link       = dtreader.GetString("product_link");
                    i.Name       = dtreader.GetString("product_name");
                    i.Type       = dtreader.GetString("product_type");
                    i.Price      = dtreader.GetDouble("product_price");
                    i.Store      = dtreader.GetString("product_store");
                    i.BuyingDate = dtreader.GetDateTime("product_buyingDate").ToString("dd-MM-yyyy");
                }
                con.Close();
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }

            return(i);
        }
        public ACTProductRegistration(TOUser u, TOProduct p)
        {
            i       = 2;
            product = p;
            //setting textboxes.
            InitializeComponent();
            user            = u;
            txtLink.Text    = p.Link;
            txtPrice.Text   = p.Price.ToString();
            txtProduct.Text = p.Name;
            txtStore.Text   = p.Store;
            txtType.Text    = p.Type;

            //set comboboxes.
            if (product.Priority == 1)
            {
                cbxPriority.SelectedValue = "Muito baixa";
            }
            else if (product.Priority == 2)
            {
                cbxPriority.SelectedValue = "Baixa";
            }
            else if (product.Priority == 3)
            {
                cbxPriority.SelectedValue = "Normal";
            }
            else if (product.Priority == 4)
            {
                cbxPriority.SelectedValue = "Alta";
            }
            else if (product.Priority == 5)
            {
                cbxPriority.SelectedValue = "Muito Alta";
            }

            //setting radioButton.
            if (product.Status == true)
            {
                rdbComprado.IsChecked = true;
            }
            else
            {
                rdbListaDesejo.IsChecked = true;
            }

            //disabling all components.
            txtLink.IsEnabled        = false;
            txtPrice.IsEnabled       = false;
            txtProduct.IsEnabled     = false;
            txtStore.IsEnabled       = false;
            txtType.IsEnabled        = false;
            cbxPriority.IsEnabled    = false;
            rdbComprado.IsEnabled    = false;
            rdbListaDesejo.IsEnabled = false;
            btnRegister.IsEnabled    = false;
            btnEdit.Visibility       = Visibility.Visible;
        }
示例#3
0
        private void lblRecentTitle_3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            TOProduct product = new TOProduct();

            product = DAOProd.Selection(lblRecentTitle_3.Content.ToString());
            ACTProductRegistration pr = new ACTProductRegistration(user, product);

            pr.ShowDialog();
            LoadScreen(user, status);
        }
示例#4
0
 private void tblProduct_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (TableValues(1) != null)
     {
         TOProduct product = new TOProduct();
         product = DAOProd.Selection(TableValues(1));
         ACTProductRegistration pr = new ACTProductRegistration(user, product);
         pr.ShowDialog();
     }
     LoadScreen(user, status);
 }
示例#5
0
 private void btnEdit_Click(object sender, RoutedEventArgs e)
 {
     if (TableValues(1) != null)
     {
         TOProduct product = new TOProduct();
         product = DAOProd.Selection(TableValues(1));
         ACTProductRegistration pr = new ACTProductRegistration(user, product);
         pr.ShowDialog();
         user = pr.ReturnUser;
         LoadScreen(user, status);
     }
 }
示例#6
0
        public bool Registration(TOProduct product, TOUser user)
        {
            bool i = false;

            try
            {
                string sql = @"insert into tbl_product(product_name, product_status, product_type, product_description, product_link, product_store, product_price, product_buyingDate, user_id, priority_id) values(
                    '" + product.Name + "', " + product.Status + ", '" + product.Type + "', '" + product.Description + "', '" + product.Link + "', '" + product.Store + "', " + product.Price + ", '" + product.BuyingDate + "', "
                             + user.Id + ", " + product.Priority + ");";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                cmd.ExecuteNonQuery();

                con.Close();

                string select = "select * from tbl_product where product_name = '" + product.Name + "';";

                con.Open();

                MySqlCommand command = new MySqlCommand(select, con);

                MySqlDataReader dtreader = command.ExecuteReader();

                if (dtreader.Read())//If there's any data.
                {
                    //registration sucessful
                    i = true;
                }
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                con.Close();
            }
            return(i);
        }
示例#7
0
        public bool UpdateDate(TOProduct product, string date)
        {
            bool i = false;

            try
            {
                string sql = @"update tbl_product set product_buyingDate = (REPLACE('" + date + "', '/', '-')) where product_id = " + product.Id + ";";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                cmd.ExecuteNonQuery();

                con.Close();

                string select = "select * from tbl_product where product_id = '" + product.Id + "';";

                con.Open();

                MySqlCommand command = new MySqlCommand(select, con);

                MySqlDataReader dtreader = command.ExecuteReader();

                if (dtreader.Read())//If there's any data.
                {
                    //registration sucessful
                    i = true;
                }
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                con.Close();
            }
            return(i);
        }
示例#8
0
        public bool Update(TOProduct product, TOUser user)
        {
            bool i = false;

            try
            {
                string sql = @"update tbl_product set product_id = " + product.Id + ", product_name = '" + product.Name + "', product_status = " + product.Status + ", product_type = '" + product.Type + "', product_description = '', product_link = '" + product.Link + "', product_store = '" + product.Store + "', product_price = " + product.Price + ", user_id = " + user.Id + ", priority_id = " + product.Priority + " where product_id = " + product.Id + ";";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                cmd.ExecuteNonQuery();

                con.Close();

                string select = "select * from tbl_product where product_id = '" + product.Id + "';";

                con.Open();

                MySqlCommand command = new MySqlCommand(select, con);

                MySqlDataReader dtreader = command.ExecuteReader();

                if (dtreader.Read())//If there's any data.
                {
                    //registration sucessful
                    i = true;
                }
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                con.Close();
            }
            return(i);
        }
示例#9
0
        public List <TOProduct> SearchPrice(TOUser user, bool status, double lowPrice, double highPrice)
        {
            List <TOProduct> i = new List <TOProduct>();

            string sql = @"select * from tbl_product 
            where user_id = " + user.Id + " and product_status = " + status + " and product_price between " + lowPrice + " and " + highPrice + ";";

            try
            {
                con = ConnectionFactory.Connection();

                con.Open();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                MySqlDataReader dtreader = cmd.ExecuteReader();

                while (dtreader.Read())
                {
                    TOProduct p = new TOProduct();

                    p.Id         = dtreader.GetInt16("product_id");
                    p.Type       = dtreader.GetString("product_type");
                    p.Name       = dtreader.GetString("product_name");
                    p.Link       = dtreader.GetString("product_link");
                    p.Store      = dtreader.GetString("product_store");
                    p.Price      = dtreader.GetDouble("product_price");
                    p.BuyingDate = dtreader.GetDateTime("product_buyingDate").ToString("dd-MM-yyyy");

                    i.Add(p);
                }
                con.Close();
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }
            return(i);
        }
示例#10
0
        public TOProduct Selection(string product)
        {
            TOProduct i = new TOProduct();

            try
            {
                MySqlConnection con = null;

                string sql = "select * from tbl_product where product_name = '" + product + "';";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                MySqlDataReader dtreader = cmd.ExecuteReader();

                while (dtreader.Read())//If there's any data.
                {
                    i.Id       = dtreader.GetInt16("product_id");
                    i.Link     = dtreader.GetString("product_link");
                    i.Name     = dtreader.GetString("product_name");
                    i.Type     = dtreader.GetString("product_type");
                    i.Price    = dtreader.GetDouble("product_price");
                    i.Priority = dtreader.GetInt16("priority_id");
                    i.Status   = dtreader.GetBoolean("product_status");
                    i.Store    = dtreader.GetString("product_store");
                }

                con.Close();
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }

            return(i);
        }
示例#11
0
 public ACTBuyingDate(TOProduct product)
 {
     InitializeComponent();
     p = product;
 }
示例#12
0
        public void LoadMenu()
        {
            //load quickmenu informations.
            TOProduct recent_1 = DAOProd.LoadRecent(user, 0);
            TOProduct recent_2 = DAOProd.LoadRecent(user, 1);
            TOProduct recent_3 = DAOProd.LoadRecent(user, 2);

            if (recent_1.Id == 0)
            {
                lblRecentTitle_1.Visibility = Visibility.Hidden;
                price_1.Visibility          = Visibility.Hidden;
                type_1.Visibility           = Visibility.Hidden;
                img_1.Visibility            = Visibility.Hidden;
                separator_1.Visibility      = Visibility.Hidden;
                date_1.Visibility           = Visibility.Hidden;
            }
            else
            {
                recent_transaction.Visibility = Visibility.Hidden;
                lblRecentTitle_1.Content      = recent_1.Name;
                price_1.Content = "- R$" + recent_1.Price;
                type_1.Content  = recent_1.Type;
                date_1.Content  = recent_1.BuyingDate;

                lblRecentTitle_1.Visibility = Visibility.Visible;
                price_1.Visibility          = Visibility.Visible;
                type_1.Visibility           = Visibility.Visible;
                img_1.Visibility            = Visibility.Visible;
                separator_1.Visibility      = Visibility.Visible;
                date_1.Visibility           = Visibility.Visible;

                btnViewTransactions.Visibility = Visibility.Visible;
            }

            if (recent_2.Id == 0)
            {
                lblRecentTitle_2.Visibility = Visibility.Hidden;
                price_2.Visibility          = Visibility.Hidden;
                type_2.Visibility           = Visibility.Hidden;
                img_2.Visibility            = Visibility.Hidden;
                separator_2.Visibility      = Visibility.Hidden;
                date_2.Visibility           = Visibility.Hidden;
            }
            else
            {
                lblRecentTitle_2.Content = recent_2.Name;
                price_2.Content          = "- R$" + recent_2.Price;
                type_2.Content           = recent_2.Type;
                date_2.Content           = recent_2.BuyingDate;

                lblRecentTitle_2.Visibility = Visibility.Visible;
                price_2.Visibility          = Visibility.Visible;
                type_2.Visibility           = Visibility.Visible;
                img_2.Visibility            = Visibility.Visible;
                separator_2.Visibility      = Visibility.Visible;
                date_2.Visibility           = Visibility.Visible;

                btnViewTransactions.Visibility = Visibility.Visible;
            }

            if (recent_3.Id == 0)
            {
                lblRecentTitle_3.Visibility = Visibility.Hidden;
                price_3.Visibility          = Visibility.Hidden;
                type_3.Visibility           = Visibility.Hidden;
                img_3.Visibility            = Visibility.Hidden;
                separator_3.Visibility      = Visibility.Hidden;
                date_3.Visibility           = Visibility.Hidden;
            }
            else
            {
                lblRecentTitle_3.Content = recent_3.Name;
                price_3.Content          = "- R$" + recent_3.Price;
                type_3.Content           = recent_3.Type;
                date_3.Content           = recent_3.BuyingDate;

                lblRecentTitle_3.Visibility = Visibility.Visible;
                price_3.Visibility          = Visibility.Visible;
                type_3.Visibility           = Visibility.Visible;
                img_3.Visibility            = Visibility.Visible;
                separator_3.Visibility      = Visibility.Visible;
                date_3.Visibility           = Visibility.Visible;

                btnViewTransactions.Visibility = Visibility.Visible;
            }

            if (recent_1.Id == 0)
            {
                if (recent_2.Id == 0)
                {
                    if (recent_3.Id == 0)
                    {
                        recent_transaction.Visibility  = Visibility.Visible;
                        btnViewTransactions.Visibility = Visibility.Hidden;
                    }
                }
            }

            lblMoney.Content    = "R$ " + user.CreditAvaliable + ",00";
            lblUserName.Content = user.Name + " " + user.SirName;
            lblEmail.Content    = user.Email;

            //loading configuration information.
            //loading menu configuration
            txtAccount.Text = user.Account;
            txtName.Text    = user.Name;

            ver = txtAccount.Text;

            txtSirName.Text             = user.SirName;
            txtEmail.Text               = user.Email;
            txtPassword.Text            = user.Password;
            txtCurrentCapital.Text      = user.Credit.ToString();
            txtTotalSpentCapital.Text   = user.CreditSpent.ToString();
            psbCurrentPassword.Password = user.Password;
            PasswordStrengh.Value       = (user.verifyPassword(user.Password));
            if (PasswordStrengh.Value <= 25)
            {
                PasswordStrengh.Foreground = Brushes.Red;
            }
            else if (PasswordStrengh.Value <= 50)
            {
                PasswordStrengh.Foreground = Brushes.Yellow;
            }
            else if (PasswordStrengh.Value >= 75)
            {
                PasswordStrengh.Foreground = Brushes.Green;
            }
        }
示例#13
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            if (i == 1)
            {
                if (rdbComprado.IsChecked == true)
                {
                    product.BuyingDate = "0000-00-00 00:00:00";

                    Model.DAO.DAOProduct d = new Model.DAO.DAOProduct();
                    if (d.Registration(product, user))
                    {
                        product = d.Selection(txtProduct.Text.ToString());
                        ACTBuyingDate date = new ACTBuyingDate(product);
                        date.ShowDialog();

                        Model.DAO.DAOUser uDAO = new Model.DAO.DAOUser();

                        user = uDAO.CreditSpent(user, product.Price);
                        user = uDAO.TotalCredit(user);
                        user = uDAO.Update(user);

                        ACTMessages message = new ACTMessages(user, "eBuy", "Produto registrado com sucesso.", 1);
                        message.ShowDialog();

                        this.Close();
                    }
                    else
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Algo errado aconteceu. Por favor, tente novamente mais tarde.", 3);
                        message.ShowDialog();
                    }
                }
                else
                {
                    product.BuyingDate = "0000-00-00 00:00:00";

                    Model.DAO.DAOProduct d = new Model.DAO.DAOProduct();
                    if (d.Registration(product, user))
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Produto registrado com sucesso.", 1);
                        message.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Algo errado aconteceu. Por favor, tente novamente mais tarde.", 3);
                        message.ShowDialog();
                    }
                }
            }
            else
            {
                if (rdbComprado.IsChecked == true)
                {
                    ACTBuyingDate date = new ACTBuyingDate(product);
                    date.ShowDialog();

                    Model.DAO.DAOProduct dPRO = new Model.DAO.DAOProduct();


                    if (dPRO.Update(product, user))
                    {
                        Model.DAO.DAOUser uDAO = new Model.DAO.DAOUser();
                        user = uDAO.CreditSpent(user, product.Price);
                        user = uDAO.TotalCredit(user);
                        user = uDAO.Update(user);


                        ACTMessages message = new ACTMessages(user, "eBuy", "Produto atualizado com sucesso.", 1);
                        message.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Algo errado aconteceu. Por favor, tente novamente mais tarde.", 3);
                        message.ShowDialog();
                    }
                }
                else
                {
                    Model.DAO.DAOProduct dPRO = new Model.DAO.DAOProduct();
                    if (dPRO.Update(product, user))
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Produto atualizado com sucesso.", 1);
                        message.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        ACTMessages message = new ACTMessages(user, "eBuy", "Algo errado aconteceu. Por favor, tente novamente mais tarde.", 3);
                        message.ShowDialog();
                    }
                }
            }
        }
示例#14
0
        public List <TOProduct> LoadProduct(TOUser user, bool status)
        {
            List <TOProduct> i = new List <TOProduct>();

            try
            {
                string sql = "select * from tbl_product where user_id = " + user.Id + " and product_status = " + status + ";";

                con = ConnectionFactory.Connection();

                MySqlCommand cmd = new MySqlCommand(sql, con);

                con.Open();

                MySqlDataReader dtreader = cmd.ExecuteReader();

                if (status == true)
                {
                    while (dtreader.Read())//If there's any data.
                    {
                        TOProduct x = new TOProduct();

                        x.Id         = dtreader.GetInt16("product_id");
                        x.Link       = dtreader.GetString("product_link");
                        x.Name       = dtreader.GetString("product_name");
                        x.Type       = dtreader.GetString("product_type");
                        x.Price      = dtreader.GetDouble("product_price");
                        x.Store      = dtreader.GetString("product_store");
                        x.BuyingDate = dtreader.GetDateTime("product_buyingDate").ToString("dd-MM-yyyy");;

                        i.Add(x);
                    }

                    con.Close();
                }
                else
                {
                    while (dtreader.Read())//If there's any data.
                    {
                        TOProduct x = new TOProduct();

                        x.Id    = dtreader.GetInt16("product_id");
                        x.Link  = dtreader.GetString("product_link");
                        x.Name  = dtreader.GetString("product_name");
                        x.Type  = dtreader.GetString("product_type");
                        x.Price = dtreader.GetDouble("product_price");
                        x.Store = dtreader.GetString("product_store");

                        i.Add(x);
                    }

                    con.Close();
                }
            }
            catch (MySqlException e)
            {
                throw new Exception(e.Message);
            }

            return(i);
        }