public void ButtonSave_Click(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            string command = "select * from (select Name from Contractors inner join Users on Contractors.Id_User = Users.id where Users.id ="
                             + Session["User"] + ") as tabelka where tabelka.Name = '" + TextBoxName.Text + "'; ";

            // check if already added
            if (BaseConnection.execScalar(command) != null)
            {
                BaseConnection.closeConnection();
                string title = "Błąd";
                string body  = "Kontrahent o takiej nazwie już isnieje!";
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "showModalError('" + title + "', '" + body + "');", true);
                return;
            }

            Dictionary <string, string> pair = new Dictionary <string, string>();

            pair.Add("@userId", Session["User"].ToString());
            pair.Add("@name", TextBoxName.Text);
            pair.Add("@postTown", TextBoxPostTown.Text);
            pair.Add("@postCode", TextBoxPostCode.Text);
            pair.Add("@city", TextBoxCity.Text);
            pair.Add("@street", TextBoxStreet.Text);
            if (!String.IsNullOrEmpty(TextBoxNIP.Text))
            {
                pair.Add("@nip", TextBoxNIP.Text);
            }
            else
            {
                pair.Add("@nip", "null");
            }
            pair.Add("@regon", "null");
            if (!String.IsNullOrEmpty(TextBoxPESEL.Text))
            {
                pair.Add("@pesel", TextBoxPESEL.Text);
            }
            else
            {
                pair.Add("@pesel", "null");
            }

            BaseConnection.execProcedure("AddContractor", pair);

            BaseConnection.closeConnection();

            Response.Redirect("Contractors.aspx");
        }
예제 #2
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            string id = Request.QueryString["id"];

            Dictionary <string, string> pair = new Dictionary <string, string>();

            pair.Add("@userId", id);
            pair.Add("@name", TextBoxName.Text);
            pair.Add("@postTown", TextBoxPostTown.Text);
            pair.Add("@postCode", TextBoxPostCode.Text);
            pair.Add("@city", TextBoxCity.Text);
            pair.Add("@street", TextBoxStreet.Text);
            if (!string.IsNullOrEmpty(TextBoxNIP.Text))
            {
                pair.Add("@nip", TextBoxNIP.Text);
            }
            else
            {
                pair.Add("@nip", "null");
            }
            if (!string.IsNullOrEmpty(TextBoxREGON.Text))
            {
                pair.Add("@regon", TextBoxREGON.Text);
            }
            else
            {
                pair.Add("@regon", "null");
            }
            if (!string.IsNullOrEmpty(TextBoxPESEL.Text))
            {
                pair.Add("@pesel", TextBoxPESEL.Text);
            }
            else
            {
                pair.Add("@pesel", "null");
            }

            BaseConnection.execProcedure("EditContractor", pair);

            BaseConnection.closeConnection();

            Response.Redirect("Contractors.aspx");
        }
예제 #3
0
        protected void ButtonLogIn_Click(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                string title = "Błąd";
                string body  = "Błąd serwera. Proszę wrócić później.";
                ClientScript.RegisterStartupScript(
                    GetType(),
                    "Popup",
                    "showModalError('" + title + "', '" + body + "');",
                    true
                    );
                return;
            }
            var para = new Dictionary <string, string>
            {
                {
                    "@e_mail",
                    TextBoxAddres.Text
                },
                {
                    "@password",
                    TextBoxPassword.Text
                }
            };
            var result = new SqlParameter("@result", SqlDbType.NVarChar, 50);

            BaseConnection.execProcedure("LogInUser", para, result);
            BaseConnection.closeConnection();
            Debug.WriteLine((string)result.Value);
            if ((string)result.Value == "null")
            {
                System.Diagnostics.Debug.WriteLine("brak w bazie");
                string title = "Błąd logowania";
                string body  = "Podano błędny adres e-mail lub hasło.";
                ClientScript.RegisterStartupScript(
                    GetType(),
                    "Popup",
                    "showModalError('" + title + "', '" + body + "');",
                    true
                    );
                return;
            }
            Session["User"] = (string)result.Value;
            BaseConnection.closeConnection();
            Response.Redirect("/Default.aspx");
        }