Пример #1
0
        protected void GridViewInvoices_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            string query = "select main.Name, reciever.Name, Issue_date, Due_date, Payment_Method.Name from Invoices " +
                           "inner join Contractors as main on main.Id = Id_contractor left join Contractors as reciever on reciever.Id = Id_receiver " +
                           "inner join Payment_Method on Id_payment = Payment_Method.Id where Invoices.Id =" + GridViewInvoices.DataKeys[GridViewInvoices.SelectedIndex].Value.ToString();
            SqlDataReader reader = BaseConnection.execReader(query);

            while (reader.Read())
            {
                LabelContractor.Text = reader.GetString(0);
                if (!reader.IsDBNull(1))
                {
                    LabelReciever.Text = reader.GetString(1);
                }
                LabelIssueDate.Text = reader.GetDateTime(2).ToShortDateString();
                LabelDueDate.Text   = reader.GetDateTime(3).ToShortDateString();
                LabelPayment.Text   = reader.GetString(4);
            }

            BaseConnection.closeConnection();

            LabelTitle.Text = (GridViewInvoices.Rows[GridViewInvoices.SelectedIndex].Cells[2].Controls[1] as Label).Text;

            SqlDataSourceProducts.SelectCommand = "select Products.Name,Units.Name, Tax_rates.Name,Tax_rates.Value, Amount, Price from Invoice_Products " +
                                                  "inner join Tax_rates on Id_tax = Tax_rates.Id inner join Products on Id_product = Products.Id " +
                                                  "inner join Units on Products.Id_unit = Units.Id where Id_invoice=" + GridViewInvoices.DataKeys[GridViewInvoices.SelectedIndex].Value.ToString();
            ClientScript.RegisterStartupScript(this.GetType(), "Popup", "showInfo();", true);
        }
        protected void GridViewContractors_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }
            var query =
                "select Name,Post_town,Post_code, City, Street, NIP, REGON, PESEL from Contractors where Id = " + GridViewContractors.DataKeys[GridViewContractors.SelectedIndex].Value;
            var reader = BaseConnection.execReader(query);

            while (reader.Read())
            {
                LabelName.Text     = LabelTitle.Text = reader.GetString(0);
                LabelPostTown.Text = reader.GetString(1);
                LabelPostCode.Text = reader.GetString(2);
                LabelCity.Text     = reader.GetString(3);
                LabelStreet.Text   = reader.GetString(4);
                if (!reader.IsDBNull(5))
                {
                    LabelNIP.Text = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    LabelREGON.Text = reader.GetString(6);
                }
            }
            BaseConnection.closeConnection();

            if (!string.IsNullOrEmpty(LabelNIP.Text))
            {
                var gus = GusApiHelper.DataSearchSubjects(LabelNIP.Text);
                var mf  = MfApiHelper.SearchNip(LabelNIP.Text);
                if (gus == null || mf == null)
                {
                    ButtonDetails.Enabled = false;
                }
                else
                {
                    ButtonDetails.Enabled = true;
                }
            }
            else
            {
                ButtonDetails.Enabled = false;
            }



            ClientScript.RegisterStartupScript(GetType(), "Popup", "showInfo();", true);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];

            if (string.IsNullOrEmpty(id))
            {
                Response.Redirect("Default.aspx");
            }

            if (IsPostBack)
            {
                return;
            }

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

            string        query  = "select Name,Post_town,Post_code, City, Street, NIP, REGON, PESEL from Contractors where Id = " + id;
            SqlDataReader reader = BaseConnection.execReader(query);



            while (reader.Read())
            {
                TextBoxName.Text     = reader.GetString(0);
                TextBoxPostTown.Text = reader.GetString(1);
                TextBoxPostCode.Text = reader.GetString(2);
                TextBoxCity.Text     = reader.GetString(3);
                TextBoxStreet.Text   = reader.GetString(4);
                if (!reader.IsDBNull(5))
                {
                    TextBoxNIP.Text = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    TextBoxREGON.Text = reader.GetString(6);
                }
            }

            BaseConnection.closeConnection();
        }
Пример #4
0
        private void loadCompanyDetail()
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            List <string> list = new List <string>();

            string        query  = "SELECT [Name], [Post_town], [Post_code], [City], [Street], [NIP], [REGON], [Bank], [Bank_account] FROM [User_Detail] WHERE ([Id_user] =" + Session["User"] + ")";
            SqlDataReader reader = BaseConnection.execReader(query);

            while (reader.Read())
            {
                LabelName.Text     = reader.GetString(0);
                LabelPostTown.Text = reader.GetString(1);
                LabelPostCode.Text = reader.GetString(2);
                LabelCity.Text     = reader.GetString(3);
                LabelStreet.Text   = reader.GetString(4);
                if (!reader.IsDBNull(5))
                {
                    LabelNIP.Text = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    LabelREGON.Text = reader.GetString(6);
                }
                LabelBank.Text        = reader.GetString(7);
                LabelBankAccount.Text = reader.GetString(8);

                /*for (int i = 0; i < reader.FieldCount; ++i)
                 * {
                 *      System.Diagnostics.Debug.WriteLine(reader.GetString(i));
                 * }*/
            }
            BaseConnection.closeConnection();
        }
Пример #5
0
        public void head()
        {
            string issueDate = "", dueDate = "", type = "Oryginał";

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

            string query = "select Issue_date, Due_date , Payment_Method.Name from Invoices " +
                           "inner join Payment_Method on Invoices.Id_payment = Payment_Method.Id where Invoices.Id=" + _idInvoice;

            type = "Oryginał";
            SqlDataReader reader = BaseConnection.execReader(query);

            while (reader.Read())
            {
                issueDate = reader.GetDateTime(0).ToShortDateString();
                dueDate   = reader.GetDateTime(1).ToShortDateString();
                _payment  = reader.GetString(2);
            }


            BaseConnection.closeConnection();



            _writer.AddAttribute(HtmlTextWriterAttribute.Class, "row");
            _writer.AddAttribute(HtmlTextWriterAttribute.Class, "h-25");
            _writer.RenderBeginTag(HtmlTextWriterTag.Div);             // open div row h-25
            {
                _writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-6");
                _writer.RenderBeginTag(HtmlTextWriterTag.Div);                 // open div col-6
                {
                    _writer.AddAttribute(HtmlTextWriterAttribute.Style, "width: 50%; height: 90%");
                    //_writer.AddAttribute(HtmlTextWriterAttribute.Class, "p-2");
                    //_writer.AddAttribute(HtmlTextWriterAttribute.Src, "file:\\" + HttpContext.Current.Server.MapPath( "Images/Logo.jpg"));
                    //_writer.AddAttribute(HtmlTextWriterAttribute.Src, IronPdf.Util.ImageToDataUri(System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("Images/Logo.jpg"))));
                    _writer.RenderBeginTag(HtmlTextWriterTag.Img);                     // img logo
                    _writer.RenderEndTag();
                }
                _writer.RenderEndTag();                 // close  div col-6

                _writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-6");
                _writer.RenderBeginTag(HtmlTextWriterTag.Div);                 // open div col-6
                {
                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "table");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Table);                     // open table
                    {
                        _writer.RenderBeginTag(HtmlTextWriterTag.Tbody);                 // open tbody
                        {
                            _writer.RenderBeginTag(HtmlTextWriterTag.Tr);                //open tr
                            {
                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);            //Invoice
                                _writer.Write("Faktura");
                                _writer.RenderEndTag();

                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);                                   // Invoice nr
                                _writer.Write(_nr);
                                _writer.RenderEndTag();
                            }
                            _writer.RenderEndTag();                             // close tr
                            _writer.RenderBeginTag(HtmlTextWriterTag.Tr);       //open tr
                            {
                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);   //Issue date
                                _writer.Write("Data wystawienia:");
                                _writer.RenderEndTag();

                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                _writer.Write(issueDate);
                                _writer.RenderEndTag();
                            }
                            _writer.RenderEndTag();                             // close tr
                            _writer.RenderBeginTag(HtmlTextWriterTag.Tr);       //open tr
                            {
                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);   //Due date
                                _writer.Write("Termin zapłaty:");
                                _writer.RenderEndTag();

                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                _writer.Write(dueDate);
                                _writer.RenderEndTag();
                            }
                            _writer.RenderEndTag();                             // close tr
                            _writer.RenderBeginTag(HtmlTextWriterTag.Tr);       //open tr
                            {
                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);   //Payment
                                _writer.Write("Metoda płatności:");
                                _writer.RenderEndTag();

                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                _writer.Write(_payment);
                                _writer.RenderEndTag();
                            }
                            _writer.RenderEndTag();                             // close tr
                            _writer.RenderBeginTag(HtmlTextWriterTag.Tr);       //open tr
                            {
                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);   //Payment
                                _writer.Write("Typ dokumentu:");
                                _writer.RenderEndTag();

                                _writer.RenderBeginTag(HtmlTextWriterTag.Td);
                                _writer.Write(type);
                                _writer.RenderEndTag();
                            }
                            _writer.RenderEndTag();                                                                    // close tr
                        }
                        _writer.RenderEndTag();                                                                        //close tbody
                    }
                    _writer.RenderEndTag();                                                                            //close table
                }
                _writer.RenderEndTag();                                                                                // close  div col-6
            }
            _writer.RenderEndTag();                                                                                    // close  div row h-25

            _writer.AddAttribute(HtmlTextWriterAttribute.Style, "color: black; height: 2px; background-color:black;"); //hr
            _writer.RenderBeginTag(HtmlTextWriterTag.Hr);
            _writer.RenderEndTag();
            _writer.RenderBeginTag(HtmlTextWriterTag.Br);             //br
            _writer.RenderEndTag();
        }
Пример #6
0
        public void products()
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }


            string query = "select Products.Name, Units.Name, Invoice_Products.Amount, Tax_rates.Name, Tax_rates.Value, Invoice_Products.Price " +
                           "from Invoice_Products inner join Invoices on Invoice_Products.Id_invoice = Invoices.Id " +
                           "inner join Products on Invoice_Products.Id_product = Products.Id " +
                           "inner join Units on Units.Id = Products.Id_unit inner join Tax_rates on Tax_rates.Id = Invoice_Products.Id_tax " +
                           "where Invoices.Id = " + _idInvoice;


            decimal           sum          = 0;
            List <ProductRow> productsList = new List <ProductRow>();
            SqlDataReader     reader       = BaseConnection.execReader(query);

            while (reader.Read())
            {
                ProductRow productRow = new ProductRow();
                productRow.name         = reader.GetString(0);
                productRow.unit         = reader.GetString(1);
                productRow.amount       = reader.GetInt32(2);
                productRow.taxRate      = reader.GetString(3);
                productRow.taxRateValue = reader.GetDecimal(4);
                productRow.price        = reader.GetDecimal(5);
                productsList.Add(productRow);
            }


            BaseConnection.closeConnection();


            _writer.AddAttribute(HtmlTextWriterAttribute.Class, "table");
            _writer.RenderBeginTag(HtmlTextWriterTag.Table);             // open table
            {
                _writer.AddAttribute(HtmlTextWriterAttribute.Class, "thead-dark");
                _writer.RenderBeginTag(HtmlTextWriterTag.Thead);                 // open thead
                {
                    _writer.RenderBeginTag(HtmlTextWriterTag.Tr);                //open tr
                    {
                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Product
                        _writer.Write("Produkt");
                        _writer.RenderEndTag();

                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Unit
                        _writer.Write("Jedn.");
                        _writer.RenderEndTag();

                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Amount
                        _writer.Write("Ilość");
                        _writer.RenderEndTag();

                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Vat
                        _writer.Write("Stawka");
                        _writer.RenderEndTag();

                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Price netto
                        _writer.Write("Cena netto");
                        _writer.RenderEndTag();

                        _writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Th);                           //Price brutto
                        _writer.Write("Cena brutto");
                        _writer.RenderEndTag();
                    }
                    _writer.RenderEndTag();                      // close tr
                }
                _writer.RenderEndTag();                          //close thead

                _writer.RenderBeginTag(HtmlTextWriterTag.Tbody); // open tbody
                {
                    foreach (var ele in productsList)
                    {
                        _writer.RenderBeginTag(HtmlTextWriterTag.Tr);                         //open tr
                        {
                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                     // Product
                            _writer.Write(ele.name);
                            _writer.RenderEndTag();

                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                               // Unit
                            _writer.Write(ele.unit);
                            _writer.RenderEndTag();

                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                               // Amount
                            _writer.Write(ele.amount);
                            _writer.RenderEndTag();

                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                               // VAT
                            _writer.Write(ele.taxRate);
                            _writer.RenderEndTag();

                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                               // Price netto
                            _writer.Write(ele.price.ToString("0.##"));
                            _writer.RenderEndTag();

                            decimal brutto = Math.Round(ele.price * (ele.taxRateValue + 1), 2);
                            sum += (brutto * ele.amount);
                            _writer.RenderBeginTag(HtmlTextWriterTag.Td);                               // Price brutto
                            _writer.Write(brutto);
                            _writer.RenderEndTag();
                        }
                        _writer.RenderEndTag();                         // close tr
                    }
                }
                _writer.RenderEndTag();         //close tbody
            }
            _writer.RenderEndTag();             //close table

            _writer.AddAttribute(HtmlTextWriterAttribute.Class, "text-right w-100 font-weight-bold bg-light");
            _writer.RenderBeginTag(HtmlTextWriterTag.H3); //open h3
            _writer.Write("Razem do zapłaty (brutto): " + sum + " zł");
            _writer.RenderEndTag();                       //close h3
        }
Пример #7
0
        public void persons()
        {
            if (!BaseConnection.openConnection())
            {
                return;
            }

            string query = "select * from User_Detail where Id_user ="******"", postTown = "", postCode = "", city = "", street = "", nip = "", regon = "", bank = "", bankAccount = "";
            SqlDataReader reader = BaseConnection.execReader(query);

            while (reader.Read())
            {
                id       = reader.GetInt32(0);
                name     = reader.GetString(1);
                postTown = reader.GetString(2);
                postCode = reader.GetString(3);
                city     = reader.GetString(4);
                street   = reader.GetString(5);
                if (!reader.IsDBNull(6))
                {
                    nip = reader.GetString(6);
                }
                if (!reader.IsDBNull(7))
                {
                    regon = reader.GetString(7);
                }
                if (!reader.IsDBNull(8))
                {
                    bank = reader.GetString(8);
                }
                if (!reader.IsDBNull(9))
                {
                    bankAccount = reader.GetString(9);
                }
            }
            reader.Close();
            BaseConnection.closeConnection();



            _writer.AddAttribute(HtmlTextWriterAttribute.Class, "row h-auto align-items-center");
            _writer.RenderBeginTag(HtmlTextWriterTag.Div);             // open div row h-auto align-items-center
            {
                _writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-6");
                _writer.RenderBeginTag(HtmlTextWriterTag.Div);                 // open div col-6 seller
                {
                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // title
                    _writer.Write("Sprzedawca:");
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // name
                    _writer.Write(name);
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // address
                    _writer.Write(city + " " + street);
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // post
                    _writer.Write(postCode + " " + postTown);
                    _writer.RenderEndTag();

                    if (nip != "")
                    {
                        _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Div);                         // nip
                        _writer.Write("NIP: " + nip);
                        _writer.RenderEndTag();
                    }

                    if ((_payment == "Przelew") && (bank != "") && (bankAccount != ""))
                    {
                        _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Div);                         // bank
                        _writer.Write(bank + " " + bankAccount);
                        _writer.RenderEndTag();
                    }
                }
                _writer.RenderEndTag();                 // close div col-6 seller

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

                query = "select Contractors.* from Contractors inner join Invoices on Contractors.Id=Invoices.Id_contractor where Invoices.Id =" + _idInvoice;
                string pesel = "";
                reader = BaseConnection.execReader(query);
                while (reader.Read())
                {
                    id       = reader.GetInt32(0);
                    id       = reader.GetInt32(1);
                    name     = reader.GetString(2);
                    postTown = reader.GetString(3);
                    postCode = reader.GetString(4);
                    city     = reader.GetString(5);
                    street   = reader.GetString(6);
                    if (!reader.IsDBNull(7))
                    {
                        nip = reader.GetString(7);
                    }
                    if (!reader.IsDBNull(8))
                    {
                        regon = reader.GetString(8);
                    }
                    if (!reader.IsDBNull(9))
                    {
                        pesel = reader.GetString(9);
                    }
                }

                BaseConnection.closeConnection();


                _writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-6");
                _writer.RenderBeginTag(HtmlTextWriterTag.Div);                 // open div col-6 buyer
                {
                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // title
                    _writer.Write("Kupujący:");
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // name
                    _writer.Write(name);
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // address
                    _writer.Write(city + " " + street);
                    _writer.RenderEndTag();

                    _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                    _writer.RenderBeginTag(HtmlTextWriterTag.Div);                     // post
                    _writer.Write(postCode + " " + postTown);
                    _writer.RenderEndTag();

                    if (nip != "")
                    {
                        _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Div);                         // nip
                        _writer.Write("NIP: " + nip);
                        _writer.RenderEndTag();
                    }

                    if (pesel != "")
                    {
                        _writer.AddAttribute(HtmlTextWriterAttribute.Class, "mt-2");
                        _writer.RenderBeginTag(HtmlTextWriterTag.Div);                         // pesel
                        _writer.Write("PESEL: " + pesel);
                        _writer.RenderEndTag();
                    }
                }
                _writer.RenderEndTag();                                                                                // close div col-6 buyer
            }
            _writer.RenderEndTag();                                                                                    // close div row h-auto align-items-center

            _writer.AddAttribute(HtmlTextWriterAttribute.Style, "color: black; height: 2px; background-color:black;"); //hr
            _writer.RenderBeginTag(HtmlTextWriterTag.Hr);
            _writer.RenderEndTag();
            _writer.RenderBeginTag(HtmlTextWriterTag.Br);             //br
            _writer.RenderEndTag();
        }