/// <summary>
        /// This is the Page Load method for deleting an item
        /// </summary>
        public void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblMessage.Text = "";
                IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();

                List <IItemCategory> itemList = objBLL.GetCategoryList();

                ddlCategory.DataSource     = itemList;
                ddlCategory.DataTextField  = "CategoryName";
                ddlCategory.DataValueField = "CategoryID";
                ddlCategory.DataBind();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Function to delete an employee from the list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();

            try
            {
                bool       isEmployeeSelected = false;
                bool       isDeleted          = false;
                List <int> selectedItemList1  = new List <int>();


                //loop through the grid to find the selected item
                for (int i = 0; i < gvManageEmployee.Rows.Count; i++)
                {
                    GridViewRow gvEmployeeRow = gvManageEmployee.Rows[i];
                    isEmployeeSelected = (Boolean)((CheckBox)gvEmployeeRow.FindControl("chkSelect")).Checked;
                    if (isEmployeeSelected)
                    {
                        selectedItemList1.Add(Convert.ToInt32(gvManageEmployee.Rows[i].Cells[1].Text));
                    }
                }
                if (selectedItemList1.Count == 0)
                {
                    lblMessage.Text = "Please select employee";
                }
                else
                {
                    isDeleted = objBLL.DeleteEmployeeDetails(selectedItemList1);
                    gvManageEmployee.DataSource = objBLL.GetEmployeeDetailsList();
                    gvManageEmployee.DataBind();


                    //if (isEmployeeSelected)
                    //{
                    //    lblMessage.Text = "Please select an employee";
                    //}
                    if (isDeleted)
                    {
                        lblMessage.Text = "Employee(s) deleted successfully";
                    }
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is the Page Load method for adding an item
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();


            int itemId = Convert.ToInt32(Request.QueryString["ItemID"]);

            if (!IsPostBack)
            {
                List <IItemCategory> itemList = objBLL.GetCategoryList();

                ddlCategory.DataSource     = itemList;
                ddlCategory.DataTextField  = "CategoryName";
                ddlCategory.DataValueField = "CategoryID";
                ddlCategory.DataBind();

                if (itemId != 0)
                {
                    //itemId = Convert.ToInt32(Request.QueryString["ItemID"]);
                    IItem objItem = ViewItemBOFactory.CreateItemobject();
                    // IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();
                    objItem        = objBLL.GetItemByItemId(itemId);
                    objItem.ItemID = itemId;

                    txtItemName.Text          = Convert.ToString(objItem.ItemName);
                    ddlCategory.SelectedValue = Convert.ToString(objItem.ItemCategory);
                    txtItemPrice.Text         = Convert.ToString(objItem.ItemPrice);
                    txtItemQuantity.Text      = Convert.ToString(objItem.ItemQuantity);
                    txtItemDiscount.Text      = Convert.ToString(objItem.ItemDiscount);

                    //objBLL.UpdateItemDetails(objItem);
                }


                lblNewCat.Visible = false;
                btnCat.Visible    = false;
                txtnewCat.Visible = false;
            }

            /*else
             * {
             *  int itemId = Convert.ToInt32(tx);
             * }*/
        }
Exemplo n.º 4
0
        /// <summary>
        /// Function to bindings the grid view data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnGridViewDataBinding(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)   //skip header row
            {
                IEmployee objEmployee = (IEmployee)e.Row.DataItem;

                IAdminBLL    objBLL   = AdminBLLFactory.CreateAdminBLLObject();
                List <IRole> roleList = objBLL.GetRoleList();

                DropDownList ddlRoleList = (DropDownList)e.Row.FindControl("ddlNewRole");

                if (ddlRoleList != null)
                {
                    ddlRoleList.AppendDataBoundItems = true;
                    ListItem lst = new ListItem("Select Role", "0");
                    ddlRoleList.Items.Add(lst);
                    ddlRoleList.DataSource     = roleList;
                    ddlRoleList.DataTextField  = "RoleName";
                    ddlRoleList.DataValueField = "RoleId";
                    ddlRoleList.DataBind();
                }
            }
        }
        /// <summary>
        /// This is the page load method for add/ update employee
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            calenderDOB.StartDate = Convert.ToDateTime("01/01/1960");
            calenderDOB.EndDate   = Convert.ToDateTime("01 / 01 / 2005");
            calenderDOJ.StartDate = DateTime.Today.AddMonths(-1);
            calenderDOJ.EndDate   = DateTime.Today;

            calenderDOJ.SelectedDate = DateTime.Today;



            IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();

            List <IRole> lstRole = objBLL.GetRoleList();

            if (!IsPostBack)
            {
                ddlRole.DataSource     = lstRole;
                ddlRole.DataTextField  = "RoleName";
                ddlRole.DataValueField = "RoleId";
                ddlRole.DataBind();
            }
        }
        /// <summary>
        /// This method will allow to update the edited fields.
        /// </summary>

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            IAdminBLL objBLL      = AdminBLLFactory.CreateAdminBLLObject();
            IEmployee objEmployee = EmployeeBOFactory.CreateEmployeeObject();

            try
            {
                bool isUpdated = false;
                objEmployee.EmployeeId   = Convert.ToInt32(lblEmployeeIdDynamic2.Text);
                objEmployee.Address      = (txtAddress2).Text;
                objEmployee.State        = Convert.ToString(ddlState2.SelectedItem);
                objEmployee.City         = Convert.ToString(ddlCity2.SelectedItem);
                objEmployee.MobileNumber = Convert.ToInt64(txtContact2.Text);
                bool IsAdded = objBLL.UpdateEmployee(objEmployee);
                isUpdated = true;
                //objEmployee.EmployeeId = Convert.ToInt32(gvEmployeeRow.Cells[1].Text);
                //objEmployee.FirstName = (gvEmployeeRow.Cells[2].Text);
                //objEmployee.LastName = (gvEmployeeRow.Cells[3].Text);
                //objEmployee.RoleName = gvEmployeeRow.Cells[4].Text;
                //objEmployee.MobileNumber = Convert.ToInt64(gvEmployeeRow.Cells[5].Text);

                //selectedItemList1.Add(objEmployee);
                if (isUpdated)
                {
                    lblMessage.Text = "Updated successfully";
                }
                else
                {
                    lblMessage.Text = "Unable to update";
                }
            }

            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Function will allow to update the employee details based on selected check box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();

            gvManageEmployee.Visible = false;
            btnDelete.Visible        = false;
            btnUpdate.Visible        = false;
            btnUP.Visible            = true;
            try
            {
                bool isEmployeeSelected = false;
                //bool isDeleted = false;



                //loop through the grid to find the selected item
                for (int i = 0; i < gvManageEmployee.Rows.Count; i++)
                {
                    GridViewRow gvEmployeeRow = gvManageEmployee.Rows[i];
                    isEmployeeSelected = (Boolean)((CheckBox)gvEmployeeRow.FindControl("chkSelect")).Checked;
                    if (isEmployeeSelected)
                    {
                        IEmployee objEmployee = EmployeeBOFactory.CreateEmployeeObject();
                        objEmployee.EmployeeId   = Convert.ToInt32(gvEmployeeRow.Cells[1].Text);
                        objEmployee.FirstName    = (gvEmployeeRow.Cells[2].Text);
                        objEmployee.LastName     = (gvEmployeeRow.Cells[3].Text);
                        objEmployee.RoleName     = gvEmployeeRow.Cells[4].Text;
                        objEmployee.MobileNumber = Convert.ToInt64(gvEmployeeRow.Cells[5].Text);

                        selectedItemList1.Add(objEmployee);
                    }
                }
                if (selectedItemList1.Count != 0)
                {
                    gvshowItems.DataSource = selectedItemList1;
                }
                gvshowItems.DataBind();

                if (selectedItemList1.Count == 0)
                {
                    gvManageEmployee.Visible = true;
                    lblMessage.Text          = "Please select employee";
                }
                //else
                //{
                //    //isDeleted = objBLL.DeleteEmployeeDetails(selectedItemList1);
                //    //if (!IsPostBack)
                //    //{

                //    //}

                //    //if (isEmployeeSelected)
                //    //{
                //    //    lblMessage.Text = "Please select an employee";
                //    //}
                //    //if (isDeleted)
                //    {
                //        //lblMessage.Text = "Employee(s) deleted successfully";
                //    }

                //
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
        /// <summary>
        /// This method will provide to edit the fields.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">returns void</param>
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            btnEdit.Visible           = false;
            btnCancel.Visible         = true;
            btnSubmitGridView.Visible = true;
            btnCalculate.Visible      = true;
            IAdminBLL objBLL = AdminBLLFactory.CreateAdminBLLObject();

            gvshowBillItems.Visible = false;
            List <IBillDetails> selectedItemList1 = new List <IBillDetails>();

            try
            {
                bool isItemSelected = false;
                //bool isDeleted = false;



                //loop through the grid to find the selected item
                for (int i = 0; i < gvshowBillItems.Rows.Count; i++)
                {
                    GridViewRow gvItemRow = gvshowBillItems.Rows[i];
                    isItemSelected = (Boolean)((CheckBox)gvItemRow.FindControl("chkSelect")).Checked;
                    if (isItemSelected)
                    {
                        IBillDetails objBillDetails = BillDetailsBOFactory.CreateBillDetailsObject();
                        objBillDetails.ItemID   = Convert.ToInt32(gvItemRow.Cells[1].Text);
                        objBillDetails.ItemName = Convert.ToString(gvItemRow.Cells[2].Text);
                        //objBillDetails.BillNumber = Convert.ToInt32(gvItemRow.Cells[3].Text);
                        objBillDetails.QuantityPurchased = Convert.ToInt32(gvItemRow.Cells[4].Text);

                        objBillDetails.LineTotal = Convert.ToInt32(gvItemRow.Cells[3].Text);
                        //objBillDetails.BillNumber = Convert.ToInt32(gvItemRow.Cells[1].Text);
                        //objBillDetails.BillNumber = Convert.ToInt32(gvItemRow.Cells[1].Text);



                        selectedItemList1.Add(objBillDetails);
                    }
                }

                gvSelectedItems.DataSource = selectedItemList1;
                gvSelectedItems.DataBind();

                if (selectedItemList1.Count == 0)
                {
                    lblMessage.Text = "Please select Items to be returned";
                }
                //else
                //{
                //    //isDeleted = objBLL.DeleteEmployeeDetails(selectedItemList1);
                //    //if (!IsPostBack)
                //    //{

                //    //}

                //    //if (isEmployeeSelected)
                //    //{
                //    //    lblMessage.Text = "Please select an employee";
                //    //}
                //    //if (isDeleted)
                //    {
                //        //lblMessage.Text = "Employee(s) deleted successfully";
                //    }

                //
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }



            //ISalesPersonBLL objBLL = SalesPersonBLLFactory.CreateSalesPersonBLLObject();
            //int billNumber = Convert.ToInt32(txtBillNo.Text);
            //gvSelectedItems.DataSource = objBLL.GetBillDetails(billNumber);
            //gvSelectedItems.DataBind();
        }