Esempio n. 1
0
        public ListOfTotalPercents ReadTotalPercents()
        {
            List <TotalPercent> totalPercentList  = new List <TotalPercent>();
            SqlConnection       connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    "SELECT PERCENT_ID, TICKET_ID FROM [TOTALPERCENTS];",
                    connectToDateBase);
                connectToDateBase.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TotalPercent totalPercent = new TotalPercent(reader.GetInt32(0), reader.GetInt32(1));
                        totalPercentList.Add(totalPercent);
                    }
                }
                reader.Close();
            }
            ListOfTotalPercents totalPercents = new ListOfTotalPercents(totalPercentList);

            return(totalPercents);
        }
Esempio n. 2
0
        private void rpt3_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (StoreName != null)
            {
                xrLabel3.Text = StoreName;
            }

            string _Date = "";

            if (ParamDate.Count == 2)
            {
                _Date = ParamDate[0].date.ToShortDateString() + " to " + ParamDate[1].date.ToShortDateString();
            }
            else
            {
                for (int i = 0; i < ParamDate.Count; i++)
                {
                    _Date += Helpers.ConvertMyDate(ParamDate[i].date) + (i == ParamDate.Count - 1 ? "" : ", ");
                }
            }
            xrLabel2.Text = "Report generated with date range of " + _Date;

            //FindControl("xrLabel21", true).DataBindings.Add("Text", this.DataSource, "Name");
            //FindControl("xrLabel22", true).DataBindings.Add("Text", this.DataSource, "Quantity");
            //FindControl("xrLabel23", true).DataBindings.Add("Text", this.DataSource, "Amount");
            //FindControl("xrLabel24", true).DataBindings.Add("Text", this.DataSource, "Percent", "{0:p}");
            //FindControl("xrLabel25", true).DataBindings.Add("Text", this.DataSource, "Average", "{0:#,##0.00}");

            xrLabel15.DataBindings.Add("Text", this.DataSource, "Name");
            xrLabel16.DataBindings.Add("Text", this.DataSource, "Quantity", "{0:#,##0}");
            xrLabel17.DataBindings.Add("Text", this.DataSource, "Amount", "{0:#,##0.00}");
            xrLabel18.DataBindings.Add("Text", this.DataSource, "Percent", "{0:p}");

            //totals ----------
            XRLabel lblTotalQty = xrLabel10;

            lblTotalQty.Text = TotalQty.ToString("#,##0.00");

            XRLabel lblTotalAmt = xrLabel11;

            lblTotalAmt.Text = TotalAmt.ToString("#,##0.00");

            XRLabel lblTotalPercent = xrLabel14;

            lblTotalPercent.Text = TotalPercent.ToString("#,##0.00");

            //other calculations ----------
            //Discount Total
            XRLabel lblDiscntTotalAmt = xrLabel13;

            lblDiscntTotalAmt.Text = DiscountAmt.ToString("#,##0.00");

            //Net Sales
            XRLabel lblNetSales = xrLabel7;

            lblNetSales.Text = (Convert.ToDouble(lblTotalAmt.Text) - Convert.ToDouble(lblDiscntTotalAmt.Text)).ToString("#,##0.00");
        }
        public void DeleteFromDatabase(TotalPercent totalPercent)
        {
            SqlConnection connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    ("DELETE FROM [TOTAL_PERCENTS] WHERE @PERCENT_ID = PERCENT_ID;"),
                    connectToDateBase);
                command.Connection.Open();
                command.Parameters.AddWithValue("@PERCENT_ID", totalPercent.PercentId);
                command.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        public void UpdateInDatabase(TotalPercent totalPercent)
        {
            SqlConnection connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    "UPDATE [TOTALPERCENTS]" +
                    "SET PERCENT_ID = @PERCENT_ID, FROM [TOTALPERCENTS];",
                    connectToDateBase);
                connectToDateBase.Open();
                command.Parameters.AddWithValue("@PERCENT_ID", totalPercent.PercentId);
                command.ExecuteNonQuery();
            }
        }
Esempio n. 5
0
        public void WriteInDatabase(TotalPercent totalPercent)
        {
            SqlConnection connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    ("INSERT INTO [TOTALPERCENTS] (TICKET_ID, PERCENT_ID)" +
                     "VALUES (@TICKET_ID, @PERCENT_ID);"),
                    connectToDateBase);
                command.Connection.Open();
                command.Parameters.AddWithValue("@TICKET_ID", totalPercent.PercentId);
                command.Parameters.AddWithValue("@PERCENT_ID", totalPercent.TicketId);
                command.ExecuteNonQuery();
            }
        }