private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string ProdID;
            string sql;
            string UserID = Login.UserID;

            SqlLite sq = new SqlLite();

            if (DG.SelectedItems.Count == 0)
            {
                return;
            }
            ProdID = ((DataRowView)DG.SelectedItems[0]).Row["ProdID"].ToString();
            //clientID = (int)((DataRowView)DG.SelectedItems[0]).Row["ID"];

            sql = "select OrderState from Orders where UserID = '" + UserID + "' and OrderState = 1";

            if (Convert.ToInt16(sq.GetSingleSet(sql)) == 1)
            {
                check = true;
            }
            else
            {
                check = false;
            }

            if (check == false)
            {
                sql = " Insert Into Orders(OrderID, OrderDate, UserID, OrderState) Select (Select IFNull(Max(OrderID)+1,1) From Orders) OrderID, DATETIME() OrderDate, '" + UserID + "' UserID, 1 OrderState";
                sq.GetSingleSet(sql);
                check = true;
            }

            sql = "Insert Into OrdersD(OrderID, SrcPosID, ProdID, qty) SELECT (SELECT MAX(OrderID) FROM Orders WHERE UserID = '" + UserID + "' AND OrderState = 1) OrderID, (SELECT IFNull(MAX(SrcPosID)+1,1) FROM OrdersD WHERE OrderID = (SELECT MAX(OrderID) FROM Orders WHERE UserID = '" + UserID + "' AND OrderState = 1)) SrcPosID, " + ProdID + " ProdID, 1 qty";
            sq.GetSingleSet(sql);
        }
        private void btnCompleteOrder_Click(object sender, RoutedEventArgs e)
        {
            string  sql;
            string  orderid;
            SqlLite sq = new SqlLite();

            if (Dg1.SelectedItems.Count == 0)
            {
                return;
            }

            orderid = ((DataRowView)Dg1.SelectedItems[0]).Row["OrderId"].ToString();


            sql = "update orders set orderstate = 2 where orderid = " + orderid + "";
            sq.GetSingleSet(sql);
        }
示例#3
0
        //   public static string Email;

        static public bool CheckUser(string email, string PW)
        {
            string  sql;
            SqlLite sq = new SqlLite();



            sql = " select ifnull(UserID,0) as UserID from UsersLogin where email = '" + email + "' and PW = '" + PW + "' ";

            UserID = Convert.ToString(sq.GetSingleSet(sql));

            if (UserID == "")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void btnChangeQty_Click(object sender, RoutedEventArgs e)
        {
            string sql;
            string prodid;
            string orderid;
            string qty;

            SqlLite sq = new SqlLite();

            if (Dg1.SelectedItems.Count == 0)
            {
                return;
            }
            prodid  = ((DataRowView)Dg1.SelectedItems[0]).Row["ProdID"].ToString();
            orderid = ((DataRowView)Dg1.SelectedItems[0]).Row["OrderId"].ToString();
            qty     = ((DataRowView)Dg1.SelectedItems[0]).Row["qty"].ToString();
            //clientID = (int)((DataRowView)DG.SelectedItems[0]).Row["ID"];

            sql = "update ordersd set qty = " + qty + " where prodid = " + prodid + " and orderid = " + orderid + " ";
            sq.GetSingleSet(sql);
        }
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            int NewUserID;

            if (checkFields() == false)
            {
                MessageBox.Show("Поля со * обязательны для заполнения.");
                return;
            }

            if (CheckPassword(txtPW.Password) == "Пароль должен содержать не менее 6 символов!")
            {
                return;
            }


            SqlLite sq = new SqlLite();

            NewUserID = Convert.ToInt16(sq.GetSingleSet("Select ifnull(max(UserID),0)+1 from UsersLogin"));

            sq.Create("UsersLogin", Convert.ToString(NewUserID) + ",'" + txtEmail.Text + "','" + txtPW.Password + "'", "UserID,Email,PW");

            if (txtFio.Text != "" || txtPhone.Text != "")
            {
                sq.Create("Users", Convert.ToString(NewUserID) + ",'" + txtFio.Text + "','" + txtPhone.Text + "'", "UserID,Fio,Phone");
            }


            //  MessageBox.Show("Регистрация прошла успешно, авторизируйтесь в программе.");

            login NW = new login();

            NW.Show();
            NW.txtRegConfirm.Content    = "Регистрация прошла успешно, авторизируйтесь в программе.";
            NW.txtRegConfirm.Visibility = Visibility.Visible;
            this.Close();
        }