protected void firstButton_Click(object sender, EventArgs e) { BookSpeciman bookSpeciman = bookSpecimanManager.GetBookSpeciman(0); GetData(bookSpeciman); Session["active"] = 0; }
protected void saveButton_Click(object sender, EventArgs e) { BookSpeciman bookSpeciman = new BookSpeciman(); bookSpeciman.Date = dateTextBox.Value; bookSpeciman.DistrictId = int.Parse(districtNameDropDownList.SelectedValue); bookSpeciman.PartyId = int.Parse(partyCodeDropDownList.SelectedValue); bookSpeciman.MemoNo = memoNoTextBox.Text; bookSpeciman.Year = yearTextBox.Text; bookSpeciman.GroupId = int.Parse(groupNameDropDownList.SelectedValue); bookSpeciman.BookId = int.Parse(bookNameDropDownList.SelectedValue); string quantity = quantityTextBox.Text; string rate = rateTextBox.Text; string total = totalTextBox.Text; if (dateTextBox.Value == "" || memoNoTextBox.Text == "" || yearTextBox.Text == "" || quantityTextBox.Text == "" || rateTextBox.Text == "" || totalTextBox.Text == "") { messageLabel.InnerText = "All Fields are Required!!"; } else { bookSpeciman.Quantity = Convert.ToDouble(quantity); bookSpeciman.Rate = Convert.ToDouble(rate); bookSpeciman.Total = Convert.ToDouble(total); messageLabel.InnerText = bookSpecimanManager.Save(bookSpeciman); } ClearTextBoxes(); }
public string Save(BookSpeciman bookSpeciman) { if (bookSpecimanGateway.Insert(bookSpeciman) > 0) { return("Saved Successfully!!"); } return("Could Not Save data in Database!!"); }
protected void lastButton_Click(object sender, EventArgs e) { List <BookSpeciman> bookSpecimanList = (List <BookSpeciman>)(Session["bookSpeciman"]); int x = bookSpecimanList.Count - 1; BookSpeciman bookSpeciman = bookSpecimanManager.GetBookSpeciman(x); GetData(bookSpeciman); Session["active"] = x; }
private void GetData(BookSpeciman bookSpeciman) { dateTextBox.Value = bookSpeciman.Date; districtNameDropDownList.Text = bookSpeciman.DistrictName; partyCodeDropDownList.Text = bookSpeciman.PartyCode; memoNoTextBox.Text = bookSpeciman.MemoNo; yearTextBox.Text = bookSpeciman.Year; groupNameDropDownList.Text = bookSpeciman.GroupName; bookNameDropDownList.Text = bookSpeciman.BookId.ToString(); bookRateTextBox.Text = bookSpeciman.BookRate.ToString(); commissionTextBox.Text = bookSpeciman.Commission.ToString(); quantityTextBox.Text = bookSpeciman.Quantity.ToString(); rateTextBox.Text = bookSpeciman.Rate.ToString(); totalTextBox.Text = bookSpeciman.Total.ToString(); }
public int Insert(BookSpeciman bookSpeciman) { SqlConnection connection = new SqlConnection(connectionString); string query = "INSERT INTO tbl_bookSpeciman VALUES('" + bookSpeciman.Date + "','" + bookSpeciman.DistrictId + "','" + bookSpeciman.PartyId + "','" + bookSpeciman.MemoNo + "','" + bookSpeciman.Year + "','" + bookSpeciman.GroupId + "','" + bookSpeciman.BookId + "','" + bookSpeciman.Quantity + "','" + bookSpeciman.Rate + "','" + bookSpeciman.Total + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
protected void searchButton_Click(object sender, EventArgs e) { var m = memoTextBox.Value; BookSpeciman bookSpeciman = bookSpecimanManager.GetSearchInfo(m); if (bookSpeciman.MemoNo == null) { message.InnerText = "Invalid Memo No!!"; ClearTextBoxes(); } else { GetData(bookSpeciman); message.InnerText = ""; } }
protected void previousButton_Click(object sender, EventArgs e) { int active = (int)Session["active"]; active--; List <BookSpeciman> bookSpecimanList = (List <BookSpeciman>)(Session["bookSpeciman"]); if (active <= -1) { active = bookSpecimanList.Count - 1; } BookSpeciman bookSpeciman = bookSpecimanManager.GetBookSpeciman(active); GetData(bookSpeciman); Session["active"] = active; }
protected void nextButton_Click(object sender, EventArgs e) { int active = (int)Session["active"]; active++; List <BookSpeciman> bookSpecimanList = (List <BookSpeciman>)(Session["bookSpeciman"]); if (active >= bookSpecimanList.Count) { active = 0; } BookSpeciman bookSpeciman = bookSpecimanManager.GetBookSpeciman(active); GetData(bookSpeciman); Session["active"] = active; }
public BookSpeciman GetSearchInfo(string s) { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM tbl_bookSpeciman WHERE memo_no='" + s + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); BookSpeciman bookSpeciman = new BookSpeciman(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { GetValueFromDatabase(bookSpeciman, reader); } reader.Close(); connection.Close(); return(bookSpeciman); }
public BookSpeciman GetBookSpeciman(int i) { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM tbl_bookSpeciman ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); BookSpeciman bookSpeciman = new BookSpeciman(); while (reader.Read()) { GetValueFromDatabase(bookSpeciman, reader); } reader.Close(); connection.Close(); return(bookSpeciman); }
private void GetValueFromDatabase(BookSpeciman bookSpeciman, SqlDataReader reader) { bookSpeciman.BookSpecimanId = int.Parse(reader["id"].ToString()); bookSpeciman.Date = reader["date"].ToString(); bookSpeciman.DistrictName = reader["district_id"].ToString(); bookSpeciman.PartyCode = reader["party_id"].ToString(); bookSpeciman.MemoNo = reader["memo_no"].ToString(); bookSpeciman.Year = reader["year"].ToString(); bookSpeciman.GroupName = reader["group_id"].ToString(); bookSpeciman.BookId = int.Parse(reader["book_id"].ToString()); BookInfo bookInfo = GetBookInfo(bookSpeciman.BookId); bookSpeciman.BookRate = bookInfo.BookRate; bookSpeciman.Commission = bookInfo.BookCommission; bookSpeciman.Quantity = Convert.ToDouble(reader["quantity"].ToString()); bookSpeciman.Rate = Convert.ToDouble(reader["rate"].ToString()); bookSpeciman.Total = Convert.ToDouble(reader["total"].ToString()); }
private string LoadNextMemoNo() { BookSpeciman bookSpeciman = bookSpecimanManager.GetNextMemoNo(); string memoNo = bookSpeciman.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); }
public BookSpeciman GetNextMemoNo() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT TOP 1 * FROM tbl_bookSpeciman ORDER BY id DESC"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); BookSpeciman bookSpeciman = new BookSpeciman(); while (reader.Read()) { bookSpeciman.BookSpecimanId = int.Parse(reader["id"].ToString()); bookSpeciman.MemoNo = reader["memo_no"].ToString(); } reader.Close(); connection.Close(); return(bookSpeciman); }
public List <BookSpeciman> GetAllBookSpecimanList() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM tbl_bookSpeciman"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <BookSpeciman> bookSpecimanList = new List <BookSpeciman>(); while (reader.Read()) { BookSpeciman bookSpeciman = new BookSpeciman(); GetValueFromDatabase(bookSpeciman, reader); bookSpecimanList.Add(bookSpeciman); } reader.Close(); connection.Close(); return(bookSpecimanList); }