|
Hi,
I am beginner to c#.net.
I am engaged in a project (part of HR Management), and i am stucked in a small problem.
The problem is, Leave is provided to employee. I have to display the leave statics of the employee in a manner show below
-------------------
| LEAVE | => this is dataGridView Header
-------------------
| USED | REMAINING | => this and remaining are dataGridVeiw cells.
-------------------
| | |
-------------------
| | |
-------------------
| | |
-------------------
| | |
-------------------
Thank you.
|
|
|
|
|
|
The DataGridView doesn't support cell merging natively. You have to custom draw the headers of the DGV yourself. Since you're a beginner, I don't know if this is going to help or even make sense to you, but there's a code example here[^].
|
|
|
|
|
By trying to use a grid with effectively 2 header rows I feel that you are overcomplicating things.
IMHO you would be better off by creating a custom control. Place a label on the control set its dock property to Top and Text to 'Leave'. Place a grid on the control set its dock property to fill. You can then use the grid as it was intended to be used and also have the added advantage that you can set the Font for 'Leave' independently from the font of the grid and even make the background for 'Leave' to be a pretty blue or green or whatever.
Just my 2 cents.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello all,
I want to add values from my database (.mdf) file to my report file (.rdlc) file. As far as I knw, it can be done by making a dataset and then by drag-n-drop we can add values to report at run time.
All I want to do is to add values to (.rdlc) file at run time through absolute code, no drag-n-drop.
Plz suggest me the ways do do it...
Thanks in advance !!!
csetopper_bhanu
|
|
|
|
|
The following code is from our reportviewer initialisation. You must have created the report of course.
Datatable(s) are loaded by the form that allows the user to select the report and fill in the paramters.
public partial class frmReportViewer : Form
{
public frmReportViewer(string sReportFile, DataTable dtReportData)
{
InitializeComponent();
ReportFile = sReportFile;
ReportData = dtReportData;
}
private string ReportFile { get; set; }
private string NameSpace { get; set; }
private DataTable ReportData { get; set; }
private void frmReportViewer_Load(object sender, EventArgs e)
{
try
{
string sPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Reports";
ReportData.TableName = "dtReport";
DataSet oDS = ReportData.DataSet;
oDS.DataSetName = "ReportData";
string RepResource = "FinBranch.Reports." + ReportFile + ".rdlc";
repViewer.Reset();
repViewer.LocalReport.ReportEmbeddedResource = RepResource;
repViewer.LocalReport.DataSources.Add(new ReportDataSource("ReportData", oDS.Tables[0]));
this.repViewer.RefreshReport();
}
catch (Exception)
{
throw;
}
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
I need to determine when the user pasted data into a cell in a DataGridView so I can parse it out. How do I detect this?
Everything makes sense in someone's mind
|
|
|
|
|
|
Maybe this can give you some ideas as well.
|
|
|
|
|
I want to create SQL server table to save the user rrights, for example:
Allow_Delete
Allow_Add
Allow_Find
Single_Loign
and many other parameters..
I want to know if I am going to use C# then which one will be best performance wise? to create the above as columns and set the value in the rows? it create it as rows with a field for (user_id)?
I am asking this because I don't want my application to be slow duri8ng login...
|
|
|
|
|
The performance won't depend on such design choice AFAIK; however in a database you want a pretty stable set of columns (so your code can remain the same) and you don't mind adding rows; so turn users into rows, and capapilities/rights into columns.
|
|
|
|
|
but having privileges as columns means i might have 100, 200 or more columns in my application?! is that ok if we talk about the performance?
|
|
|
|
|
That is a big number. I don't like that many columns in any table. Are you sure you need that many?
There is an alternative, where you basically use one row for each user, privilege combination granted.
TABLE: UsersAndRights
FIELDS: ID, userID, rightID
TABLE: users
FIELDS: userID, more user data
TABLE: rights
FIELDS: rightID, more rights data
|
|
|
|
|
I prefer bit-mapped user rights and such. And an enum in my code.
Then adding new rights doesn't require schema changes.
|
|
|
|
|
Another option to consider is the concept of roles or groups -- assign the rights to rolls or groups and then add individual users to them. This can sometimes ease the burden of administration.
|
|
|
|
|
jrahma wrote: I am asking this because I don't want my application to be slow duri8ng login
If that's all you're after, it won't matter either way (both will be so fast the user will not notice any delay really). That being said, there is a limit to the number of columns you add to a table (something like 1024, and it depends on your version of SQL Server). Also, you have to code for each column and that can create problems. I'd say go with the simpler approach and use a row per setting. You can add an index to the first column (presumably the name of the setting) to make it fast (assuming you are loading the settings separately).
There is then the problem of data types. You could store everything as a string, which would solve that, but then you might have to worry about parsing and such (which is not that big a deal if you ask me). One way to get around that would be to create a table per data type. So, StringSettings, DateSettings, and so on. You could link those tables back to a central table if you like. You could also create a table with a column for the name of the setting, a column for the data type of the setting, and a column for each possible data type (varchar, datetime, etc.). That would waste space, but not too much really, considering you have so few settings. There is also the option of using a single row/column to store some XML that contains all your settings, which would work well if you save/load all your settings at once.
There are quite a few variables to consider when deciding which approach to take. Since speed is not much of an issue, I'd just say take whichever approach seems to be the simplest to you.
|
|
|
|
|
As others have said, design will not impact the apps performance in this area. However I disagree with the column solution as a change of rights requires a data structure change.
There are a vast number of solutions used for this particular problem, let me ad the one we use.
Have a function table which defines either a form or control.
Use user groups
Have a permissions table that joins group and function with a rights field. The rights field contains AEDX for add/edit/delete/execute.
When the user logs on grab a table of the functions and permissions allowed for the user and test the content of the rights field for the specified forms/controls.
A change of user/groups does not require a data/code change. A change of function does. Everything is a compromise.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hey,
I wrote some Console application (implementation of KNN Algorithm).
It's involve Polymorphism (for different distance calculation), in console everything works great, but the problems began when i tried to add UI to it.
i added a new project (WinForm) and setted it to be a startup Project, then as usual i referenced a console (which become a logic layer) and after i do a rebuild for the whole solution i get an "Error 4 Metadata file ..." compilation error...
I checked in the debug folder of console application, and the ".exe" file was missing.
what is the problem here ?
thanks in advance
|
|
|
|
|
I'm not sure what you are doing, so I'll say this instead...
I have some utilities that run as console applications when executed with command-line parameters and as WinForms applications when run without command-line parameters. Is that what you are trying to do?
To achieve this:
0) Set the project to be a console application
1) In the Main method, detect which mode you want, if you want to launch the form:
1.1) Call the Windows API method FreeConsole (to close the console window)
1.2) Run your form as you normally do
<pre lang="text">
if ( args.Length == 0 )
{
PIEBALD.Lib.LibApi.FreeConsole() ;
PIEBALD.Types.Singularity.ThereCanBeOnlyOne ( typeof(frmDBTW) ) ;
}
else
{
... Console mode code ..
}
</pre>
|
|
|
|
|
Hey guys, I have a problem, I run a code in sqlQuesry builder and it works just fine but when I apply the same thing in C# code it doesn't work !!!
in SQLQuery Builder
SELECT ID, StuName,
StuLName, Shenasnameh, StuLandline, StuMobilePhone,
StuEmail, StuAddress
FROM Students WHERE StuName like N'کیوان%'
the above code works perfectly and I get the result I want but the below code doesn't
SELECT ID, StuName,
StuLName, Shenasnameh, StuLandline, StuMobilePhone,
StuEmail, StuAddress StuEmail, StuAddress FROM Students WHERE StuLName
like N'" + StuLName_tb.Text + "%'";
I'm puzzled here because It the same code, am I missing something ???
|
|
|
|
|
I think that you have too many quotes in there. Try altering
like N'" + StuLName_tb.Text + "%'";
to
like N"'" + StuLName_tb.Text + "%" + "'";
What I think you are getting now is literally + StuLName_tb.Text%'
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I think that you have too many quotes in there
so you suggest to add three double quotes?
in fact, I don't see anything wrong in the original query; I suspect there is a regional setting or an encoding problem somewhere.
|
|
|
|
|
Judging by the way that the code was formatted within the pre tags, StuLName_tb.Text was part of the string and not the value of the property.
This may simply be the result of the way that CP formatting/parsing differs from the way that VS does it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I do hope you will feel better tomorrow.
|
|
|
|