Exemplo n.º 1
0
        protected void firstButton_Click(object sender, EventArgs e)
        {
            BookSales bookSales = bookSalesManager.GetBookSales(0);

            GetData(bookSales);
            Session["active"] = 0;
        }
Exemplo n.º 2
0
 public string Save(BookSales bookSales)
 {
     if (bookSalesGateway.Insert(bookSales) > 0)
     {
         return("Saved Successfully!!");
     }
     return("Could Not Save data in Database!!");
 }
Exemplo n.º 3
0
        protected void lastButton_Click(object sender, EventArgs e)
        {
            List <BookSales> bookSalesList = (List <BookSales>)(Session["bookSales"]);
            int       x         = bookSalesList.Count - 1;
            BookSales bookSales = bookSalesManager.GetBookSales(x);

            GetData(bookSales);
            Session["active"] = x;
        }
Exemplo n.º 4
0
        public int Insert(BookSales bookSales)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "INSERT INTO tbl_bookSales VALUES('" + bookSales.Date + "','" + bookSales.DistrictId + "','" +
                                       bookSales.PartyId + "','" + bookSales.MemoNo + "','" + bookSales.SalesType + "','" +
                                       bookSales.Year + "','" + bookSales.GroupId + "','" + bookSales.BookId + "','" +
                                       bookSales.Quantity + "','" + bookSales.SalesRate + "','" + bookSales.Total + "','" + bookSales.Packing + "','" +
                                       bookSales.Bonus + "','" + bookSales.TotalPrice + "','" + bookSales.PaymentAmount + "','" + bookSales.Dues + "')";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
Exemplo n.º 5
0
        protected void searchButton_Click(object sender, EventArgs e)
        {
            var       m         = memoTextBox.Value;
            BookSales bookSales = bookSalesManager.GetSearchInfo(m);

            if (bookSales.MemoNo == null)
            {
                message.InnerText = "Invalid Memo No!!";
                ClearTextBoxes();
            }
            else
            {
                GetData(bookSales);
                message.InnerText = "";
            }
        }
Exemplo n.º 6
0
        protected void previousButton_Click(object sender, EventArgs e)
        {
            int active = (int)Session["active"];

            active--;
            List <BookSales> bookSalesList = (List <BookSales>)(Session["bookSales"]);

            if (active <= -1)
            {
                active = bookSalesList.Count - 1;
            }
            BookSales bookSales = bookSalesManager.GetBookSales(active);

            GetData(bookSales);
            Session["active"] = active;
        }
Exemplo n.º 7
0
        protected void nextButton_Click(object sender, EventArgs e)
        {
            int active = (int)Session["active"];

            active++;
            List <BookSales> bookSalesList = (List <BookSales>)(Session["bookSales"]);

            if (active >= bookSalesList.Count)
            {
                active = 0;
            }
            BookSales bookSales = bookSalesManager.GetBookSales(active);

            GetData(bookSales);
            Session["active"] = active;
        }
Exemplo n.º 8
0
        public BookSales GetSearchInfo(string s)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_bookSales WHERE memo_no='" + s + "'";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            BookSales     bookSales = new BookSales();
            SqlDataReader reader    = command.ExecuteReader();

            while (reader.Read())
            {
                GetValueFromDatabase(bookSales, reader);
            }
            reader.Close();
            connection.Close();
            return(bookSales);
        }
Exemplo n.º 9
0
        public BookSales GetBookSales(int i)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_bookSales ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader    = command.ExecuteReader();
            BookSales     bookSales = new BookSales();

            while (reader.Read())
            {
                GetValueFromDatabase(bookSales, reader);
            }
            reader.Close();
            connection.Close();
            return(bookSales);
        }
Exemplo n.º 10
0
        public BookSales GetNextMemoNo()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT TOP 1 * FROM tbl_bookSales ORDER BY id DESC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader    = command.ExecuteReader();
            BookSales     bookSales = new BookSales();

            while (reader.Read())
            {
                bookSales.BookSalesId = int.Parse(reader["id"].ToString());
                bookSales.MemoNo      = reader["memo_no"].ToString();
            }
            reader.Close();
            connection.Close();
            return(bookSales);
        }
Exemplo n.º 11
0
        private string LoadNextMemoNo()
        {
            BookSales bookSales = bookSalesManager.GetNextMemoNo();
            string    memoNo    = bookSales.MemoNo;
            int       count;

            if (memoNo == null)
            {
                count = 1;
            }
            else
            {
                count = (memoNo[3] - '0') * 10 + (memoNo[4] - '0') + 1;
            }

            string nextMemoNo = "M-0" + count.ToString("00");

            return(nextMemoNo);
        }
Exemplo n.º 12
0
        public List <BookSales> GetAllBookSalesList()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_bookSales";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader    reader        = command.ExecuteReader();
            List <BookSales> bookSalesList = new List <BookSales>();

            while (reader.Read())
            {
                BookSales bookSales = new BookSales();
                GetValueFromDatabase(bookSales, reader);
                bookSalesList.Add(bookSales);
            }
            reader.Close();
            connection.Close();
            return(bookSalesList);
        }
Exemplo n.º 13
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            BookSales bookSales = new BookSales();

            bookSales.Date       = dateTextBox.Value;
            bookSales.DistrictId = int.Parse(districtNameDropDownList.SelectedValue);
            bookSales.PartyId    = int.Parse(partyCodeDropDownList.SelectedValue);
            bookSales.MemoNo     = memoNoTextBox.Text;
            bookSales.SalesType  = salesTypeDropDownList.SelectedValue;
            bookSales.Year       = yearTextBox.Text;
            bookSales.GroupId    = int.Parse(groupNameDropDownList.SelectedValue);
            bookSales.BookId     = int.Parse(bookNameDropDownList.SelectedValue);
            string quantity      = quantityTextBox.Text;
            string saleRate      = saleRateTextBox.Text;
            string total         = totalTextBox.Text;
            string packing       = packingTextBox.Text;
            string bonus         = bonusTextBox.Text;
            string totalPrice    = totalPriceTextBox.Text;
            string paymentAmount = paymentAmountTextBox.Text;
            string dues          = duesTextBox.Text;

            if (dateTextBox.Value == "" || memoNoTextBox.Text == "" || salesTypeDropDownList.Text == "" ||
                yearTextBox.Text == "" || quantityTextBox.Text == "" || saleRateTextBox.Text == "" ||
                packingTextBox.Text == "" || bonusTextBox.Text == "" || paymentAmountTextBox.Text == "")
            {
                messageLabel.InnerText = "All Fields are Required!!";
            }
            else
            {
                bookSales.Quantity      = Convert.ToDouble(quantity);
                bookSales.SalesRate     = Convert.ToDouble(saleRate);
                bookSales.Total         = Convert.ToDouble(total);
                bookSales.Packing       = Convert.ToDouble(packing);
                bookSales.Bonus         = Convert.ToDouble(bonus);
                bookSales.TotalPrice    = Convert.ToDouble(totalPrice);
                bookSales.PaymentAmount = Convert.ToDouble(paymentAmount);
                bookSales.Dues          = Convert.ToDouble(dues);
                messageLabel.InnerText  = bookSalesManager.Save(bookSales);
            }
            ClearTextBoxes();
        }
Exemplo n.º 14
0
 private void GetData(BookSales bookSales)
 {
     dateTextBox.Value             = bookSales.Date;
     districtNameDropDownList.Text = bookSales.DistrictName;
     partyCodeDropDownList.Text    = bookSales.PartyCode;
     memoNoTextBox.Text            = bookSales.MemoNo;
     salesTypeDropDownList.Text    = bookSales.SalesType;
     yearTextBox.Text           = bookSales.Year;
     groupNameDropDownList.Text = bookSales.GroupName;
     bookNameDropDownList.Text  = bookSales.BookId.ToString();
     bookRateTextBox.Text       = bookSales.BookRate.ToString();
     commissionTextBox.Text     = bookSales.Commisssion.ToString();
     saleRateTextBox.Text       = bookSales.SalesRate.ToString();
     quantityTextBox.Text       = bookSales.Quantity.ToString();
     totalTextBox.Text          = bookSales.Total.ToString();
     packingTextBox.Text        = bookSales.Packing.ToString();
     bonusTextBox.Text          = bookSales.Bonus.ToString();
     totalPriceTextBox.Text     = bookSales.TotalPrice.ToString();
     paymentAmountTextBox.Text  = bookSales.PaymentAmount.ToString();
     duesTextBox.Text           = bookSales.Dues.ToString();
 }
Exemplo n.º 15
0
        private void GetValueFromDatabase(BookSales bookSales, SqlDataReader reader)
        {
            bookSales.Date         = reader["date"].ToString();
            bookSales.DistrictName = reader["district_id"].ToString();
            bookSales.PartyCode    = reader["party_id"].ToString();
            bookSales.MemoNo       = reader["memo_no"].ToString();
            bookSales.SalesType    = reader["sales_type"].ToString();
            bookSales.Year         = reader["year"].ToString();
            bookSales.GroupName    = reader["group_id"].ToString();
            bookSales.BookId       = int.Parse(reader["book_id"].ToString());
            BookInfo bookInfo = GetBookInfo(bookSales.BookId);

            bookSales.BookRate      = bookInfo.BookRate;
            bookSales.Commisssion   = bookInfo.BookCommission;
            bookSales.Quantity      = Convert.ToDouble(reader["quantity"].ToString());
            bookSales.SalesRate     = Convert.ToDouble(reader["sales_rate"].ToString());
            bookSales.Total         = Convert.ToDouble(reader["total"].ToString());
            bookSales.Packing       = Convert.ToDouble(reader["packing"].ToString());
            bookSales.Bonus         = Convert.ToDouble(reader["bonus"].ToString());
            bookSales.TotalPrice    = Convert.ToDouble(reader["total_price"].ToString());
            bookSales.PaymentAmount = Convert.ToDouble(reader["payment_amount"].ToString());
            bookSales.Dues          = Convert.ToDouble(reader["dues"].ToString());
        }