|
Dear all please provide code we have 2 role 1)admin 2)user but we have only single login page when we select admin role in login page page redirect to admin panel and when role select at login page redirect to user panel
Please provide code in C#
|
|
|
|
|
Member 10678352 wrote: Please provide code in C# If you need code samples then you should try searching for them.
|
|
|
|
|
i have already searching for code but i not did not found any code...
|
|
|
|
|
|
|
|
I am trying the following sql statement on a simple windows form textbox:
select count(*) from job_orders;
then I am running the code using the following:
when I use the dtandared DataGrid from Microsoft Visual studio I get the correct result (total_count) in the row
but when I use the same with DevExpress xtraGrid I just get blank row although other sql statements are working fine in xtraGrid such as:
Select * from job_orders;
here is the code:
sql_connection = new MySqlConnection("Server=127.0.0.1;Port=3306;Database=MyDB;Uid=root;Pwd=MyPwd;Connect Timeout=360;");
sql_connection.Open();
sql_command = new MySqlCommand(txtQuery.Text, sql_connection);
sql_command.CommandType = CommandType.Text;
sql_adapter = new MySqlDataAdapter(sql_command);
sql_adapter.Fill(data_table);
dataGridView1.DataSource = null;
dataGridView1.ResetBindings();
dataGridView1.DataSource = data_table;
Technology News @ www.JassimRahma.com
|
|
|
|
|
Hi ,
i am a iphone app developer, i have decided to move to asp.net mvc now .I have litele knowledge on VC++ and c# long back.
Is it a gud decission or not?
If yes how do i start.Can any one guide me plz?
modified 21-Mar-14 5:55am.
|
|
|
|
|
|
If you are truly moving to ASP.NET (which is web based) you do not even want to think about C++ - look at C# instead.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I have a Class called horse. Its fields are name; color; age; sex.
I would like to loop thru an arry of names like trigger; royal; crown; etc.
I would like to do this.
foreach (string name in arrayNames)
{
horse name = new horse();
}
Now I have a class for each horses name. Can this be done.
Thanks Ray
|
|
|
|
|
You're creating a horse object, but then forgetting about it and it's being destroyed.
You have to add each horse to a collection to keep it alive.
You also should probably set the name of each horse after you create each instance of horse.
|
|
|
|
|
You should really declare a collection of Horses, and then in your loop, create a new Horse and give a name based on the current name in the array
List<Horse> allHorses = new List<Horse>();
foreach(string name in arrayNames)
{
horses.Add(new Horse(){ Name = name };
}
Everyone dies - but not everyone lives
|
|
|
|
|
In addition to previous answers I would create a Dictionary [^] instead of a List (given the horsename is unique).
Dictionary<string, horse> horses = new Dictionary<string, horse>();
then in your loop you can do:
foreach (string name in arrayNames)
{
horse h = new horse();
horses.add(name, h);
}
later in code you can get the horse out of the collection using the name.
In addition I would also add the name property to the horse object itself.
Hope this helps.
|
|
|
|
|
Just to add to the previous answers: you can't do that anyway.
foreach (string name in arrayNames)
{
horse name = new horse();
}
Because the declaration of your new horse inside the loop "hides" the name of the string used in the foreach - which will give you a compilation error:
A local variable named 'name' cannot be declared in this scope because it would give a different meaning to 'name', which is already used in a 'parent or current' scope to denote something else
Instead, you probably want to call it "horse" or similar so that you can access both the horse instance you just created and the name you want to give it.
BTW: You should try to follow naming conventions as they make everything slightly more understandable. And one of the conventions is that class names start with an uppercase letter: "Horse" rather than "horse":
string[] arrayNames = new string[] { "Trigger", "Royal", "Crown" };
List<Horse> horses = new List<Horse>();
foreach (string name in arrayNames)
{
Horse horse = new Horse();
horse.Name = name;
horses.Add(horse);
}
...
public class Horse
{
public string Name { get; set; }
public int Age { get; set; }
public Color Colour { get; set; }
public string Sex { get; set; }
}
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Just to throw another thing in there, the most concise way to write this in modern C# is
var horses = arrayNames.Select(n => new horse { name = n }).ToList();
ToList is optional if you only ever want to enumerate over it, but it's probably what you want in this context.
|
|
|
|
|
I have an incoming json object that I can successfully deserialize into an object. However, I now need to send that object back to the UI and to do this we use Google Proto objects.
This is what the json string looks like coming in and what it should look like going back out:
"lang\":{\"en-US\":{\"name\":\"AS Test Assembly Activity\",\"description\":\"Activity to test assembly activities\"}
I am trying to organize my proto messages that would output the same but I am having no luck. Here is what I have so far.
Proto Messages:
message CustomActivityConfig {
optional CustomActivityLanguage lang = 5;
}
message CustomActivityLanguage {
required string key = 1;
repeated LanguageData lang = 2;
}
message LanguageData {
optional string name = 1;
optional string description = 2;
}
This gives me an output of:
"lang":{"key":"en-US","lang":[{"name":"AS Test Assembly Activity","description":"Activity to test assembly activities"}
My Class structure which holds the correct data from the json at the top looks like this:
[Serializable]
public class CustomAssemblyData
{
public Dictionary<string, LangData> Lang { get; set; }
}
[Serializable]
public class LangData
{
public string Name { get; set; }
public string Description { get; set; }
}
So what I am doing is iterating through the KeyValuePair in my class above and trying to pack it into my proto message.
I feel if I can get the proto right that it should work as expected
If this helps, here is how I am currently trying to pack the proto (which gives the second incorrect json output:
var cac = new CustomActivityConfig.Builder();
foreach (KeyValuePair<string, LangData> kvp in genericAssembly.CustomActivityConfig.Lang)
{
var culture = kvp.Key;
var name = kvp.Value.Name;
var desc = kvp.Value.Description;
var langData = new LanguageData.Builder()
{
Name = name,
Description = desc
}.Build();
var customActivityLanguage = new CustomActivityLanguage.Builder()
{
Key = culture
};
customActivityLanguage.AddLang(langData);
cac.Lang = customActivityLanguage.Build();
}
Also, if anyone can answer me this: Is there any way to get rid of the field names? 'Key', 'Lang' for instance and just show the values?
Hope this makes sense. Appreciate the time.
|
|
|
|
|
What are you actually using to build the protobuf? Are you using Jon Skeet's implementation[^]?
|
|
|
|
|
I believe that is what we are using but am not 100% on it. Reason being is that the implementation is a part of our framework here and we don't touch it but rather implement it. I cannot be certain how the core framework is using it.
I've determined that the 'dataType' so to speak is a Dictionary<string, class=""> and that will allow me to deserialize the json into an object correctly.
When it comes into my area it is a json, I deserialize into a class, now I need to pack it back into a proto and send it out in the exact same format it comes in at. I can't seem to order my proto in a way that does this.
modified 21-Mar-14 10:37am.
|
|
|
|
|
Is there much overhead in WCF SSL (wsHttpBinding)? I have a web service that returns 1MB - 4MB TIFs. I originally had it on http during dev and got 3 - 5 / min (generation takes a while). Same code, but on SSL drops to 1 - 2 / min. Surely SSL can't have 50% overhead???
|
|
|
|
|
Post your question in the WCF forum.
|
|
|
|
|
Hi everyone,
I have a problem with my project.
I must to do a calendar with days and hours.
On the first's datagridview row I want to write this hour (07:00:00).
At this hour I want to add 30 minutes automatically.
I want that my output is like this:
07:00:00
07:30:00
08:00:00
08:30:00
...
But, it didn't works correctly.
This is my code:
TimeSpan ora = TimeSpan.FromHours(7);
TimeSpan mezzora = TimeSpan.FromMinutes(0);
TimeSpan orario;
for (int i = 0; i < 20; i++)
{
dataGridView2.Rows.Add("");
orario = ora + mezzora;
dataGridView2[0, i].Value = orario;
mezzora = TimeSpan.FromMinutes(30);
}
In output I have this:
07:00:00
07:30:00
07:30:00
07:30:00
Can you help me?
|
|
|
|
|
The issue that you have is that you never allocate the new time increment to ora, and mezzora never changes. Fortunately, you can update mezzora with no problem using the following:
mezzora = TimeSpan.FromMinutes(30 * (i + 1)); What you're doing here is multiplying the minutes by the increment of i (you need to add 1 to the count because you have a zero offset here.
|
|
|
|
|
It works !
Thanks so much Pete O'Hanlon !
|
|
|
|
|
You're welcome. I'm glad that I could help.
|
|
|
|