public static List<Package> GetAll(Package srchPackage, string executedBy)
        {
            List<Package> cusList = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Package_GetAll);

                db.AddInParameter(cmd, "IsActive", DbType.Boolean, srchPackage.IsActive);
                db.AddInParameter(cmd, "PackageCode", DbType.String, srchPackage.PackageCode);
                db.AddInParameter(cmd, "PackageName", DbType.String, srchPackage.PackageName);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, srchPackage.ItemID);

                DataSet ds = db.ExecuteDataSet(cmd);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    cusList = Utility.DataTableToCollection<Package>(ds.Tables[0]);
                }
            }
            catch (Exception ex)
            {
                cusList = null;
            }

            return cusList;
        }
 public static bool UpdatePackage(Package package, string executedBy)
 {
     return PackageDAO.Update(package, executedBy);
 }
 public static List<Package> GetAllPackage(Package srchPackage, string executedBy)
 {
     return PackageDAO.GetAll(srchPackage, executedBy);
 }
 public static bool AddPackage(Package package, string executedBy)
 {
     return PackageDAO.Insert(package, executedBy);
 }
        public static bool Insert(Package package, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Package_Insert);

                db.AddInParameter(cmd, "ItemID", DbType.Int32, package.Item.ItemID);
                db.AddInParameter(cmd, "QtyPerPack", DbType.Int32, package.QtyPerPack);
                db.AddInParameter(cmd, "PackageName", DbType.String, package.PackageName);
                db.AddInParameter(cmd, "IsActive", DbType.Boolean, package.IsActive);
                db.AddInParameter(cmd, "CreatedBy", DbType.Int32, 1);

                db.AddOutParameter(cmd, "NewID", DbType.Int32, 4);

                db.ExecuteNonQuery(cmd);

                int newID = 0;
                int.TryParse(db.GetParameterValue(cmd, "NewID").ToString(), out newID);

                if (newID > 0)
                {
                    rslt = true;
                    package.PackageID = newID;
                }
            }

            catch (Exception ex)
            {
                rslt = false;
            }

            return rslt;
        }
        public static bool Update(Package package, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Package_Update);

                db.AddInParameter(cmd, "PackageID", DbType.Int32, package.PackageID);
                db.AddInParameter(cmd, "QtyPerPack", DbType.Int32, package.QtyPerPack);
                db.AddInParameter(cmd, "PackageName", DbType.String, package.PackageName);
                db.AddInParameter(cmd, "IsActive", DbType.Boolean, package.IsActive);
                db.AddInParameter(cmd, "UpdatedBY", DbType.Int32, 1);

                db.ExecuteNonQuery(cmd);

                rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
            }

            return rslt;
        }
        public ActionResult Index(FormCollection collection)
        {
            //get the non property checkbox value , find a more suitable way later
            bool bIsActive = Request.Form.GetValues("active") != null && Request.Form.GetValues("active")[0] != null ? true : false;
            string item = Request.Form.GetValues("Items") != null ? Request.Form.GetValues("Items")[0] : "";

            Package srchPackage = new Package();
            srchPackage.ItemID = int.Parse(item.ToString());
            srchPackage.PackageName = collection["name"].Trim();
            srchPackage.IsActive = bIsActive;
            srchPackage.PackageCode = "";

            List<Package> packList = PackageManager.GetAllPackage(srchPackage, "nirshan");
            List<PackageModel> customerList = Utility.ConvetrToList<PackageModel, Package>(packList);

            List<SelectListItem> Items;
            Items = GetItemsSelectList();
            ViewBag.Items = Items;

            return View(customerList);
        }
        //
        // GET: /Package/
        public ActionResult Index()
        {
            Package sample = new Package() { PackageCode = "", PackageName = "", IsActive = true };
            List<PackageModel> packages = Utility.ConvetrToList<PackageModel, Package>(PackageManager.GetAllPackage(sample, "nirshan"));

            List<SelectListItem> Items;
            Items = GetItemsSelectList();
            ViewBag.Items = Items;

            return View(packages);
        }