private void deleteContractor(int index)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }
            string query =
                "delete from Contractors where id=" + GridViewContractors.DataKeys[index].Value.ToString();

            BaseConnection.execCommand(query);
            BaseConnection.closeConnection();
            Response.Redirect(Request.RawUrl);
        }
예제 #2
0
        private void deleteInvoice(int index)
        {
            string idInvoice = GridViewInvoices.DataKeys[index].Value.ToString();

            if (!BaseConnection.openConnection())
            {
                return;
            }

            string q1    = "delete from Invoice_Products where Id_invoice=" + idInvoice;
            string q2    = "delete from Invoices where id=" + idInvoice;
            string query = q1 + "; " + q2;

            BaseConnection.execCommand(query);


            BaseConnection.closeConnection();

            Response.Redirect(Request.RawUrl);
        }
예제 #3
0
        protected void ButtonAddProduct_Click(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            string command = "select * from Products where Name='" + TextBoxName.Text + "' and Id_user="******"User"];

            if (BaseConnection.execScalar(command) != null)
            {
                BaseConnection.closeConnection();
                string title = "Błąd";
                string body  = "Taki produkt już istnieje!";
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "showModalError('" + title + "', '" + body + "');", true);

                return;
            }

            command = "insert into Products values (" + Session["User"] + ",'" + TextBoxName.Text + "'," + DropDownListUnit.SelectedValue + " )";

            if ((int)BaseConnection.execCommand(command) == 1)
            {
                LabelError.Text     = "Produkt dodany";
                LabelError.CssClass = "text-success";
                LabelError.Visible  = true;
            }
            else
            {
                LabelError.Text     = "Nie udało się dodać do bazy";
                LabelError.CssClass = "text-danger";
                LabelError.Visible  = true;
            }


            BaseConnection.closeConnection();

            Response.Redirect("Product.aspx");
        }