Esempio n. 1
0
        public int Add(BO.SaleAddBO saleAdd)
        {
            int _ID;

            try
            {
                DatabaseAccess.OpenConnection(true);
                var _ourParams = DatabaseAccess.ExecuteProcedureDML("P_Sale_AddUpdate", new List <DAL.DatabaseParameter>()
                {
                    new DAL.DatabaseParameter("@ClientID", DAL.ParameterDirection.In, DAL.DataType.Int, saleAdd.ClientID),
                    new DAL.DatabaseParameter("@SaleID", DAL.ParameterDirection.InOut, DAL.DataType.Int, saleAdd.SaleID),
                    new DAL.DatabaseParameter("@DueDays", DAL.ParameterDirection.In, DAL.DataType.Int, saleAdd.DueDays),
                    new DAL.DatabaseParameter("@SaleDate", DAL.ParameterDirection.In, DAL.DataType.Date, saleAdd.SaleDate),
                    new DAL.DatabaseParameter("@Saller", DAL.ParameterDirection.In, DAL.DataType.Int, saleAdd.SallerID),
                    new DAL.DatabaseParameter("@Buyer", DAL.ParameterDirection.In, DAL.DataType.Int, saleAdd.BuyerID),
                    new DAL.DatabaseParameter("@TotalWeight", DAL.ParameterDirection.In, DAL.DataType.Decimal, saleAdd.TotalWeight),
                    new DAL.DatabaseParameter("@RejectionWeight", DAL.ParameterDirection.In, DAL.DataType.Decimal, saleAdd.RejectionWeight),
                    new DAL.DatabaseParameter("@UnitPrice", DAL.ParameterDirection.In, DAL.DataType.Decimal, saleAdd.UnitPrice),
                    new DAL.DatabaseParameter("@LessPer", DAL.ParameterDirection.In, DAL.DataType.Decimal, saleAdd.LessPer)
                });
                DatabaseAccess.CommitTransaction();
                _ID        = Convert.ToInt32(_ourParams["@SaleID"]);
                _ourParams = null;
            }
            catch
            {
                DatabaseAccess.RollbackTransaction();
                throw;
            }
            finally
            {
                DatabaseAccess.CloseConnection();
            }
            return(_ID);
        }
Esempio n. 2
0
        public BO.SaleAddBO GetSaleDetails(int clientID, int saleID)
        {
            BO.SaleAddBO _saleAdd = null;
            try
            {
                DatabaseAccess.OpenConnection();
                using (DataSet _ds = DatabaseAccess.ExecuteProcedure("P_Sale_GetDetails", new List <DAL.DatabaseParameter>()
                {
                    new DAL.DatabaseParameter("@SaleID", DAL.ParameterDirection.In, DAL.DataType.Int, saleID),
                    new DAL.DatabaseParameter("@ClientID", DAL.ParameterDirection.In, DAL.DataType.Int, clientID)
                }))
                {
                    if (_ds != null && _ds.Tables.Count > 0)
                    {
                        var _row = _ds.Tables[0].Rows[0];
                        _saleAdd = new BO.SaleAddBO()
                        {
                            SaleDate        = Convert.ToDateTime(_row["SaleDate"]).ToString(BaseService.DefaultDateFormat),
                            SallerID        = Convert.ToInt32(_row["SallerID"]),
                            BuyerID         = Convert.ToInt32(_row["BuyerID"]),
                            DueDays         = Convert.ToInt32(_row["DueDays"]),
                            TotalWeight     = float.Parse(_row["Weight"].ToString()),
                            RejectionWeight = float.Parse(_row["RejectionWt"].ToString()),
                            UnitPrice       = float.Parse(_row["UnitPrice"].ToString()),
                            LessPer         = float.Parse(_row["LessPer"].ToString()),
                            Status          = Convert.ToInt32(_row["Status"])
                        };
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                DatabaseAccess.CloseConnection();
            }

            return(_saleAdd);
        }