I am trying to get the values that i inserted in the database dynamically but I can't get the value.
here my code
String[] SchoolName = request.getParameterValues("shoolname");
String[] DateFrom = request.getParameterValues("Dateform");
String[] DateTo = request.getParameterValues("Datato");
String[] DiscriptDetails = request.getParameterValues("Dscript");
this for insert data and its working well.
for ( int i = 0 ; i < SchoolName.length;++i ) {
educatiodetails edu = new educatiodetails();
edu.setSchoolName(SchoolName[i]);
edu.setDateFrom(DateFrom[i]);
edu.setDateTo(DateTo[i]);
edu.setDiscriptDetails(DiscriptDetails[i]);
EducatiIMP education = new EducatiIMP();
education.addEducation(edu);
HttpSession session = request.getSession(true);
//here I am trying to get values
addEducation.getList();
educatiodetails educat =education.geteducatiodetails(SchoolName[i]);
//here my session just get the first value
session.setAttribute("educat",educat);
}
}
Related
I am using the Remedy API for Java.
How do I get a User ID or the User GUID from a Remedy User using java?
I do a simple logon using something like the following:
ARServerUser sUser = new ARServerUser("server", "port", "user", "pass", 1);
The sUser object however does not have any userid or guid inside it?
I have looked at the API and cannot find a method to retrieve it. I have also tried looking in the UserInfo object, but that also doe not contain it?
Any ideas?
Thanks
Sample code to fetch ALL details for a User.
ARServerUser arConnection = new ARServerUser("server", "port", "user", "pass", 1);
List<SortInfo> sortList = new ArrayList<SortInfo>();
int firstRetreive = 0;
int maxRetreive = maxNumEntries;//1M
OutputInteger numMatches = new OutputInteger();
ResultEntryList iterator = new ResultEntryList(data);
QualifierInfo qiPlain = new QualifierInfo();
//make field list for results
List<Field> fields = arConnection.getListFieldObjects(formName);
ArrayList<Integer> alFieldIds = new ArrayList<Integer>();
for (int x = 0; x <
fields.size(); x++) {
alFieldIds.add(fields.get(x).getFieldID());
}
int[] fieldIds = new int[alFieldIds.size()];
for (int i = 0; i < fieldIds.length; i++) {
fieldIds[i] = ((Integer) alFieldIds.get(i)).intValue();
}
arConnection.getListEntryObjects("User", qiPlain, firstRetreive, maxRetreive, sortList, fieldIds, false, numMatches, iterator);
If you just want the ids, you can skip the retrieval of all the field IDs. unfortunately I cannot remember the ID of the username field. Substitute the xxx with its ID)
ARServerUser arConnection = new ARServerUser("server", "port", "user", "pass", 1);
List<SortInfo> sortList = new ArrayList<SortInfo>();
int firstRetreive = 0;
int maxRetreive = maxNumEntries;//1M
OutputInteger numMatches = new OutputInteger();
ResultEntryList iterator = new ResultEntryList(data);
QualifierInfo qiPlain = new QualifierInfo();
//make field list for results
int[] fieldIds = {Constants.AR_CORE_ENTRY_ID, xxx};
arConnection.getListEntryObjects("User", qiPlain, firstRetreive, maxRetreive, sortList, fieldIds, false, numMatches, iterator);
I am using Entity Framework. I have the following query in which I get data using two tables Application and Employee connected by a foreign key EmployeeID in Application Table. The tables have 1-1 relationship .
Is there a way to simplify the following code and get rid of the DTO Employee1
which is the same as auto generated Employee class
public List<Employee1> GetApplicant(int ApplicationID)
{
var context = new FPSDB_newEntities();
var data = (from a in context.Applications
join e in context.Employees on a.EmployeeID equals e.EmployeeID
where
(
a.ApplicationID == ApplicationID
)
select new Employee1
{
EmployeeID = e.EmployeeID,
SecondEmail = e.SecondEmail,
EmailID = e.EmailID,
Title = e.Title,
Name = e.Name,
Rank = e.Rank,
POBox = e.POBox,
Phone = e.Phone,
JoinDate = e.JoinDate,
Status = e.Status,
DepartmentID = e.DepartmentID.Value,
NameString = e.NameString,
Department = e.Department,
ParentDept = e.ParentDept,
DepartmentAr = e.DepartmentAr,
NameAr = e.NameAr,
NameStringAr = e.NameStringAr,
TitleAr = e.TitleAr
}).ToList();
return data;
}
If you need to return list of Employees, just select e which refers to Employee and don't use Employee1 as a DTO.
public List<Employee> GetApplicant(int ApplicationID)
{
var context = new FPSDB_newEntities();
var data = (from a in context.Applications
join e in context.Employees on a.EmployeeID equals e.EmployeeID
where
(
a.ApplicationID == ApplicationID
)
select e).ToList();
return data;
}
Another way is this, which I would prefer because of readability:
public List<Employee> GetApplicant(int ApplicationID)
{
var context = new FPSDB_newEntities();
var data = context.Applications.Where(p=>p.ApplicationID == ApplicationID).Select(p=>p.Employee).ToList();
return data;
}
I'm simply trying to do this, so later on when I save my values in the database they should be set to null incase the textfield is empty.
int? DeliveryAdrID = null;
int.TryParse(TextBoxDeliveryAdrID.Text, out DeliveryAdrID);
But I'm having an error parsing it along.
The above solution should later on make it possible to save empty textbox values in the database as "NULL" instead of 0.
The whole solution:
int parsedValue;
int? DeliveryAdrID = int.TryParse(TextBoxDeliveryAdrID.Text, out parsedValue) ? parsedValue : (int?)null;
int id = Convert.ToInt32(GridViewData.SelectedValue.ToString());
var data = tf.DBTable.Where(a => a.ID == id).FirstOrDefault();
if (data == null)
{
DBTable mt = new DBTable();
mt.Customer = TextBoxCustomer.Text;
mt.Country = TextBoxCountry.Text;
mt.DeliveryAdrID = parsedValue;
tf.DBTable.AddObject(mt);
tf.SaveChanges();
}
else
{
data.Customer = TextBoxCustomer.Text;
data.Country = TextBoxCountry.Text;
data.DeliveryAdrID = parsedValue;
tf.SaveChanges();
}
}
You cannot give a nullable int to int.TryParse. It must be an int. What you are trying to do can be accomplished like so:
int parsedValue;
int? DeliveryAdrID = int.TryParse(TextBoxDeliveryAdrID.Text, out parsedValue) ? parsedValue : (int?) null;
on the web service side I am applying
StoreRequestParameters parameters = new StoreRequestParameters(this.Context);
string condition= parameters.GridFilters.ToString();
//I ma sending this to the methot "List<Ks> Get(....)"
to get the gridfilter parameters.
inside the other methot ,trying to get the selected gridfilters values like this.
public List<Ks> Get(int start, int limit, string sort, string terssiralama, string condition, out int totalrow)
{
FilterConditions fc = new FilterConditions(condition);
foreach (FilterCondition cnd in fc.Conditions)
{
Comparison comparison = cnd.Comparison;
string fi = cnd.Field;
FilterType type = cnd.Type;
switch (cnd.Type)
{
case FilterType.Date:
switch (comparison)
{
case Comparison.Eq:
field1 = cnd.Field;
cmp1 = "=";
value1 = cnd.Value<string>();
...........
..........
}
but I failed getting the values like this
FilterConditions fc = new FilterConditions(condition);
I couldnt pass the string values .
should I serializes or deserilized first ?
StoreRequestParameters parameters = new StoreRequestParameters(this.Context);
instead of using this, string condition= parameters.GridFilters.ToString();
I use this
string obj = this.Context.Request["filter"];
and pass it to the
FilterConditions fc = new FilterConditions(obj);
It can be reach all filter condition in fc filtercondition variable.
I have dynamically created textbox in asp.net. Now i am extracting the values through following code.
string[] sublist = new string[] { };
int[] maxmarkslist = new int[] { };
int i;
for (i = 0; i < Convert.ToInt32(Label15.Text); i++)
{
string sub = "subject" + i;
string marks = "maxmarks" + i;
TextBox subject = (TextBox)PlaceHolder1.FindControl(sub);
TextBox maxmarks = (TextBox)PlaceHolder1.FindControl(marks);
sublist[i] = subject.Text;
maxmarkslist[i] = Convert.ToInt32(maxmarks.Text);
}
But I getting error "Index was outside the bounds of the array" for the below two lines:
sublist[i] = subject.Text;
maxmarkslist[i] = Convert.ToInt32(maxmarks.Text);
When I debugged it, values are coming in subject.Text and maxmarks.Text but not going to array.
Did I define the array in a wrong way?
You define both the arrays as empty arrays. So you will get index out of bound erros if you try to index into those.
Arrays are not dynamically expanding. If you want that, use a collection type and may be later convert to an array.
Try this:
int length = Convert.ToInt32(Label15.Text);
string[] sublist = new string[length-1];
int[] maxmarkslist = new int[length-1];
for (int i = 0; i < length; i++)
{
string sub = "subject" + i;
string marks = "maxmarks" + i;
TextBox subject = (TextBox)PlaceHolder1.FindControl(sub);
TextBox maxmarks = (TextBox)PlaceHolder1.FindControl(marks);
sublist[i] = subject.Text;
maxmarkslist[i] = Convert.ToInt32(maxmarks.Text);
}
Or here is how to do this with a collection (List) type:
int length = Convert.ToInt32(Label15.Text);
List<string> sublist1 = new List<string>();
List<int> maxmarkslist1 = new List<int>();
for (int i = 0; i < Convert.ToInt32(Label15.Text); i++)
{
string sub = "subject" + i;
string marks = "maxmarks" + i;
TextBox subject = (TextBox)PlaceHolder1.FindControl(sub);
TextBox maxmarks = (TextBox)PlaceHolder1.FindControl(marks);
sublist1.Add(subject.Text);
maxmarkslist1.Add(Convert.ToInt32(maxmarks.Text));
}
string[] sublist = sublist1.ToArray();
int[] maxmarkslist = maxmarkslist1.ToArray();
Note with collections you dont have to specify the size upfront. But keep adding items to it as it can expand as needed. But arrays can not do this.
Your string[] sublist = new string[] { }; is a shortcut method where you create and initialize the array. In that you don't have to specify the size, but compiler will count the elements between {} and set the size appropriately. In your case since there are no elements inside {} it will create an empty array.
string[] sublist = new string[100];
int[] maxmarkslist = new int[100];
Put this..replace 100 with the max possible value of your loop...but this is not a good practice...will come back to this thread if i found something better...