public string AddCategoryInfoAjax(Categoryinfo Info, string CategoryDesc, string CategoryId, string userId, string mode)//string AgencyId { try { command.Connection = Connection; command.CommandText = "SP_addcategory"; command.Parameters.AddWithValue("@CategoryID", CategoryId); command.Parameters.AddWithValue("@mode", mode); command.Parameters.AddWithValue("@CategoryDesc", CategoryDesc); command.Parameters.AddWithValue("@CreatedBy", userId); command.Parameters.AddWithValue("@result", "").Direction = ParameterDirection.Output; command.CommandType = CommandType.StoredProcedure; _dataset = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(command); da.Fill(_dataset); try { List <FingerprintsModel.Categoryinfo.CategoryDetail> _categorylist = new List <FingerprintsModel.Categoryinfo.CategoryDetail>(); if (_dataset.Tables[0] != null && _dataset.Tables[0].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[0].Rows) { FingerprintsModel.Categoryinfo.CategoryDetail obj = new FingerprintsModel.Categoryinfo.CategoryDetail(); obj.Id = dr["CategoryID"].ToString(); obj.Name = dr["Description"].ToString(); _categorylist.Add(obj); } } Info.categoryList = _categorylist; } catch (Exception ex) { clsError.WriteException(ex); } return(command.Parameters["@result"].Value.ToString()); } catch (Exception ex) { clsError.WriteException(ex); } finally { Connection.Close(); command.Dispose(); } return(command.Parameters["@result"].Value.ToString()); }
public Categoryinfo GetCategoryList() { // List<AgencyStaff> _agencyStafflist = new List<AgencyStaff>(); Categoryinfo Info = new Categoryinfo(); try { DataSet ds = null; using (SqlConnection Connection = connection.returnConnection()) { using (SqlCommand command = new SqlCommand()) { ds = new DataSet(); command.Connection = Connection; command.CommandText = "Sp_Sel_CategoryInfo"; command.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(command); da.Fill(ds); } try { List <FingerprintsModel.Categoryinfo.CategoryDetail> _categorylist = new List <FingerprintsModel.Categoryinfo.CategoryDetail>(); foreach (DataRow dr in ds.Tables[0].Rows) { FingerprintsModel.Categoryinfo.CategoryDetail obj = new FingerprintsModel.Categoryinfo.CategoryDetail(); obj.Id = dr["CategoryId"].ToString(); obj.Name = dr["Description"].ToString(); _categorylist.Add(obj); } // _rolelist.Insert(0, new Role() { RoleId = "0", RoleName = "Select" }); Info.categoryList = _categorylist; } catch (Exception ex) { clsError.WriteException(ex); } } } catch (Exception ex) { clsError.WriteException(ex); } return(Info); }