public void PopulateGridView() { DataTable dt = new DataTable(); //using (SqlConnection conn = new SqlConnection(ConnectionString)) SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString); { conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM PurchaseList", conn); adapter.Fill(dt); if (dt.Rows.Count > 0) { ViewState["Paging"] = dt; //MedicineGridView.DataSource = null; PurchaseGridView.DataSource = dt; PurchaseGridView.DataBind(); ViewState["dirState"] = dt; ViewState["sortdr"] = "Asc"; } else { PurchaseGridView.DataSource = dt; PurchaseGridView.DataBind(); } conn.Close(); } }
public void LoadPurchaseDetails() { string Invoice; Invoice = txtInvoice.Text; PurchaseGridView.DataSource = _PurchaseRepository.GetAllPurchaseDetails(Invoice); PurchaseGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //// Dummy book a and b for testing purpose //Book a = new Book(); // to be deleted when combine //a.BookID = 1; // to be deleted when combine //a.Title = "The Trials of Apollo Book Two The Dark Prophecy"; // to be deleted when combine //a.Price = (decimal)19.99; // to be deleted when combine //a.Stock = 10; // to be deleted when combine //a.ISBN = "9781484746424"; // to be deleted when combine //a.CategoryID = 1; // to be deleted when combine //a.Author = "Rick Riordan"; // to be deleted when combine //Book b = new Book(); // to be deleted when combine //b.BookID = 2; // to be deleted when combine //b.Title = "The Wonderful Things You Will Be"; // to be deleted when combine //b.Price = (decimal)17.99; // to be deleted when combine //b.Stock = 10; // to be deleted when combine //b.ISBN = "9780385376716"; // to be deleted when combine //b.CategoryID = 1; // to be deleted when combine //b.Author = "Emily Winfield Martin"; // to be deleted when combine //// Assign Session["cart"] into cartList, and add dummy book a and b into cartList //cartList = Session["cart"] as List<Book>; //cartList.Add(a); // to be deleted when combine //cartList.Add(b); // to be deleted when combine //Session["cart"] = cartList; // to be deleted when combine // Assign Session["cart"] into cartList, and add dummy book a and b into cartList cartList = Session["cart"] as List <Book>; if (cartList != null) { PurchaseGridView.DataSource = cartList; PurchaseGridView.DataBind(); } decimal sum = 0; foreach (Book c in cartList) { sum += c.Price; } PriceLabel.Text = sum.ToString(); } }
protected void PurchaseGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable dataTable = (DataTable)ViewState["Details"]; if (dataTable.Rows.Count > 0) { dataTable.Rows[e.RowIndex].Delete(); ViewState["Details"] = dataTable; PurchaseGridView.DataSource = dataTable; PurchaseGridView.DataBind(); txtAmount.Text = total.ToString(); txtGrandTotal.Text = total.ToString(); } }
public void AddNewPurchaseItem() { string productID = ProductIDTextBox.Text; string productDesc = ProductDescTextBox.Text; string purchasePrice = PriceTextBox.Text; purchaseItemTable.Rows.Add(productID, productDesc, purchasePrice); PurchaseGridView.DataSource = purchaseItemTable; PurchaseGridView.Refresh(); SaveInventoryItem(); SavePurchaseItem(); ProductIDTextBox.Text = string.Empty; ProductDescTextBox.Text = string.Empty; ProductDescTextBox.Text = string.Empty; PriceTextBox.Text = string.Empty; SerialNumberTextBox.Text = string.Empty; }
public void AddPurchaseItems() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Item", typeof(string)); dataTable.Columns.Add("Batch", typeof(int)); dataTable.Columns.Add("Qty", typeof(decimal)); dataTable.Columns.Add("CostPrice", typeof(decimal)); dataTable.Columns.Add("TotalPrice", typeof(decimal)); dataTable.Columns.Add("SellingPrice", typeof(decimal)); dataTable.Columns.Add("Expire", typeof(string)); DataRow dr = null; var data = (DataTable)ViewState["Details"]; if (data != null) { for (int i = 0; i < 1; i++) { dataTable = (DataTable)ViewState["Details"]; if (dataTable.Rows.Count > 0) { dr = dataTable.NewRow(); dr["Item"] = ItemsDropDownList.SelectedItem.ToString(); dr["Batch"] = txtBatch.Text; dr["Qty"] = txtQty.Text; dr["CostPrice"] = txtCostPrice.Text; dr["TotalPrice"] = Convert.ToDecimal(dr["Qty"]) * Convert.ToDecimal(dr["CostPrice"]); dr["SellingPrice"] = txtSellingPrice.Text; dr["Expire"] = txtExpire.Text; dataTable.Rows.Add(dr); PurchaseGridView.DataSource = dataTable; PurchaseGridView.DataBind(); } else { dr = dataTable.NewRow(); dr["Item"] = ItemsDropDownList.SelectedItem.ToString(); dr["Batch"] = txtBatch.Text; dr["Qty"] = txtQty.Text; dr["CostPrice"] = txtCostPrice.Text; dr["TotalPrice"] = Convert.ToDecimal(dr["Qty"]) * Convert.ToDecimal(dr["CostPrice"]); dr["SellingPrice"] = txtSellingPrice.Text; dr["Expire"] = txtExpire.Text; dataTable.Rows.Add(dr); PurchaseGridView.DataSource = dataTable; PurchaseGridView.DataBind(); } } } else { dr = dataTable.NewRow(); dr["Item"] = ItemsDropDownList.SelectedItem.ToString(); dr["Batch"] = txtBatch.Text; dr["Qty"] = txtQty.Text; dr["CostPrice"] = txtCostPrice.Text; dr["TotalPrice"] = Convert.ToDecimal(dr["Qty"]) * Convert.ToDecimal(dr["CostPrice"]); dr["SellingPrice"] = txtSellingPrice.Text; dr["Expire"] = txtExpire.Text; dataTable.Rows.Add(dr); PurchaseGridView.DataSource = dataTable; PurchaseGridView.DataBind(); } ViewState["Details"] = dataTable; ItemsDropDownList.ClearSelection(); txtBatch.Text = ""; txtQty.Text = ""; txtCostPrice.Text = ""; txtSellingPrice.Text = ""; txtExpire.Text = ""; }
protected void PurchaseGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { PurchaseGridView.PageIndex = e.NewPageIndex; PurchaseGridView.DataSource = ViewState["Paging"]; PurchaseGridView.DataBind(); }