public string SaveRetailSales(DataTable dtPrdList)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                string Id = salesOrder.SaveRetailSales(this, dtPrdList, db);
                db.Stop();

                return Id;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
                dtPrdList = null;
            }
        }
        public bool RejectRetailSales()
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                bool status = salesOrder.RejectRetailSales(this, db);
                db.Stop();

                return status;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
                
            }
        }
        public string ApproveSalesRecordRetailSubproducs(DataTable dt)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                string Id = salesOrder.ApproveSalesRecordRetailSubproducs(this, dt, db);
                db.Stop();

                return Id;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
                dt = null;
            }
        }
        public DataTable GetSalesRecordMainProductListById(string salesRecordId)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                DataTable dt = salesOrder.GetSalesRecordMainProductListById(salesRecordId, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
                
            }
        }
 public bool rejectProduct(string SOID)
 {
     SalesOrderDAL newSalesDal = new SalesOrderDAL();
     bool status = false;
     try
     {
         LumexDBPlayer db = LumexDBPlayer.Start();
         status = newSalesDal.rejectProduction(db, SOID);
         db.Stop();
     }
     catch (Exception ex)
     {
         throw;
     }
     return status;
 }
 public bool UpdateSalesOrderOnApproved(string salesRecordId,string salesOrderId)
 {
     SalesOrderDAL newSalesDal = new SalesOrderDAL();
     bool status = false;
     try
     {
         LumexDBPlayer db = LumexDBPlayer.Start();
         status = newSalesDal.UpdateSalesOrderOnApproved(db, salesRecordId,salesOrderId);
         db.Stop();
     }
     catch (Exception ex)
     {
         throw;
     }
     return status;
 }
        public DataTable SaveSalesReturn(DataTable dtPrdList)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                DataTable dt = salesOrder.SaveSalesReturn(this, dtPrdList, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
                dtPrdList = null;
            }
        }
        public void SaveUncollectableAmountBySalesRecordId(string salesRecordId, string uncollectableAmount)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                salesOrder.SaveUncollectableAmountBySalesRecordId(salesRecordId, uncollectableAmount, db);
                db.Stop();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public DataTable GetDamageRecordById(string damageRecordId)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                DataTable dt = salesOrder.GetDamageRecordById(damageRecordId, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public DataTable SaveCustomerPaymentBySales()
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                DataTable dt = salesOrder.SaveCustomerPaymentBySales(this, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public DataTable GetSalesReturnsListBySalesCenterDateRangeAndStatus(string salesCenterId, string fromDate, string toDate, string status)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                DataTable dt = salesOrder.GetSalesReturnsListBySalesCenterDateRangeAndStatus(salesCenterId, fromDate, toDate, status, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public DataTable GetDamageRecordsListByWarehouseDateRangeAndStatus(string warehouseId, string fromDate, string toDate, string status)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                DataTable dt = salesOrder.GetDamageRecordsListByWarehouseDateRangeAndStatus(warehouseId, fromDate, toDate, status, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public void UpdateSalesOrderOnDelivered(string salesOrderId)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start(true);
                salesOrder.UpdateSalesOrderOnDelivered(salesOrderId, db);
                db.Stop();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public void CancelSalesOrderById(string salesOrderId)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                salesOrder.CancelSalesOrderById(salesOrderId, db);
                db.Stop();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }
        public DataTable GetPendingSalesOrdersListBySalesCenter(string salesCenterId)
        {
            SalesOrderDAL salesOrder = new SalesOrderDAL();

            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                DataTable dt = salesOrder.GetPendingSalesOrdersListBySalesCenter(salesCenterId, db);
                db.Stop();

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                salesOrder = null;
            }
        }