protected void firstButton_Click(object sender, EventArgs e) { PaperPrint paperPrint = paperPrintManager.GetPaperPrint(0); GetData(paperPrint); Session["active"] = 0; }
public string Save(PaperPrint paperPrint) { if (paperPrintGateway.Insert(paperPrint) > 0) { return("Saved Successfully!!"); } return("Could Not Save data In Database!!"); }
protected void lastButton_Click(object sender, EventArgs e) { List <PaperPrint> paperPrintList = (List <PaperPrint>)(Session["paperPrint"]); int x = paperPrintList.Count - 1; PaperPrint paperPrint = paperPrintManager.GetPaperPrint(x); GetData(paperPrint); Session["active"] = x; }
protected void previousButton_Click(object sender, EventArgs e) { int active = (int)Session["active"]; active--; List <PaperPrint> paperPrintList = (List <PaperPrint>)(Session["paperPrint"]); if (active <= -1) { active = paperPrintList.Count - 1; } PaperPrint paperPrint = paperPrintManager.GetPaperPrint(active); GetData(paperPrint); Session["active"] = active; }
protected void nextButton_Click(object sender, EventArgs e) { int active = (int)Session["active"]; active++; List <PaperPrint> paperPrintList = (List <PaperPrint>)(Session["paperPrint"]); if (active >= paperPrintList.Count) { active = 0; } PaperPrint paperPrint = paperPrintManager.GetPaperPrint(active); GetData(paperPrint); Session["active"] = active; }
public int Insert(PaperPrint paperPrint) { SqlConnection connection = new SqlConnection(connectionString); string query = "INSERT INTO tbl_paperPrint VALUES('" + paperPrint.Date + "','" + paperPrint.OrderNo + "','" + paperPrint.PressId + "','" + paperPrint.Year + "','" + paperPrint.PrintingType + "','" + paperPrint.GroupId + "','" + paperPrint.BookId + "','" + paperPrint.Plate + "','" + paperPrint.Forma + "','" + paperPrint.FormaType + "','" + paperPrint.ColorType + "','" + paperPrint.PaperId + "','" + paperPrint.PaperType + "','" + paperPrint.BookQuantity + "','" + paperPrint.PaperQuantity + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }
private void GetData(PaperPrint paperPrint) { dateTextBox.Value = paperPrint.Date; orderNoTextBox.Text = paperPrint.OrderNo; pressNameDropDownList.Text = paperPrint.PressName; yearTextBox.Text = paperPrint.Year; printingTypeDropDownList.Text = paperPrint.PrintingType; groupNameDropDownList.Text = paperPrint.GroupName; bookNameDropDownList.Text = paperPrint.BookName; plateTextBox.Text = paperPrint.Plate.ToString(); formaTextBox.Text = paperPrint.Forma.ToString(); formaTypeDropDownList.Text = paperPrint.FormaType; colorTypeDropDownList.Text = paperPrint.ColorType; paperNameDropDownList.Text = paperPrint.PaperName; paperTypeDropDownList.Text = paperPrint.PaperType; bookQuantityTextBox.Text = paperPrint.BookQuantity.ToString(); paperQuantityTextBox.Text = paperPrint.PaperQuantity.ToString(); }
public PaperPrint GetPaperPrint(int i) { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM tbl_paperPrint ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); PaperPrint paperPrint = new PaperPrint(); while (reader.Read()) { GetValueFromDatabase(paperPrint, reader); } reader.Close(); connection.Close(); return(paperPrint); }
private string LoadNextOrderNo() { PaperPrint paperPrint = paperPrintManager.GetNextOrderNo(); string orderNo = paperPrint.OrderNo; int count; if (orderNo == null) { count = 1; } else { count = (orderNo[2] - '0') * 10 + (orderNo[3] - '0') + 1; } string nextOrderNo = "Or" + count.ToString("00"); return(nextOrderNo); }
private static void GetValueFromDatabase(PaperPrint paperPrint, SqlDataReader reader) { paperPrint.PaperPrintId = int.Parse(reader["id"].ToString()); paperPrint.Date = reader["date"].ToString(); paperPrint.OrderNo = reader["order_no"].ToString(); paperPrint.PressName = reader["press_id"].ToString(); paperPrint.Year = reader["year"].ToString(); paperPrint.PrintingType = reader["printing_type"].ToString(); paperPrint.GroupName = reader["group_id"].ToString(); paperPrint.BookName = reader["book_id"].ToString(); paperPrint.Plate = Convert.ToDouble(reader["plate"].ToString()); paperPrint.Forma = Convert.ToDouble(reader["forma"].ToString()); paperPrint.FormaType = reader["forma_type"].ToString(); paperPrint.ColorType = reader["color_type"].ToString(); paperPrint.PaperName = reader["paper_id"].ToString(); paperPrint.PaperType = reader["paper_type"].ToString(); paperPrint.BookQuantity = Convert.ToDouble(reader["book_quantity"].ToString()); paperPrint.PaperQuantity = Convert.ToDouble(reader["paper_quantity"].ToString()); }
public PaperPrint GetNextOrderNo() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT TOP 1 * FROM tbl_paperPrint ORDER BY id DESC"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); PaperPrint paperPrint = new PaperPrint(); while (reader.Read()) { paperPrint.PaperPrintId = int.Parse(reader["id"].ToString()); paperPrint.OrderNo = reader["order_no"].ToString(); } reader.Close(); connection.Close(); return(paperPrint); }
public List <PaperPrint> GetAllPaperPrint() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM tbl_paperPrint"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <PaperPrint> paperPrintList = new List <PaperPrint>(); while (reader.Read()) { PaperPrint paperPrint = new PaperPrint(); GetValueFromDatabase(paperPrint, reader); paperPrintList.Add(paperPrint); } reader.Close(); connection.Close(); return(paperPrintList); }
protected void saveButton_Click(object sender, EventArgs e) { PaperPrint paperPrint = new PaperPrint(); paperPrint.Date = dateTextBox.Value; paperPrint.OrderNo = orderNoTextBox.Text; paperPrint.PressId = int.Parse(pressNameDropDownList.SelectedValue); paperPrint.Year = yearTextBox.Text; paperPrint.PrintingType = printingTypeDropDownList.SelectedValue; paperPrint.GroupId = int.Parse(groupNameDropDownList.SelectedValue); paperPrint.BookId = int.Parse(bookNameDropDownList.SelectedValue); string plate = plateTextBox.Text; string forma = formaTextBox.Text; paperPrint.FormaType = formaTypeDropDownList.SelectedValue; paperPrint.ColorType = colorTypeDropDownList.SelectedValue; paperPrint.PaperId = int.Parse(paperNameDropDownList.SelectedValue); paperPrint.PaperType = paperTypeDropDownList.SelectedValue; string book = bookQuantityTextBox.Text; string paper = paperQuantityTextBox.Text; if (dateTextBox.Value == "" || orderNoTextBox.Text == "" || yearTextBox.Text == "" || plateTextBox.Text == "" || formaTextBox.Text == "" || bookQuantityTextBox.Text == "" || paperQuantityTextBox.Text == "" || paperTypeDropDownList.Text == "" || formaTypeDropDownList.Text == "" || colorTypeDropDownList.Text == "") { messageLabel.InnerText = "All Fields are Required!!"; } else { paperPrint.Plate = Convert.ToDouble(plate); paperPrint.Forma = Convert.ToDouble(forma); paperPrint.BookQuantity = Convert.ToDouble(book); paperPrint.PaperQuantity = Convert.ToDouble(paper); messageLabel.InnerText = paperPrintManager.Save(paperPrint); } ClearTextBoxes(); }