Click here to Skip to main content
15,907,392 members
Home / Discussions / C#
   

C#

 
AnswerRe: How execute Command Prompt(Ms-DOS) commands through C# Pin
0x3c026-Sep-09 22:32
0x3c026-Sep-09 22:32 
GeneralRe: How execute Command Prompt(Ms-DOS) commands through C# Pin
DarkSorrow3827-Sep-09 4:11
DarkSorrow3827-Sep-09 4:11 
GeneralRe: How execute Command Prompt(Ms-DOS) commands through C# Pin
0x3c027-Sep-09 5:01
0x3c027-Sep-09 5:01 
AnswerRe: How execute Command Prompt(Ms-DOS) commands through C# Pin
PIEBALDconsult27-Sep-09 4:38
mvePIEBALDconsult27-Sep-09 4:38 
AnswerRe: How execute Command Prompt(Ms-DOS) commands through C# [modified] Pin
Luc Pattyn27-Sep-09 7:21
sitebuilderLuc Pattyn27-Sep-09 7:21 
QuestionSrcChess by Jacques Fournier Pin
Marcel5126-Sep-09 20:55
Marcel5126-Sep-09 20:55 
AnswerRe: SrcChess by Jacques Fournier Pin
Richard MacCutchan26-Sep-09 21:44
mveRichard MacCutchan26-Sep-09 21:44 
QuestionHow to develop an VS add-in to find the path and file name of the assembly? Pin
Damu Li26-Sep-09 16:20
Damu Li26-Sep-09 16:20 
AnswerRe: How to develop an VS add-in to find the path and file name of the assembly? Pin
Luc Pattyn26-Sep-09 16:41
sitebuilderLuc Pattyn26-Sep-09 16:41 
GeneralRe: How to develop an VS add-in to find the path and file name of the assembly? Pin
PIEBALDconsult26-Sep-09 17:01
mvePIEBALDconsult26-Sep-09 17:01 
GeneralRe: How to develop an VS add-in to find the path and file name of the assembly? Pin
Damu Li26-Sep-09 17:54
Damu Li26-Sep-09 17:54 
GeneralRe: How to develop an VS add-in to find the path and file name of the assembly? Pin
Damu Li26-Sep-09 19:47
Damu Li26-Sep-09 19:47 
QuestionInteracting with a Global System Object [modified] Pin
Bull City Rambler26-Sep-09 16:18
Bull City Rambler26-Sep-09 16:18 
AnswerRe: Interacting with a Global System Object Pin
Dave Kreskowiak26-Sep-09 17:29
mveDave Kreskowiak26-Sep-09 17:29 
Questionhow i can fill collection from database and connect this collection to ComboBox ? Pin
E_Gold26-Sep-09 9:30
E_Gold26-Sep-09 9:30 
AnswerRe: how i can fill collection from database and connect this collection to ComboBox ? Pin
Abhijit Jana26-Sep-09 9:49
professionalAbhijit Jana26-Sep-09 9:49 
AnswerRe: how i can fill collection from database and connect this collection to ComboBox ? Pin
PIEBALDconsult26-Sep-09 12:38
mvePIEBALDconsult26-Sep-09 12:38 
QuestionCreate TaskBar Icon Pin
treuveni26-Sep-09 9:13
treuveni26-Sep-09 9:13 
AnswerRe: Create TaskBar Icon Pin
Abhijit Jana26-Sep-09 9:44
professionalAbhijit Jana26-Sep-09 9:44 
GeneralRe: Create TaskBar Icon Pin
khosnur26-Sep-09 20:49
khosnur26-Sep-09 20:49 
AnswerRe: Create TaskBar Icon Pin
DaveyM6926-Sep-09 9:45
professionalDaveyM6926-Sep-09 9:45 
QuestionCreate ID Auto code C# Pin
choemxin26-Sep-09 7:18
choemxin26-Sep-09 7:18 
First select all product from database

private DataTable ShowProduct()
{
string mach = "select ID,Name from product";
cmd = new SqlCommand(mach,con);
adt = new SqlDataAdapter(cmd);
ds = new DataSet();
adt.Fill(ds);
return ds.Tables[0];
}
-----------------------------------------------------------------
Second build funtion create id auto

private int AutoID() //funtion create auto id
{
DataTable dt = new DataTable();
dt=ShowProduct(); //datatable store list id
int ma=-1;
int row = -1;
string mach1="";
int i = 0;
if (dt.Rows.Count > 0) //at least one id
{
int[] id = new int[dt.Rows.Count];

foreach (DataRow mach in dt.Rows) //assigned id in string array
{
ma++;
row++;
mach1 = dt.Rows[row][0].ToString();
id[ma] = Convert.ToInt32(mach1.Substring(2)); //get string index=2 to end converter int assigned id in string array

}

for (int j = 0; j < id.Length; j++) //create auto id
{
i++;
if (id[0] != 1) //first id !=1 set id =0
{
i = i - 1;
break;
}
if (id[j] > i) //id[j] != id[j-1]+1 set id=id[j-1]
{
i = id[j - 1];
break;
}
}
}
return i + 1; //return id need create
}
---------------------------------------------------------------
Using

private void bttInsert_Click(object sender, EventArgs e)
{
int id = AutoID(); ////Using
string idpro = "SP" + id.ToString().PadLeft(4, '0');
txtID.Text = idpro;
if (bttInsert.Text == "Insert")
{
txtName.Clear();
bttInsert.Text = "Save";
}
else
{
if (txtName.Text != "")
{
InsertSP(idpro, txtName.Text);
dgvShowSP.DataSource = ShowProduct();
bttInsert.Text = "Insert";
}
else
MessageBox.Show("Bạn chưa nhập tên sản phẩm");
}
}

Link download demo
CreateAutoID.rar
AnswerRe: Create ID Auto code C# Pin
Abhishek Sur26-Sep-09 10:14
professionalAbhishek Sur26-Sep-09 10:14 
AnswerRe: Create ID Auto code C# Pin
choemxin27-Sep-09 8:09
choemxin27-Sep-09 8:09 
GeneralRe: Create ID Auto code C# Pin
Dave Kreskowiak27-Sep-09 9:37
mveDave Kreskowiak27-Sep-09 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.