Exemple #1
0
        public bool AddSuppliers(Supplier supplier)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Supplier_Insert);

                db.AddInParameter(dbCommand, "@sSup_Code", DbType.String, supplier.Sup_Code);
                db.AddInParameter(dbCommand, "@sSupplierName", DbType.String, supplier.SupplierName);
                db.AddInParameter(dbCommand, "@sSupplierPhone", DbType.String, supplier.SupplierPhone);
                db.AddInParameter(dbCommand, "@sSupplierContact", DbType.String, supplier.SupplierContact);
                db.AddInParameter(dbCommand, "@sSupplierAddress", DbType.String, supplier.SupplierAddress);
                db.AddInParameter(dbCommand, "@bIsActive", DbType.Boolean, supplier.IsActive);
                db.AddInParameter(dbCommand, "@iCreatedUser", DbType.Int32, supplier.CreatedUser);
                db.AddInParameter(dbCommand, "@iModifiedBy", DbType.Int32, supplier.ModifiedBy);

                db.AddOutParameter(dbCommand, "@iSupId", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    int newSupplierID = (int)db.GetParameterValue(dbCommand, "@iSupId");

                    if (newSupplierID > 0)
                    {
                        success = true;
                        supplier.SupId = newSupplierID;
                    }
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItems(Item item)");
                throw ex;
            }
            return success;
        }
Exemple #2
0
        public bool DeleteSuppliers(Supplier supplier)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Supplier_Delete);

                db.AddInParameter(dbCommand, "@iSupId", DbType.Int32, supplier.SupId);

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    success = true;
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItems(Item item)");
                throw ex;
            }
            return success;
        }
Exemple #3
0
        public bool GetSupplierByID(Supplier supplier)
        {
            bool success = false;
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constant.Database_Connection_Name);
                DbCommand dbCommand = db.GetStoredProcCommand(Constant.SP_Supplier_GetByID);

                db.AddInParameter(dbCommand, "@iSupId", DbType.Int32, supplier.SupId);

                IDataReader reader = db.ExecuteReader(dbCommand);

                if (reader != null)
                {
                    while (reader.Read())
                    {
                        supplier.SupId = reader["SupId"] != DBNull.Value ? Convert.ToInt32(reader["SupId"].ToString()) : 0;
                        supplier.Sup_Code = reader["Sup_Code"].ToString();
                        supplier.SupplierName = reader["SupplierName"].ToString();
                        supplier.SupplierPhone = reader["SupplierPhone"].ToString();
                        supplier.SupplierContact = reader["SupplierContact"].ToString();
                        supplier.SupplierAddress = reader["SupplierAddress"].ToString();
                        supplier.IsActive = reader["IsActive"] != DBNull.Value ? Convert.ToBoolean(reader["IsActive"].ToString()) : false;
                        supplier.CreatedUser = reader["CreatedUser"] != DBNull.Value ? Convert.ToInt32(reader["CreatedUser"].ToString()) : 0;
                        supplier.CreatedDate = reader["CreatedDate"] != DBNull.Value ? Convert.ToDateTime(reader["CreatedDate"].ToString()) : DateTime.Now;
                        supplier.ModifiedBy = reader["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(reader["ModifiedBy"].ToString()) : 0;
                        supplier.ModifiedDate = reader["ModifiedDate"] != DBNull.Value ? Convert.ToDateTime(reader["ModifiedDate"].ToString()) : DateTime.Now;
                        supplier.CreditAmmount = reader["CreditAmmount"] != DBNull.Value ? Convert.ToDecimal(reader["CreditAmmount"].ToString()) : 0;
                        success = true;
                    }
                }

                if (db.ExecuteNonQuery(dbCommand) > 0)
                {
                    success = true;
                }

            }
            catch (System.Exception ex)
            {
                ex.Data.Add("BusinessLayerException", GetType().ToString() + Constant.Error_Seperator + "public bool AddItems(Item item)");
                throw ex;
            }
            return success;
        }