pitic 15 Newbie Poster

Hi. Though I haven't done it myself yet, I found a lot of examples online on how to do it. Here are a few links that can get you started. Once you have some code feel free to ask for help if needed.

MSDN Blog
MSDN
Codeproject Example

pitic 15 Newbie Poster

Hi. Can you also post the Flight class? And the full Create Job view where you use Html.Partial()

pitic 15 Newbie Poster

string statementcmd = "insert into register_user (pid,username,pwd,fullname) values (1,'" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "')";

it wasn't that had to correct... just removed a double quote near 1

pitic 15 Newbie Poster

Try this version (encapsulated textboxes in single quotes and removed quotes from pid value)

string statementcmd =  "insert into register_user (pid,username,pwd,fullname) values ("1,'" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "')";
pitic 15 Newbie Poster

After you set the ReadAndExecute permission on the parent folder do a loop through all the directories inside that folder and set their appropriate permissions

foreach (var folder in dInfo.GetDirectories())
{
    var security = folder.GetAccessControl();
    security.AddAccessRule(...);
    folder.SetAccessControl(security);
}
pitic 15 Newbie Poster

From looking at the error's documentation I'm guessing one of your textboxes' text contains a column name. You can refer to this page to see if this is the case.
Click Here

It also gives you an example of what might be wrong.

pitic 15 Newbie Poster

Of course you can. It really isn't a C# issue. The database server should be configured to allow remote access and that's it. There are a lot of tutorials about how to connect to a DB server.

After you decided which one you'll use (MSSQL, MySql, Oracle...) just enable remote access, authentication and access rights and you're good to go.

If you need any specific guidance let me know and I'll help you out.

pitic 15 Newbie Poster

Hi. Since you went with this approach to create your connection classs, in the OPEN method only open the connection if it is closed.

if (csCon.State == ConnectionState.Closed)
{
    csCon.Open();
}
ddanbe commented: Great. +15
pitic 15 Newbie Poster

Loop the split array with a foreach and add it to the same string + Environment.NewLine and finally set the textBox1.Text property with the string.

pitic 15 Newbie Poster

That wasn't supposed to be read as... duplicate their website... only to give you a starting template to work upon. Or at least use their styling to implement yours :)

pitic 15 Newbie Poster

well then... use a web downloader to get the page and updateit to your liking :)

pitic 15 Newbie Poster

It's a dynamic table I'm working with and I don't know upfront the number of rows I have. So depends on user selection. He could select 3 columns to display or 300. So the "MyObject" class would store the column name and value, and for the rows I'm using the List<MyObject>.

The problem is I'm using SSRS to build some custom reports (user made) and I have to make everything dynamic. Which pretty much limits the possibilities.

pitic 15 Newbie Poster
  1. learn css
  2. gradually disable css on that page to see how it starts / progresses from scratch
  3. have a designer's eye / mind
pitic 15 Newbie Poster

Yes you are. That would just give me an orderd list like this.

BirthDate    01-01-1900
...
FirstName    Jane
FirstName    John
...
LastName     Whalberg

The list example I gave should give you an idea of what the table will look like.

FirstName LastName BirthDate

With their sorted values. The problem is I have to sort the List before I turn it into a table.

pitic 15 Newbie Poster
pitic 15 Newbie Poster

Hey,

Who can give me a hint on this case?

Let's say I have an object "MyObject" with the following properties (this is a breakdown for easier explination)

public clas MyObject
{
    public string Column { get; set; }
    public string Value { get; set; }
    public int Row { get; set; }
}

When this get's populated I then create a List<MyObject> which I need to sort based on different column names.
Ex: this is how the list would look like when populated. The ElementAt(i) is there to signify that there is a MyObject instance in the list.

ElementAt(i) Row Column Value
0 1 FirstName John
0 1 LastName Doe
0 1 BirthDate 01-01-1900
1 2 FirstName Jane
1 2 LastName Doe
1 2 BirthDate 01-01-1901
2 3 FirstName Mary
2 3 LastName Poppins
2 3 BirthDate 01-01-1910
3 4 FirstName Mark
3 4 LastName Whalberg
3 4 BirthDate 01-01-1905

As you can see I can easily pivot it to a table which get displayed into a report afterwards. How would you go about sorting it by "Column" value before sending it to the report. Right now I only found a cumbersome way of translating it to a DataTable and do the sorting there and then recreate the list to pass to the report.

Thanks

pitic 15 Newbie Poster

Yep. If you worked with ASP.NET Webforms, partial views are the same as ascx files. They get loaded into the layout view (or master page in webforms).
If you want to save bandwith then go for ajax + partial view and replace the <div> (or whatever) on the master view (which is already loaded) with the new content

pitic 15 Newbie Poster

It realy depends on how you call your action. If it's a normal http get request it loads the layout + view + every partial.
If you want only the partial view to be retunred do an ajax call and replace the content with the result.

pitic 15 Newbie Poster

Probably soverflow :D

pitic 15 Newbie Poster

Ok. So what have you done so far and where are you stuck?

pitic 15 Newbie Poster

Or just MessageBox.Show("Hello World!"); :)

pitic 15 Newbie Poster

Do a File.ReadLines(), loop the lines and try parsing each line to a double value. If it succedes you have your text to fill up the lines until the following double exists.

pitic 15 Newbie Poster

Try setting the width to 0 and change it back when disaplying it

pitic 15 Newbie Poster

The solution was something to get you started with. The problem with this one is that if you have multiple orders of same type and 0 orders of the other it will still show up.

be in a list, it can be 3, 4, or more.

d who (customers) buy 101 and 102(in first step) then retu

2 - i need who (customers) buy 101 and 102(in first step) then return rows of this customer that payed(second step).
but in you solution use or (o.ordId == 101 || o.ordId == 102).

Of course it is ||. You can't have an order with ordId = 101 && ordId = 102. That's like saying give me the row which has both values in the ordId. My condition selects all orders with those id's.

To bypass the issue I mentioned you could select orders with 101, than orders with 102 and intersect those lists to see where you have the same customer.

pitic 15 Newbie Poster

I think I understood what you want. Select the customers that have at least 1 order 101 and at least 1 order 102 and payment true. Notice you said "and" not "or".

Here is what I came up with so far.

Get customer ids that have both at least 1 order of 101 and 102 and payment true:

var customerIds = tblOrders.Where(o => o.payment == true && (o.ordId == 101 || o.ordId == 102))
                .GroupBy(o => o.customerId)
                .Select(grp => new { Count = grp.Count(), CustomerId = grp.Key })
                .Where(g => g.Count > 1).Select(c => c.CustomerId);

Select based on joined list of customer ids

var results = from o in tblOrders
                join c in tblCustomers on o.customerId equals c.id
                where customerIds.Contains(o.customerId) && o.payment == true
                select new { o.id, c.name, o.ordId };

If you meant to say 101 OR 102 it's easy... select the customer ids from orders where your conditions meet and do a join with this list of ids.

pitic 15 Newbie Poster

What exactly is your problem? You need the SQL syntax for select? Or the linq syntax?
And based on your example where (orderId = 101 and orderId = 102) you would never get the result you mentioned. (which include ordId 100).

pitic 15 Newbie Poster

Da**it... I had the C# forum opened... It should be in ASP.NET

pitic 15 Newbie Poster

Hi everyone,

I have a tricky question, at least for me. We have a website deployed on IIS that once in a while throws a NullPointerException when trying to read the HttpContext.Current.Application["JScriptRootPath"] value.

So this is the whole scenario:

This is just a key added in the Web.config file that is read in default.aspx.cs at application start and stored in the HttpContext.Application dictionary. This is used on our master page so it is accesses on all views (MVC 4 with Razor).

But... sometimes it throws this error. Now I have been able to get the error while debug-ing the IIS instance with Visual Studio, and the weird thing is, I can see the variable in the dictionary. This behavior also occurs if running the site with Visual Studio Development Server.

I have disabled Rapid Fail Protection for the Application Pool that the site runs under and it seems to have resolved the issue. But now I don't understand why I'm getting the error in Visual Studio Development Server. Since the app pool is available only under IIS (right?).

I have finally decided to change the logic and hold that value somwhere else, but I was wondering if anyone got this behavior and see what they did to prevent it.

Thanks

pitic 15 Newbie Poster

Look through your code... there is a point when you actually do that, just the conditions don't get you there all the time.

pitic 15 Newbie Poster

Deferred execution might not make a difference in smaller tasks. The point of lazy execution is to not retrieve the data unless you need it. For example in a linq expression against a table:

var a = customers.Where(Active).(c => c.Name);

Lazy execution would not load the whole table into memory, but instead take the next customer when MoveNext() is called on the IEnumerator. And as far as I know that would mean the GarbageColletor would be called fewer times.

You might be right also, that when used incorrectly it could result in a decrease in performance.

pitic 15 Newbie Poster

It's because SelectedPiece is instantiated but it's properties are not. So SelectedPiece is just a new Piece qith nothing in it... no Moves, no name...

pitic 15 Newbie Poster

Just clicking the select button doesn't throw any exception for me. If you run the program from Visual Studio when it throws an uncaught exception the IDE jumps to the line of code where the exception occured. Check that line.

pitic 15 Newbie Poster

What error? Paste the error here.

pitic 15 Newbie Poster

Because you are building all the buttons and delegate a click event btn_Click.

Inside the btn_Click event you are creating a NEW button which is not added to the form and use the btn_PieceClick event for the Click action on it. This button just exists as an object in the application. it is not displayed. You have to do the coloring part inside the btn_Click event.

pitic 15 Newbie Poster

Read the comment above.

Whenever you get stuck... take a deep breath and think of it logically. It may seem hard at first but when you'll do it the first time you'll see how easy it is.

Think of this line like this:

  • SelectedPiece - what's that... check where SelectedPiece is declared
  • oh... it's an object of type Pieces
  • let's check what particularities the object Pieces has
  • this object has moves, name...
  • the moves property is of type Movement
  • let's check what particularities the object Movement has
  • and so on...
  • you'll eventually get to the correct conclusion
pitic 15 Newbie Poster

This line actually tells you that the Piece object has a Moves property of type Movement. It does not contain anything until you explicitly set it.

Pieces p = new Pieces();
Movement move = new Movement();
p.Moves = move;

Then you can set the Movement properties for that Pieces.

pitic 15 Newbie Poster

In this case, the foreach loop requires a ReadAllLines instead of a line by line read. So unless you need the whole file in memory at once there is no reason not to use while. Besides, the StreamReader uses lazy evaluation which increases performance... so they say

pitic 15 Newbie Poster

Same code I provided goes for showing movements. You just need to arrange the pieces (you could even have a graphical representation of a piece - image) and get the selected piece on button press instead of select button click.

pitic 15 Newbie Poster

Check the Web.config file for the "IsTesting" key.

pitic 15 Newbie Poster

As far as I know foreach loops are always slower than while/for. Although the syntax looks clearer, I don't know if there are any other advantages to what he needs.

pitic 15 Newbie Poster

What do you mean by "Pieces On The board"? Like simulate a chess game where the chess piecess are actually visible?

pitic 15 Newbie Poster

Your while condition is wrong. It should be while ((line = sr.ReadLine()) != null)

pitic 15 Newbie Poster

You said you already did that in the first post...

pitic 15 Newbie Poster
  1. part this is a piece object used when you select one from the radio button list. There is a global Pieces called "SelectedPiece" which gets initialized when you click the select button. The piece has a name (king, queen...), a Movement object (which in turn has the properties from the 2 part you asked about) and a StartingPosition (which i did not use eventually :))

  2. part these are the properties of a movement. It has a list of directions (up, down...) where a piece can move, a maximum number of steps it can take (1 for king) and a complex direction which you can use to simulate the knight movement (2 verticaly, 1 horizontaly).

The code is pretty much self explanatory... you have one chess piece which has a movement option. the movement has direction and max limit.

Check out btn_selectClick to see how I defined the king and queen.

pitic 15 Newbie Poster

Why don't you just add the wsdl as a web reference to your project? This way it will automatically create all the necessary code so you can access any method in that web service.

pitic 15 Newbie Poster

Did you check the Event Viewer for any errors in IIS? Also verify that the Application Pool used for the website (which I assumed it is) is correctlly set and started. Verify the .Net Framework for the App Pool. Did you run aspnet_regiis ?

pitic 15 Newbie Poster

I made some changes to your code to get you started. First of all you have to think of a chess board/piece. A piece has directions of movement, movement pattern and maximum moves. I added a class that simulates these three attributes of a chess piece. So once you load the program, select one piece and it will give it the right attributes. Then if you click on a chess board button it shows where it can go.

  • the coloring part is pretty much done (except the knight)
  • I have replaced the positions you are using as Tags with button's Left an Top properties which can then be used to get the other buttons based on their position

Now for the not so good part for you :)
- I have only defined king and queen movements but this should be enough as an example. You have to define the other pieces
- the movement class has a ComplexMovement... you could use this for the Knight piece which has a complex pattern... it's your job to figure out how to simulate it

Let me know if you have any questions

 public partial class Form1 : Form
    {
        public Pieces SelectedPiece;

        public class Position
        {
            private int X, Y;
            public Position(int x,int y)
            {
                X = x;
                Y = y;
            }

            public Position() { }

            public int getX()
            {
                return X;
            }
            public int getY()
            {
                return Y;
            }
        }
        public class Pieces
        {
            public string …
pitic 15 Newbie Poster

Since I'm not able to fully understand what you are trying to do... here's what I can give you

private void btn_Click(object sender, EventArgs e)
Pieces peice = new Pieces(position.getX(), position.getY(), Sp.returnpeice());

position is a new Position() so getX and getY always return 0 and 0 (even though you're not using it afterwards)

As I said in my previous post you can change color with (sender as Button).BackColor = Color.Green;. I don't know what you mean by using Tag command. From your code the Tag is just a x/y position on the window. Why do you want to relate to that position since the sender can be cast as button and colored?

pitic 15 Newbie Poster

If you need to change the color of a button (at least this is what I understood) you can use the button.BackColor = Color.Green

If you needed something else please give more details.

pitic 15 Newbie Poster

Do you want to add them to the same combobox? If so you could use UNION ALL:

select vuser, vStudentName from StudentAccount UNION ALL select <columns requested> from FacultyAccount

replace the <columns request> with what you need from FacultyAccount

Just remember you have to select the same number/order/types of columns between each select