protected void btnCalculate_Click(object sender, EventArgs e)
        {
            IBillDetails objBillDetails = BillDetailsBOFactory.CreateBillDetailsObject();


            for (int j = 0; j < gvSelectedItems.Rows.Count; j++)
            {
                GridViewRow gvBillsItemRow = gvSelectedItems.Rows[j];

                objBillDetails.QuantityPurchased = Convert.ToInt32(gvBillsItemRow.Cells[3].Text);
                objBillDetails.QuantityReturned  = Convert.ToInt32(((TextBox)(gvBillsItemRow.FindControl("txtReturnedItemQuantity"))).Text);



                if (objBillDetails.QuantityPurchased < objBillDetails.QuantityReturned)
                {
                    lblMessage.Text = "Return Quantity can not be greater than purchased quantity";
                    break;
                }

                //obj
                objBillDetails.LineTotal = Convert.ToInt32(gvBillsItemRow.Cells[2].Text);
                objBillDetails.LineTotalofReturnedItems = (objBillDetails.LineTotal / objBillDetails.QuantityPurchased) * objBillDetails.QuantityReturned;
                objBillDetails.Remarks       = Convert.ToString(((TextBox)(gvBillsItemRow.FindControl("txtRemarks"))).Text);
                gvBillsItemRow.Cells[5].Text = objBillDetails.LineTotalofReturnedItems.ToString();
            }

            btnSubmitGridView.Visible = true;
        }
        /// <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;
            }
        }
Beispiel #3
0
        public void TakeBackSoldItems(IBillDetails objBillDetails)
        {
            SqlConnection objSQLConn    = null;
            SqlCommand    objSQLCommand = null;

            try
            {
                objSQLConn = new SqlConnection(strConnectionString);

                objSQLCommand             = new SqlCommand("usp_ReturnItems", objSQLConn);
                objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;

                objSQLCommand.Parameters.AddWithValue("@QuantityReturned", objBillDetails.QuantityReturned);
                objSQLCommand.Parameters.AddWithValue("@ReturnedTotal", objBillDetails.LineTotalofReturnedItems);
                objSQLCommand.Parameters.AddWithValue("@Remark", objBillDetails.Remarks);
                objSQLCommand.Parameters.AddWithValue("@BillNumber", objBillDetails.BillNumber);
                objSQLCommand.Parameters.AddWithValue("@ItemID", objBillDetails.ItemID);
                //objSQLCommand.Parameters.AddWithValue("@Address", objEmployee.Address);
                //objSQLCommand.Parameters.AddWithValue("@State", objEmployee.State);
                //objSQLCommand.Parameters.AddWithValue("@City", objEmployee.City);
                //objSQLCommand.Parameters.AddWithValue("@ContactNumber", objEmployee.MobileNumber);

                //objSQLCommand.Parameters.Add("@EmployeeID", System.Data.SqlDbType.Int);
                //objSQLCommand.Parameters["@EmployeeID"].Direction = System.Data.ParameterDirection.Output;

                objSQLConn.Open();
                //int noOfRowsAffected = objSQLCommand.ExecuteNonQuery();
                //if (noOfRowsAffected > 0)
                //    objBillDetails.EmployeeId = Convert.ToInt32(objSQLCommand.Parameters["@EmployeeID"].Value);
                //isAdded = true;

                //objSQLCommand = new SqlCommand("usp_addToLoginDetails", objSQLConn);
                //objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;
                //objSQLCommand.Parameters.AddWithValue("@EmployeeID", objEmployee.EmployeeId);
                //objSQLCommand.Parameters.AddWithValue("@RoleId", objEmployee.RoleId);
                //string pwd = string.Empty;
                //pwd = (objEmployee.Dob.Month).ToString() + (objEmployee.Dob.Day).ToString() + (objEmployee.Dob.Year).ToString();
                //objSQLCommand.Parameters.AddWithValue("@Password", pwd);

                objSQLCommand.ExecuteNonQuery();
            }

            catch
            {
                throw;
            }
            finally
            {
                if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed)
                {
                    objSQLConn.Close();
                }
            }

            //return isAdded;
        }
Beispiel #4
0
        /// <summary>
        /// Function to get bill details
        /// </summary>
        /// <param name="billNumber">  User selected billNumber </param>
        /// <returns> list of attributes of bill details based on bill number </returns>
        public List <IBillDetails> GetBillDetails(int billNumber)
        {
            List <IBillDetails> lstBillDetail = new List <IBillDetails>();
            SqlConnection       objSQLConn    = null;
            SqlCommand          objSQLCommand = null;

            try
            {
                objSQLConn = new SqlConnection(strConnectionString);
                objSQLConn.Open();

                objSQLCommand = new SqlCommand("usp_ViewBillDetails", objSQLConn);

                objSQLCommand.Parameters.AddWithValue("@BillNo", billNumber);
                objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader objSQLReader = objSQLCommand.ExecuteReader();
                IBillDetails  bills        = BillDetailsBOFactory.CreateBillDetailsObject();
                while (objSQLReader.Read())
                {
                    objSQLCommand.Parameters.AddWithValue("@BillNo", billNumber);
                    bills.ItemName = Convert.ToString(objSQLReader["ItemName"]);
                    //objReturnedItems. = Convert.ToString(objSQLReader["EmployeeLastName"]);
                    bills.ItemID = Convert.ToInt32(objSQLReader["ItemID"]);

                    bills.QuantityPurchased = Convert.ToInt32(objSQLReader["QuantityPurchased"]);
                    bills.LineTotal         = Convert.ToDouble(objSQLReader["LineTotal"]);


                    lstBillDetail.Add(bills);
                }

                objSQLReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed)
                {
                    objSQLConn.Close();
                }
            }


            return(lstBillDetail);
        }
 /// <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();
         }
     }
 }
 public void TakeBackSoldItems(IBillDetails objBillDetails)
 {
     ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject();
     objDAL.TakeBackSoldItems(objBillDetails);
 }
Beispiel #7
0
        public void TakeBackSoldItems(IBillDetails objBillDetails)
        {
            ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject();

            objDAL.TakeBackSoldItems(objBillDetails);
        }
        public void TakeBackSoldItems(IBillDetails objBillDetails)
        {
            
            SqlConnection objSQLConn = null;
            SqlCommand objSQLCommand = null;

            try
            {
                objSQLConn = new SqlConnection(strConnectionString);

                objSQLCommand = new SqlCommand("usp_ReturnItems", objSQLConn);
                objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;

                objSQLCommand.Parameters.AddWithValue("@QuantityReturned", objBillDetails.QuantityReturned);
                objSQLCommand.Parameters.AddWithValue("@ReturnedTotal", objBillDetails.LineTotalofReturnedItems);
                objSQLCommand.Parameters.AddWithValue("@Remark", objBillDetails.Remarks);
                objSQLCommand.Parameters.AddWithValue("@BillNumber", objBillDetails.BillNumber);
                objSQLCommand.Parameters.AddWithValue("@ItemID", objBillDetails.ItemID);
                //objSQLCommand.Parameters.AddWithValue("@Address", objEmployee.Address);
                //objSQLCommand.Parameters.AddWithValue("@State", objEmployee.State);
                //objSQLCommand.Parameters.AddWithValue("@City", objEmployee.City);
                //objSQLCommand.Parameters.AddWithValue("@ContactNumber", objEmployee.MobileNumber);

                //objSQLCommand.Parameters.Add("@EmployeeID", System.Data.SqlDbType.Int);
                //objSQLCommand.Parameters["@EmployeeID"].Direction = System.Data.ParameterDirection.Output;

                objSQLConn.Open();
                //int noOfRowsAffected = objSQLCommand.ExecuteNonQuery();
                //if (noOfRowsAffected > 0)
                //    objBillDetails.EmployeeId = Convert.ToInt32(objSQLCommand.Parameters["@EmployeeID"].Value);
                //isAdded = true;

                //objSQLCommand = new SqlCommand("usp_addToLoginDetails", objSQLConn);
                //objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure;
                //objSQLCommand.Parameters.AddWithValue("@EmployeeID", objEmployee.EmployeeId);
                //objSQLCommand.Parameters.AddWithValue("@RoleId", objEmployee.RoleId);
                //string pwd = string.Empty;
                //pwd = (objEmployee.Dob.Month).ToString() + (objEmployee.Dob.Day).ToString() + (objEmployee.Dob.Year).ToString();
                //objSQLCommand.Parameters.AddWithValue("@Password", pwd);

                objSQLCommand.ExecuteNonQuery();

            }

            catch
            {
                throw;
            }
            finally
            {
                if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed)
                    objSQLConn.Close();
            }

            //return isAdded;
        }
        /// <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();
        }