示例#1
0
        private void simpleButton6_Click(object sender, EventArgs e)
        {
            var name        = label47.Text;
            var phonenumber = _u.GetCustomerByEmail(_beforeMail).Rows[0][6].ToString();
            var price       = int.Parse(label36.Text);

            _productNumber = 0;
            var userName = _u.GetCustomerByEmail(_beforeMail).Rows[0][1] + " " +
                           _u.GetCustomerByEmail(_beforeMail).Rows[0][2].ToString();
            var userId = int.Parse(_u.GetCustomerByEmail(_beforeMail).Rows[0][0].ToString());
            var date   = DateTime.Today.ToString();

            if (_cc.GetByName(phonenumber, name).Rows.Count > 0)
            {
                var piece = int.Parse(_cc.GetByName(phonenumber, name).Rows[0][2].ToString());
                _cc.UpdatePiece(piece + 1, name, phonenumber);
                _order.UpdatePiece(piece + 1, name, userId);
            }
            else
            {
                _cc.Add(name, 1, phonenumber, price, "Computers");
                _order.Add(name, 1, price, phonenumber, "Not entered", "On Cart", "Computers", userName, userId, date);
            }

            GetNumberProduct(phonenumber);
            alert = new Alert();
            alert.Show();
            try
            {
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == dataGridView1.Columns.Count - 1 && e.RowIndex >= 0)
                {
                    var name        = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    var phonenumber = u.GetCustomerByEmail(mail).Rows[0][6].ToString();
                    var userId      = int.Parse(u.GetCustomerByEmail(mail).Rows[0][0].ToString());

                    if (cc.GetByName(phonenumber, name).Rows.Count > 0)
                    {
                        var piece = int.Parse(cc.GetByName(phonenumber, name).Rows[0][2].ToString());
                        if (piece > 1)
                        {
                            cc.UpdatePiece(piece - 1, name, phonenumber);
                            order.UpdatePiece(piece - 1, name, userId);
                        }
                        else
                        {
                            cc.Delete(phonenumber, name);
                            order.Delete(userId, name);
                        }
                    }

                    Payment_Load(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }