예제 #1
0
        private static List<BranchInfo> FillBranchCollection(IDataReader reader, out int totalRecords)
        {
            var retVal = new List<BranchInfo>();
            totalRecords = 0;
            try
            {
                while (reader.Read())
                {
                    //fill business object
                    var info = new BranchInfo();

                    info.BranchId = ConvertHelper.ToInt32(reader["BranchId"]);

                    info.Code = ConvertHelper.ToString(reader["Code"]);

                    info.Name = ConvertHelper.ToString(reader["Name"]);

                    info.LocationID = ConvertHelper.ToInt32(reader["LocationID"]);

                    info.Description = ConvertHelper.ToString(reader["Description"]);

                    info.Status = ConvertHelper.ToInt32(reader["Status"]);

                    info.CreatedBy = ConvertHelper.ToInt32(reader["CreatedBy"]);

                    info.ChangedBy = ConvertHelper.ToInt32(reader["ChangedBy"]);

                    info.CreatedDate = ConvertHelper.ToDateTime(reader["CreatedDate"]);

                    info.ChangedDate = ConvertHelper.ToDateTime(reader["ChangedDate"]);

                    retVal.Add(info);
                }
                //Get the next result (containing the total)
                reader.NextResult();

                //Get the total no of records from the second result
                if (reader.Read())
                {
                    totalRecords = Convert.ToInt32(reader[0]);
                }

            }
            catch (Exception exc)
            {
                //DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                ObjectHelper.CloseDataReader(reader, true);
            }
            return retVal;
        }
예제 #2
0
        public string Edit(FormDataCollection form)
        {
            var retVal = string.Empty;
            var operation = form.Get("oper");
            var id = ConvertHelper.ToInt32(form.Get("BranchId"));
            if (!string.IsNullOrEmpty(operation))
            {
                BranchInfo info;
                switch (operation)
                {
                    case "edit":
                        info = BranchRepository.GetInfo(id);
                        if (info != null)
                        {

                            info.Code = form.Get("Code");
                            info.Name = form.Get("Name");
                            info.LocationID = ConvertHelper.ToInt32(form.Get("LocationName"));
                            info.Description = form.Get("Description");
                            //info.Status = form.Get("Status");
                            info.ChangedBy = UserRepository.GetCurrentUserInfo().UserID;
                            BranchRepository.Update(info);

                        }
                        break;
                    case "add":
                        info = new BranchInfo
                               {
                                   Code = form.Get("Code"),
                                   Name = form.Get("Name"),
                                   LocationID = ConvertHelper.ToInt32(form.Get("LocationName")),
                                   Description = form.Get("Description"),
                                   //Status = form.Get("Status"),
                                   CreatedBy = UserRepository.GetCurrentUserInfo().UserID
                               };

                        BranchRepository.Create(info);
                        break;
                    case "del":
                        BranchRepository.Delete(id,UserRepository.GetCurrentUserInfo().UserID);
                        break;
                }
            }
            StoreData.ListBranch = BranchRepository.GetAll();
            return retVal;
        }
예제 #3
0
 public static void Update(BranchInfo info)
 {
     DataProvider.Instance().Branches_Update( info.BranchId, info.Code, info.Name, info.LocationID, info.Description, info.ChangedBy);
 }
예제 #4
0
 public static int Create(BranchInfo info)
 {
     //var retVal = CachingProvider.Instance().Get()
     var retVal =  DataProvider.Instance().Branches_Insert( info.Code, info.Name, info.LocationID, info.Description, info.CreatedBy);
     return retVal;
 }