public void CreateBill(ICustomerBill objCustomerBill) { ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject(); objDAL.CreateBill(objCustomerBill); //return objDAL.CreateBill(objBillDetails); }
public List <ICustomerBill> GetCancelledBillList(DateTime d) { SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; List <ICustomerBill> custBillList = new List <ICustomerBill>(); try { objSQLConn = new SqlConnection(strConnectionString); objSQLConn.Open(); objSQLCommand = new SqlCommand("usp_GetCancelledBills", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@BillDate", d); objSQLCommand.Parameters["@BillDate"].Direction = System.Data.ParameterDirection.Input; SqlDataReader objSQLReader = objSQLCommand.ExecuteReader(); while (objSQLReader.Read()) { ICustomerBill objCustCancelledBill = CustomerBillBOFactory.CreateCustomerBillObject(); objCustCancelledBill.BillDate = (DateTime)((objSQLReader["BillDate"])); objCustCancelledBill.BillNumber = Convert.ToInt32(objSQLReader["BillNumber"]); objCustCancelledBill.EmployeeId = Convert.ToInt32(objSQLReader["EmployeeID"]); objCustCancelledBill.CustomerName = (objSQLReader["CustomerName"]).ToString(); objCustCancelledBill.TotalBillAmount = Convert.ToDouble((objSQLReader["TotalBillAmount"])); objCustCancelledBill.MoneyIn = Convert.ToDouble(objSQLReader["MoneyIn"]); objCustCancelledBill.TotalMoneyReturned = Convert.ToDouble(objSQLReader["ReturnAmount"]); objCustCancelledBill.BillStatus = (objSQLReader["BillStatus"]).ToString(); custBillList.Add(objCustCancelledBill); } objSQLReader.Close(); } catch (Exception ex) { throw ex; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) { objSQLConn.Close(); } } return(custBillList); }
// <summary> /// This method will display the bill details . /// </summary> /// <returns>returns the list of bills generated on that date</returns> public List <ICustomerBill> GetBillList(DateTime date) { SqlConnection objSqlConn = null; SqlCommand objSqlCommand = null; List <ICustomerBill> custBillList = new List <ICustomerBill>(); try { objSqlConn = new SqlConnection(strConnectionString); objSqlCommand = new SqlCommand("usp_viewBillByDate", objSqlConn); objSqlCommand.CommandType = System.Data.CommandType.StoredProcedure; objSqlConn.Open(); objSqlCommand.Parameters.AddWithValue("@BillDate", date); objSqlCommand.Parameters["@BillDate"].Direction = System.Data.ParameterDirection.Input; SqlDataReader objSqlReader = objSqlCommand.ExecuteReader(); while (objSqlReader.Read()) { ICustomerBill objBill = CustomerBillBOFactory.CreateCustomerBillObject(); objBill.BillNumber = Convert.ToInt32(objSqlReader["BillNumber"]); objBill.CustomerName = objSqlReader["CustomerName"].ToString(); objBill.TotalBillAmount = Convert.ToInt32(objSqlReader["TotalBillAmount"]); custBillList.Add(objBill); } objSqlReader.Close(); } catch (Exception ex) { throw ex; } finally { if (objSqlConn != null && objSqlConn.State != System.Data.ConnectionState.Closed) { objSqlConn.Close(); } } return(custBillList); }
/// <summary> /// Function to get searched bill details /// </summary> /// <param name="billNumber"> User selected billNumber </param> /// <returns> list of attributes of bill details based on bill number </returns> public List <ICustomerBill> SearchBillDetails(int billNumber) { SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; List <ICustomerBill> lstBill = new List <ICustomerBill>(); try { objSQLConn = new SqlConnection(strConnectionString); objSQLCommand = new SqlCommand("usp_GetBillDetails", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLConn.Open(); objSQLCommand.Parameters.AddWithValue("@BillNumber", billNumber); objSQLCommand.Parameters["@BillNumber"].Direction = System.Data.ParameterDirection.Input; SqlDataReader objSQLReader1 = objSQLCommand.ExecuteReader(); while (objSQLReader1.Read()) { ICustomerBill objBill = CustomerBillBOFactory.CreateCustomerBillObject(); objBill.BillNumber = Convert.ToInt32(objSQLReader1["BillNumber"]); objBill.EmployeeId = Convert.ToInt32(objSQLReader1["EmployeeID"]); objBill.CustomerName = objSQLReader1["CustomerName"].ToString(); objBill.BillDate = Convert.ToDateTime(objSQLReader1["BillDate"]); objBill.TotalBillAmount = Convert.ToDouble(objSQLReader1["TotalBillAmount"]); lstBill.Add(objBill); } } catch { throw; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) { objSQLConn.Close(); } } return(lstBill); }
/// <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> /// Function to cancel bill /// </summary> /// <param name="objCustomerBill"> contains the bills data </param> public bool CancelBill(ICustomerBill objCustomerBill) { bool isDeleted = false; SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; try { objSQLConn = new SqlConnection(strConnectionString); objSQLConn.Open(); objSQLCommand = new SqlCommand("usp_CancelBill", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@BillNumber", objCustomerBill.BillNumber); objSQLCommand.Parameters["@BillNumber"].Direction = System.Data.ParameterDirection.Input; objSQLCommand.Parameters.AddWithValue("@Remarks", objCustomerBill.Remarks); objSQLCommand.Parameters["@Remarks"].Direction = System.Data.ParameterDirection.Input; objSQLCommand.ExecuteNonQuery(); isDeleted = true; } catch (Exception ex) { throw ex; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) { objSQLConn.Close(); } } return(isDeleted); }
/// <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(); } }
public bool CancelBill(ICustomerBill objCustomerBill) { ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject(); return objDAL.CancelBill(objCustomerBill); }
public void CreateBill(ICustomerBill objCustomerBill) { ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject(); objDAL.CreateBill(objCustomerBill); //return objDAL.CreateBill(objBillDetails); }
/// <summary> /// Function to generate bill /// </summary> /// <param name="objCustomerBill"> contains the bills data </param> public void CreateBill(ICustomerBill objCustomerBill) { SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; SqlTransaction objTran = null; try { // storing data in bills table objSQLConn = new SqlConnection(strConnectionString); objSQLCommand = new SqlCommand("usp_addBill", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@CustomerID", objCustomerBill.CustomerId); objSQLCommand.Parameters.AddWithValue("@CustomerName", objCustomerBill.CustomerName); objSQLCommand.Parameters.AddWithValue("@EmployeeID", objCustomerBill.EmployeeId); objSQLCommand.Parameters.AddWithValue("@BillStatus ", objCustomerBill.BillStatus); objSQLCommand.Parameters.AddWithValue("@BillDate", objCustomerBill.BillDate); objSQLCommand.Parameters.AddWithValue("@MoneyIn", objCustomerBill.MoneyIn); objSQLCommand.Parameters.AddWithValue("@MoneyOut", objCustomerBill.MoneyOut); objSQLCommand.Parameters.AddWithValue("@TotalBillAmount", objCustomerBill.TotalBillAmount); objSQLCommand.Parameters.AddWithValue("@ReturnAmount", objCustomerBill.TotalMoneyReturned); objSQLCommand.Parameters.Add("@BillNumber", System.Data.SqlDbType.Int); objSQLCommand.Parameters["@BillNumber"].Direction = System.Data.ParameterDirection.Output; objSQLConn.Open(); objTran = objSQLConn.BeginTransaction(); objSQLCommand.Transaction = objTran; int noOfRowsAffected = objSQLCommand.ExecuteNonQuery(); if (noOfRowsAffected > 0) { objCustomerBill.BillNumber = Convert.ToInt32(objSQLCommand.Parameters["@BillNumber"].Value); // storing data in bill details table foreach (IItem item in objCustomerBill.BoughtItemList) { objSQLCommand = new SqlCommand("usp_addBillDetails", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@BillNumber", objCustomerBill.BillNumber); objSQLCommand.Parameters.AddWithValue("@ItemID", item.ItemID); objSQLCommand.Parameters.AddWithValue("@ItemName", item.ItemName); objSQLCommand.Parameters.AddWithValue("@BillDate", objCustomerBill.BillDate); objSQLCommand.Parameters.AddWithValue("@ItemWiseDiscount", item.ItemDiscount); objSQLCommand.Parameters.AddWithValue("@QuantityPurchased", item.ItemQuantity); double lineTotal = item.ItemQuantity * (item.ItemPrice + item.ItemPrice * item.ItemDiscount / 100); objSQLCommand.Parameters.AddWithValue("@LineTotal", lineTotal); objSQLCommand.Parameters.AddWithValue("@ItemStatus", "ok"); objSQLCommand.Parameters.AddWithValue("@QuantityReturned", 0); objSQLCommand.Parameters.AddWithValue("@ReturnedTotal", 0); objSQLCommand.Parameters.AddWithValue("@Remark", ""); objSQLCommand.Transaction = objTran; noOfRowsAffected = objSQLCommand.ExecuteNonQuery(); if (noOfRowsAffected == 0) { objTran.Rollback(); break; } } } objTran.Commit(); } catch { objTran.Rollback(); throw; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) { objSQLConn.Close(); } } }
public bool CancelBill(ICustomerBill objCustomerBill) { ISalesPersonDAL objDAL = SalesPersonDALFactory.CreateSalesPersonDALObject(); return(objDAL.CancelBill(objCustomerBill)); }
/// <summary> /// Function to cancel bill /// </summary> /// <param name="objCustomerBill"> contains the bills data </param> public bool CancelBill(ICustomerBill objCustomerBill) { bool isDeleted = false; SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; try { objSQLConn = new SqlConnection(strConnectionString); objSQLConn.Open(); objSQLCommand = new SqlCommand("usp_CancelBill", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@BillNumber", objCustomerBill.BillNumber); objSQLCommand.Parameters["@BillNumber"].Direction = System.Data.ParameterDirection.Input; objSQLCommand.Parameters.AddWithValue("@Remarks", objCustomerBill.Remarks); objSQLCommand.Parameters["@Remarks"].Direction = System.Data.ParameterDirection.Input; objSQLCommand.ExecuteNonQuery(); isDeleted = true; } catch (Exception ex) { throw ex; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) objSQLConn.Close(); } return isDeleted; }
/// <summary> /// Function to generate bill /// </summary> /// <param name="objCustomerBill"> contains the bills data </param> public void CreateBill(ICustomerBill objCustomerBill) { SqlConnection objSQLConn = null; SqlCommand objSQLCommand = null; SqlTransaction objTran = null; try { // storing data in bills table objSQLConn = new SqlConnection(strConnectionString); objSQLCommand = new SqlCommand("usp_addBill", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@CustomerID", objCustomerBill.CustomerId); objSQLCommand.Parameters.AddWithValue("@CustomerName", objCustomerBill.CustomerName); objSQLCommand.Parameters.AddWithValue("@EmployeeID", objCustomerBill.EmployeeId); objSQLCommand.Parameters.AddWithValue("@BillStatus ", objCustomerBill.BillStatus); objSQLCommand.Parameters.AddWithValue("@BillDate", objCustomerBill.BillDate); objSQLCommand.Parameters.AddWithValue("@MoneyIn", objCustomerBill.MoneyIn); objSQLCommand.Parameters.AddWithValue("@MoneyOut", objCustomerBill.MoneyOut); objSQLCommand.Parameters.AddWithValue("@TotalBillAmount", objCustomerBill.TotalBillAmount); objSQLCommand.Parameters.AddWithValue("@ReturnAmount", objCustomerBill.TotalMoneyReturned); objSQLCommand.Parameters.Add("@BillNumber", System.Data.SqlDbType.Int); objSQLCommand.Parameters["@BillNumber"].Direction = System.Data.ParameterDirection.Output; objSQLConn.Open(); objTran = objSQLConn.BeginTransaction(); objSQLCommand.Transaction = objTran; int noOfRowsAffected = objSQLCommand.ExecuteNonQuery(); if (noOfRowsAffected > 0) { objCustomerBill.BillNumber = Convert.ToInt32(objSQLCommand.Parameters["@BillNumber"].Value); // storing data in bill details table foreach (IItem item in objCustomerBill.BoughtItemList) { objSQLCommand = new SqlCommand("usp_addBillDetails", objSQLConn); objSQLCommand.CommandType = System.Data.CommandType.StoredProcedure; objSQLCommand.Parameters.AddWithValue("@BillNumber", objCustomerBill.BillNumber); objSQLCommand.Parameters.AddWithValue("@ItemID", item.ItemID); objSQLCommand.Parameters.AddWithValue("@ItemName", item.ItemName); objSQLCommand.Parameters.AddWithValue("@BillDate", objCustomerBill.BillDate); objSQLCommand.Parameters.AddWithValue("@ItemWiseDiscount", item.ItemDiscount); objSQLCommand.Parameters.AddWithValue("@QuantityPurchased", item.ItemQuantity); double lineTotal = item.ItemQuantity * (item.ItemPrice + item.ItemPrice * item.ItemDiscount / 100); objSQLCommand.Parameters.AddWithValue("@LineTotal", lineTotal); objSQLCommand.Parameters.AddWithValue("@ItemStatus", "ok"); objSQLCommand.Parameters.AddWithValue("@QuantityReturned", 0); objSQLCommand.Parameters.AddWithValue("@ReturnedTotal", 0); objSQLCommand.Parameters.AddWithValue("@Remark", ""); objSQLCommand.Transaction = objTran; noOfRowsAffected = objSQLCommand.ExecuteNonQuery(); if (noOfRowsAffected == 0) { objTran.Rollback(); break; } } } objTran.Commit(); } catch { objTran.Rollback(); throw; } finally { if (objSQLConn != null && objSQLConn.State != System.Data.ConnectionState.Closed) objSQLConn.Close(); } }