|
Are you making sure to encrypt what the user types in to log into the system (with the same key) and comparing the two encrypted values? What type of encryption are you using, Semetric (Blowfish, 3DES) or One-way Hashing (MD5, SHA1)?
Sunday Ironfoot
www.dominicpettifer.co.uk (work in progress)
|
|
|
|
|
How are you storing that data? Assuming your character is unicode, you'll need to store your data as type NVarChar or NText.
|
|
|
|
|
i have listview with multi colum
when i add item i see it at the botton
now
1- how make the scrol of the the listview always at the botton
or
2- how can add item to the top at all item in the listView
Palestine
|
|
|
|
|
TAREQ F ABUZUHRI wrote: 1- how make the scrol of the the listview always at the botton
myListView.EnsureVisible(myListView.Items.Count - 1);
TAREQ F ABUZUHRI wrote: how can add item to the top at all item in the listView
myListView.Items.Insert(0, theItem);
|
|
|
|
|
I just picked up this client who wants me to design and build a data base application for them and i have no problem with that. I was just wondering what is a good gird control to use with C# and SQL
Thanks in advance
|
|
|
|
|
Have you looked at the built-in System.Windows.Forms.DataGridView ?
|
|
|
|
|
Yes I have looked at it a little bit but i could not figure out how to resize the coulms
thanks
ryan
|
|
|
|
|
|
I'm new to C# so I have at present been keeping the coding simple.
This is for a windows application
I have 6 text boxes depending on which last two are filled, on exit it checks the database (sql server) to see if its a valid record
Beneath these boxes is a datagrid, I worked out how to label the columns, what I'm trying to do and cannot figure it out yet is once the text boxes have been validated on exit I would like to copy the information into the datagrid. Afterwards I will blank the text boxes ready for further input.
Any help would be much appreciated
Robert
|
|
|
|
|
You need to put the text into a container of some sort, DataTable, Array, List<>, whatever and bind the datagrid to it.
only two letters away from being an asset
|
|
|
|
|
There are plenty of articles on how to bind an arraylist to a datagrid, but how exactly does one get the arraylist back out of the datagrid?
I have bound an arraylist to the datagrid, and allow users to change all values (decimal, string, checkbox) and would like to update my arraylist to match the changes.
I guess there are two approaches, interate through each row of the datagrid, create a new object for my arraylist, and add it to a new arraylist...
Or I could just go trhough and compare the objects in arraylist and that of the datagrid and update whatever has changed...
Can anyone point me in the right direction as to how to approach this?
|
|
|
|
|
I vaguely recall seeing code similar to this:
ArrayList list = (ArrayList) yourDataGrid.DataSource;
|
|
|
|
|
I'm trying to set a windows timer event to fire, and when it does it will close the current drawing (Autocad) and open a new one. I can get the event to fire, but for some reason it doesn't seem to want to close the drawing. It knows the stuff for Autocad, as I put in messages boxes to make sure it does, it just won't do what I want it to do. Any body tried this before? Knows (has ideas) as to how I can do this?
The program is supposed to open a set of drawings, one at a time, for a specified time period.
Any/all help is appreciated. I'm pretty new to C#, just so you know.
If you want to see the code, I can post it.
Thanks.
Tim
|
|
|
|
|
Hello
T.Willey wrote: If you want to see the code, I can post it.
Sure!! Posting the code that closes/opens the drawings would do a great help.
Regards
|
|
|
|
|
Thanks for the response. Here is the code. It will open the first drawing, issue the '3dorbit' command, fire the timer event, but then it stops. It will not close the current drawing, nor open the next one.
using System;
using System.Diagnostics;
using System.Timers;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
[assembly: CommandClass(typeof(Test.TimeLimitOpenv02))]
namespace Test
{
/// <summary>
/// Description of TimeLimitOpen.
/// </summary>
public class TimeLimitOpenv02
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);
public string[] DwgList;
public Document NewDoc;
DocumentCollection DocMan = AcadApp.DocumentManager;
System.Timers.Timer CountDownTimer;
int cnt = 1;
//- Constructor: sets up var's etc for this class before use.
public TimeLimitOpenv02()
{
CountDownTimer = new System.Timers.Timer();
CountDownTimer.Elapsed += new ElapsedEventHandler(CancelCommand);
CountDownTimer.Interval = 10000;
}
~TimeLimitOpenv02() // <-- Destructor, do clean up here.
{
CountDownTimer.Elapsed -= new ElapsedEventHandler(CancelCommand);
}
public void CancelCommand(object sender, ElapsedEventArgs e)
{
acedPostCommand ("CancelCmd");
//MessageBox.Show (DocMan.ToString());
NewDoc = DocMan.MdiActiveDocument;
//MessageBox.Show ("Testing");
//MessageBox.Show (cnt.ToString());
NewDoc.CloseAndDiscard();
NewDoc = DocMan.Open (DwgList[cnt], true);
if (NewDoc != DocMan.MdiActiveDocument) {
DocMan.MdiActiveDocument = NewDoc;
}
++cnt;
if (cnt > DwgList.Length) {
CountDownTimer.Enabled = false;
CountDownTimer.Dispose();
}
NewDoc.SendStringToExecute ("_.3dorbit", false, false, true);
}
[CommandMethod("TestTimer", CommandFlags.Session)]
public void Main()
{
Autodesk.AutoCAD.Windows.OpenFileDialog Dia =
new Autodesk.AutoCAD.Windows.OpenFileDialog(
"Select drawings to update Cloud layer", "", "dwg", "",
Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
Dia.ShowDialog();
string[] DwgList = Dia.GetFilenames();
if (DwgList.Length > 1)
{
CountDownTimer.Enabled = true;
Document NewDoc = DocMan.Open (DwgList[0], true);
if (NewDoc != DocMan.MdiActiveDocument) {
DocMan.MdiActiveDocument = NewDoc;
}
NewDoc.SendStringToExecute ("_.3dorbit\n", false, false, true);
}
}
}
}
I can't seem to keep the formatting. Nevermind, I think I did it right.
Tim
|
|
|
|
|
Hello
Well, I wonder a bit about how your code did compile at all!!
your main method is public while it should have been static private. This -I believe- should make a compile error!!
Anyway, I don't understand much of Autocad's interop method calls. I hope you are sure they should do the work. You said that the elapsed event is fired?? Does that mean that your CancelCommand is called and exctuted properly?
BTW:
You've declared DwgList twice. The one in main method is not the one you are accessing in the CancelCommand method. Try to debug through your code and see its value in the first time the event is fired.
Regards
|
|
|
|
|
I don't know why/how it compiles either, but it does. =D
The CancelCommand does fire, but you are correct in that my DwgList isn't anything in the CancelCommand part. I thought by adding it to the main part of the class, that it could be used inside the code, and shared with other parts of code as long as it was within the same class. Guess I was wrong, back to reading some more.
I guess I need to figure out how to have two global variable. One for DwgList and one for cnt . Or figure out a way to pass them between the calls to CommandCancel .
Thanks for your help, I don't think I would have ever got this far without it.
Tim
|
|
|
|
|
Hello
Well, forgive me if I say that your code sin't Object oriented. It looks like you have good experience in languages before C++. Your style is very procedural and it sin't that bad. It's just that your applications doesn't even have an interface?!! All you do is that you show a dialog, ake an input then do some interop. Well, either you make a full functional windows application or wrap your code in a dll or something. I didn't mean to ofend you - sincerely-, I just wanted to be as honest as I can with you.
Anyway, I wouldn't like to disrupt your code structure, so, the closest solution to get your code to work -though it would be better to remodel your code later to be more OO-, is simply to declare your variables as static thus you'd be able to call them by the class.
Here is your code, modified:
namespace Test
{
public class TimeLimitOpenv02
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);
private static string[] DwgList;
public Document NewDoc;
DocumentCollection DocMan = AcadApp.DocumentManager;
System.Timers.Timer CountDownTimer;
private static int cnt = 1;
public TimeLimitOpenv02()
{
CountDownTimer = new System.Timers.Timer();
CountDownTimer.Elapsed += new ElapsedEventHandler(CancelCommand);
CountDownTimer.Interval = 10000;
}
~TimeLimitOpenv02()
{
CountDownTimer.Elapsed -= new ElapsedEventHandler(CancelCommand);
}
public void CancelCommand(object sender, ElapsedEventArgs e)
{
acedPostCommand ("CancelCmd");
NewDoc = DocMan.MdiActiveDocument;
NewDoc.CloseAndDiscard();
NewDoc = DocMan.Open (DwgList[cnt], true);
if (NewDoc != DocMan.MdiActiveDocument) {
DocMan.MdiActiveDocument = NewDoc;
}
++TimeLimitOpenv02.cnt;
if (TimeLimitOpenv02.cnt > TimeLimitOpenv02.DwgList.Length) {
CountDownTimer.Enabled = false;
CountDownTimer.Dispose();
}
NewDoc.SendStringToExecute ("_.3dorbit", false, false, true);
}
[CommandMethod("TestTimer", CommandFlags.Session)]
public void Main()
{
Autodesk.AutoCAD.Windows.OpenFileDialog Dia =
new Autodesk.AutoCAD.Windows.OpenFileDialog(
"Select drawings to update Cloud layer", "", "dwg", "",
Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
Dia.ShowDialog();
TimeLimitOpenv02.DwgList = Dia.GetFilenames();
if (DwgList.Length > 1)
{
CountDownTimer.Enabled = true;
Document NewDoc = DocMan.Open (DwgList[0], true);
if (NewDoc != DocMan.MdiActiveDocument) {
DocMan.MdiActiveDocument = NewDoc;
}
NewDoc.SendStringToExecute ("_.3dorbit\n", false, false, true);
}
}
}
}
BTW:
You still can access DwgList from your main , and your CancelCommand if you didn't redeclare it. Your redeclaration made a second local variable with the same name that masked the original one -I hope I'm making sense!;P-. Anyway, even though I totally don't like this static workaround, but it would relieve the ambiguity, and get your code to work. But if you want to make a windows application, at least it should have a form, shouldn't it? Well, Maybe you are making a command line tool -never liked them though-. Good luck! I hope it works this time.
Regards
|
|
|
|
|
Thanks for you help, and you can be as blunt as you want to be. I know I'm learing as I go, and my only background with programming is within the AutoCAD enviroment, and that was with Lisp.
It is going to be run for a presentation on 3d drawings. It will only allow the people to use the 3dorbit command from within Acad for a limited amout of time per drawing. It will be ran from the command line, and loaded in as a dll file.
Thanks again for all the help. I will let you know when I get it working.
Tim
|
|
|
|
|
It looks like the problem now is that it doesn't know how to get the current drawing NewDoc = DocMan.MdiActiveDocument; . Even if I put it in the long way NewDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; . It still won't be able to find it, and in turn execute the commands on it.
Is the timer taking control away from Acad? Is that why it can't find it?
If you have any ideas, I'm will to try them, as I'm totally lost now. Thanks.
Tim
|
|
|
|
|
Ooops!!:-> I missed that
Docman and NewDoc too should be declared as static if you want to share them between main and CancelCommand . Don't forget to call them by the class name.
Regards
|
|
|
|
|
No problem. I made the DocMan static, but didn't think I need to make the NewDoc static also. After I did this, it was able to read the NewDoc , and I was able to get a property, but when I tried to use the method CloseAndDiscard() it crashed with and unhandled access issue. I will have to look into this tomorrow, as I'm going home, and don't have Acad there yet, so can't test anything.
Thanks for all your help today Nader it is really appreciated!!
Tim
|
|
|
|
|
You're welcome.
And if you need something tommorow, just reply and I'll get an email notification.
Good luck with your demo.;)
Regards
|
|
|
|
|
I hate to have to ask you for somemore help, but I can't see to find an answer to what I thought would be a simple question.
How can you set the focus to an application? I think this might be a problem with my code. I think I need to set the focus back to Autocad in the event handler portion.
Thanks again.
-- modified at 13:54 Friday 15th September, 2006
Nevermind. It doesn't seem to work that way. Back to the drawing board. I found a way on this website.
http://www.personalmicrocosms.com/Pages/dotnettips.aspx?c=3&t=3[^]
Tim
|
|
|
|
|
Hello
Sorry I saw your post late. Here is the way -if you still want it-.
First, you can't do that using C# alone. you have to make some Windows API unmanaged functions. The functions import code is:
[DllImport("User32.dll", CharSet=CharSet.Auto)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
Now this loop will go through all top-level windows, check their title, then activate the one that has "Autocad" word on it:
foreach(Process P in Process.GetProcesses())
{
if (P.MainWindowTitle.Length > 0 && P.MainWindowTitle.IndexOf("Autocad") != -1)
SetForegroundWindow(P.MainWindowHandle);
}
One flow is that all windows that has "Autocad" word on it will be activated sequentily. If you know more word in a single phrase -ie. as a sentence- this should narrow this error margin.
Regards
|
|
|
|
|