/// <summary> /// This method is used to display grid view of items available on selecting any category in dropdownlist /// </summary> protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e) { btnReset.Visible = true; //On selecting category from ddl,respective item list should be displayed ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); List <IItem> listItems = new List <IItem>(); List <IItem> listItem = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedValue)); foreach (IItem item in listItem) { if (item.ItemQuantity < 50) { listItems.Add(item); } } gvshowInventoryList.DataSource = listItems; gvshowInventoryList.DataBind(); btnaddToReport.Visible = true; if (gvshowInventoryList.Rows.Count == 0) { LblMessage.Text = "No Items In this Category"; btnaddToReport.Visible = false; return; } }
/// <summary> /// Function to bind the data. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DataBind() { ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); string name = string.Empty; if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != ""))) { if (!(ddlCategory.SelectedIndex == 0)) { gvShowItemList.DataSource = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value)); gvShowItemList.DataBind(); } else if (!(txtItemName.Text == "")) { name = txtItemName.Text; gvShowItemList.DataSource = objBLL.SearchItembyName(name); gvShowItemList.DataBind(); } else { gvShowItemList.Visible = false; } } else { name = txtItemName.Text; int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value); gvShowItemList.DataSource = objBLL.GetItemList(categoryId, name); gvShowItemList.DataBind(); } }
// static List<IItem> billsItems = new List<IItem>(); /// <summary> /// This is the page load method for generating Bill. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); List <IItemCategory> itemList = objBLL.GetItemCategoryList(); DateTime date = DateTime.Now; if (!IsPostBack) { int salesPersonId = Convert.ToInt32(Session["userID"]); lblBillsDate.Text = (date).ToString(); lblSalesPersonID.Text = salesPersonId.ToString(); lblBillNumberLabel.Visible = false; btnAddItemToBill.Visible = false; btnDelete.Visible = false; btnCalcBill.Visible = false; lblTotalPrice.Visible = false; lblTotalPriceLabel.Visible = false; lblMoneyIn.Visible = false; txtMoneyIn.Visible = false; lblReturnAmountLabel.Visible = false; lblReturnAmount.Visible = false; btnGenerateButton.Visible = false; } if (!IsPostBack) { ddlCategory.DataSource = itemList; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); } }
/// <summary> /// This method will update the details of return items to database. /// </summary> /// <param name="sender"></param> /// <param name="e">returns void</param> protected void btnSubmitGridView_Click(object sender, EventArgs e) { IBillDetails objBillDetails = BillDetailsBOFactory.CreateBillDetailsObject(); ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); try { for (int j = 0; j < gvSelectedItems.Rows.Count; j++) { GridViewRow gvBillsItemRow = gvSelectedItems.Rows[j]; objBillDetails.BillNumber = Convert.ToInt32(txtBillNo.Text); objBillDetails.ItemID = Convert.ToInt32(gvBillsItemRow.Cells[0].Text); objBillDetails.QuantityReturned = Convert.ToInt32(((TextBox)(gvBillsItemRow.FindControl("txtReturnedItemQuantity"))).Text); objBillDetails.LineTotalofReturnedItems = Convert.ToInt32(((Label)(gvBillsItemRow.FindControl("txtReturnTotal"))).Text); objBillDetails.Remarks = Convert.ToString(((TextBox)(gvBillsItemRow.FindControl("txtRemarks"))).Text); objBLL.TakeBackSoldItems(objBillDetails); lblMessage.Text = "Details updated"; } } catch (Exception ex) { lblMessage.Text = "An error occurred while returning Items"; } finally { objBillDetails = null; objBLL = null; } }
/// <summary> /// Function to search items from inventory according to values inserted or category selected or both /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnSearch_Click(object sender, EventArgs e) { lblMessage1.Text = ""; btnAddItemToBill.Visible = false; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); string name = string.Empty; if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != ""))) { if (!(ddlCategory.SelectedIndex == 0)) { List <IItem> lstItems = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value)); foreach (IItem item in lstItems) { if (item.ItemQuantity == 0) { lstItems.Remove(item); } } if (lstItems.Count == 0) { lblMessage1.Text = "No Items In this Category"; btnAddItemToBill.Visible = false; } gvshowItemList.DataSource = lstItems; gvshowItemList.DataBind(); btnAddItemToBill.Visible = true; } else if (!(txtItemName.Text == "")) { name = txtItemName.Text; gvshowItemList.DataSource = objBLL.SearchItembyName(name); gvshowItemList.DataBind(); btnAddItemToBill.Visible = true; } else { lblErrorMsg.Text = "Please Select Category/Enter Name "; } } else { btnAddItemToBill.Visible = true; name = txtItemName.Text; int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value); gvshowItemList.DataSource = objBLL.GetItemList(categoryId, name); gvshowItemList.DataBind(); } }
/// <summary> /// This is the Page Load method for showing list of items /// </summary> protected void Page_Load(object sender, EventArgs e) { ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); List <IItemCategory> itemList = objBLL.GetItemCategoryList(); if (!IsPostBack) { ddlCategory.DataSource = itemList; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); } }
/// <summary> /// This method is used to generate report which is to be saved in database /// </summary> protected void BtnGenerateReport_Click(object sender, EventArgs e) { bool saved = false; //List<IItem> itemlst = new List<IItem>(); ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); saved = objBLL.SaveReportofNotAvalableItems(notavailableItemList); if (saved) { LblMessage.Text = "Saved Item Successfully"; } else { LblMessage.Text = "Item Not Saved"; } }
/// <summary> /// This method cancels the searched bill /// </summary> protected void btnCancel_Click(object sender, EventArgs e) { // bool isBillSelected = false; bool isDeleted = false; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); ICustomerBill custBill = CustomerBillBOFactory.CreateCustomerBillObject(); try { int selectedBill = 0; custBill.BillNumber = Convert.ToInt32(txtBillNumber.Text); GridViewRow gvItem = gvShowBillList.Rows[0]; //isBillSelected = ((RadioButton)gvItem.FindControl("rdbBillNumber")).Checked; // if (isBillSelected) //{ selectedBill.Equals(Convert.ToInt32(gvShowBillList.Rows[0].Cells[1].Text)); //} custBill.Remarks = ((TextBox)gvItem.FindControl("txtRemark")).Text; if (custBill.BillStatus == "ok") { isDeleted = objBLL.CancelBill(custBill); gvShowBillList.DataBind(); if (isDeleted) { lblMessage.Text = "Cancelled Successfully"; } else { lblErrorMessage.Text = "Error"; } } else { lblErrorMessage.Text = "Bill already cancelled"; } } catch (Exception ex) { lblErrorMessage.Text = "An error occurred while cancelling bill details"; } finally { objBLL = null; } }
/// <summary> /// This is the Page Load method for generating item report /// </summary> protected void Page_Load(object sender, EventArgs e) { BtnGenerateReport.Visible = false; btnReset.Visible = false; btnaddToReport.Visible = false; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); List <IItemCategory> itemList = objBLL.GetItemCategoryList(); if (!IsPostBack)//For Binding CategoryId from Database { ddlCategory.DataSource = itemList; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); } LblMessage.Text = ""; }
/// <summary> /// This method displays the item details based on category in the database /// </summary> protected void btnSearch_Click(object sender, EventArgs e) { gvShowItemList.Visible = true; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); string name = string.Empty; if (!((ddlCategory.SelectedIndex != 0) && (txtItemName.Text != ""))) { lblMessage.Text = "Please enter item name or select item category"; if (!(ddlCategory.SelectedIndex == 0)) { lblMessage.Text = ""; gvShowItemList.DataSource = objBLL.GetItemList(Convert.ToInt32(ddlCategory.SelectedItem.Value)); gvShowItemList.DataBind(); } else if (!(txtItemName.Text == "")) { lblMessage.Text = ""; name = txtItemName.Text; gvShowItemList.DataSource = objBLL.SearchItembyName(name); gvShowItemList.DataBind(); } else if ((ddlCategory.SelectedIndex != 0) && (gvShowItemList.Rows.Count == 0)) { lblMessage.Text = "No items found in this category"; } else { gvShowItemList.Visible = false; } } else { name = txtItemName.Text; int categoryId = Convert.ToInt32(ddlCategory.SelectedItem.Value); gvShowItemList.DataSource = objBLL.GetItemList(categoryId, name); gvShowItemList.DataBind(); } }
/// <summary> /// This method is used to search Bill Number /// </summary> protected void btnSearch_Click(object sender, EventArgs e) { lblErrorMessage.Text = ""; lblMessage.Text = ""; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); gvShowBillList.DataSource = objBLL.SearchBillDetails(Convert.ToInt32(txtBillNumber.Text)); gvShowBillList.DataBind(); if (txtBillNumber.MaxLength < 4) { lblErrorMessage.Text = "Invalid Bill Number"; } else if (Convert.ToInt32(txtBillNumber.Text) >= 1000 && gvShowBillList.Rows.Count == 0) { lblErrorMessage.Text = "Bill Not Found"; } else if (gvShowBillList.Rows.Count != 0) { btnCancel.Visible = true; btnReset.Visible = true; } }
/// <summary> /// Function to generate bill /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GenerateButton_Click(object sender, EventArgs e) { if (Convert.ToDouble(lblTotalPrice.Text) == 0) { lblErrorMsg.Text = "Can not generate Bill for zero Bill amount"; } else { gvshowItemList.EnableViewState = false; ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); ICustomerBill custBill = CustomerBillBOFactory.CreateCustomerBillObject(); DateTime date = DateTime.Now; lblBillsDate.Text = (date).ToString(); custBill.BillDate = date; custBill.BoughtItemList = billItemList; //customerID++; custBill.CustomerId = customerID; custBill.CustomerName = txtCustomerName.Text; custBill.BillStatus = "ok"; custBill.EmployeeId = Convert.ToInt32(lblSalesPersonID.Text); custBill.MoneyIn = Convert.ToInt32(txtMoneyIn.Text); custBill.MoneyOut = 0; custBill.TotalBillAmount = Convert.ToDouble(lblTotalPrice.Text); custBill.TotalMoneyReturned = Convert.ToInt32(lblReturnAmount.Text); objBLL.CreateBill(custBill); lblBillNumberLabel.Visible = true; lblBillNumber.Text = (custBill.BillNumber).ToString(); clearAllFields(); } }
/// <summary> /// This method displays the bill details on entering the bill number. /// </summary> /// <param name="sender"></param> /// <param name="e">returns void</param> protected void btnSubmit_Click(object sender, EventArgs e) { btnEdit.Visible = true; btnCalculate.Visible = false; btnCancel.Visible = true; //if (!IsPostBack) { IBillDetails objBillDetails = BillDetailsBOFactory.CreateBillDetailsObject(); IOrderedItems objItem = OrderedItemsBOFactory.CreateOrderedItemsObject(); ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject(); int billNumber = Convert.ToInt32(txtBillNo.Text); List <IBillDetails> lstBillDetails = objBLL.GetBillDetails(billNumber); if (lstBillDetails.Count == 0) { lblMessage.Text = "No Bill Found"; } else { gvshowBillItems.DataSource = lstBillDetails; gvshowBillItems.DataBind(); } } }