|
You might have better luck getting an answer if you ask over in the Web Development forum, where the Web Developers hang out.
|
|
|
|
|
We need a dedicated Cool Development forum; I hear that's where the cool kids hang out.
This space for rent
|
|
|
|
|
I thought that CP already had that.... the Moderators forum.
|
|
|
|
|
hi all
I have a search button and datagrid in c#, I require perform a query in the database and load the data in me datagrid
it is my code
conexion.ConnectionString = @"Data Source = SHINIL-PC040\SQLEXPRESS; Initial Catalog = produccion; Integrated Security = True";
if(TXTORDEN_PRODUCCION.Text == "" || TXTTURNO.Text == "" || TXTMAQUINAS.Text == "" || TXTHORAINICIO.Text == "" || TXTHORAFIN.Text == "")
{
MessageBox.Show("Te falta campo");
}
else
{
if (checkBox1.Checked == true)
{
try
{
comando.Connection = conexion;
conexion.Open();
string SqlAction = "select orden, turno, operador, horainicio, horafin, articulo, totalpiezasok, totalcajas, piezascondefecto, maquina from conteo2 where CONVERT(varchar(10), horafin, 108) >= @horainicio and CONVERT(varchar(10), horafin, 108)<= @horafin and orden = @orden and turno = @turno and maquina = @maquina ";
SqlCommand cmd = new SqlCommand(SqlAction, conexion);
cmd.Parameters.AddWithValue("@orden", TXTORDEN_PRODUCCION.Text);
cmd.Parameters.AddWithValue("@turno", TXTTURNO.Text);
cmd.Parameters.AddWithValue("@maquina", TXTMAQUINAS.Text);
cmd.Parameters.AddWithValue("@horainicio", TXTHORAINICIO.Text);
cmd.Parameters.AddWithValue("@horafin", TXTHORAFIN.Text);
}
conexion.Close();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
MessageBox.Show("selecciono ok produccion");
}
if (checkBox2.Checked == true)
{
MessageBox.Show("selecciono paros");
}
if (checkBox1.Checked == false & checkBox2.Checked == false)
{
MessageBox.Show("tiene que seleccionar un reporte");
}
}
|
|
|
|
|
You never asked a question.
|
|
|
|
|
the Question is, as can I load the data back my search datagrid
|
|
|
|
|
Sorry, but can you ask your question in more detail? What exactly are you trying to achieve?
|
|
|
|
|
Yes you can. Loading the DataGrid is not a one time only operation.
This space for rent
|
|
|
|
|
I made program in C# that converts resistor value to color code.How to show closest standard value and closest standard color for resistor?
http://pastebin.com/9RbH0kmS
|
|
|
|
|
Unfortunately, it is highly unlikely that someone is going to download your code and write the missing portions for you. We have no idea who you are so we are wary of downloading code; I have no doubt you are a fine chap but because I don't really know you, I can't tell whether or not your download will have been infected with something I don't want to install (albeit accidentally on your part).
This space for rent
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "4")
{
if (textBox1.Text == "0")
{
MessageBox.Show("Otpornost mora biti veca od nule!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if(comboBox2.Text=="")
{
MessageBox.Show("Izaberi vrednost tolerancije!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var colours = new string[] { "Black", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Grey","White", "Silver", "Gold" };
var factorDictionary = new Dictionary<char, double>() { { 'p', 0.000000000001 }, { 'n', 0.000000001 }, { 'u', 0.000001 }, { 'm', 0.001 }, { 'R', 1 }, { 'K', 1000 }, { 'M', 1000000 }, { 'G', 1000000000 } };
string res = string.Empty;
while (string.IsNullOrEmpty(res))
{
res = textBox1.Text;
}
var lastChar = res.Last();
var isUnitCorrect = factorDictionary.ContainsKey(lastChar);
var value = res.Substring(0, res.Length - 1);
var isValueCorrect = !value.Any(x => !char.IsDigit(x));
if (isUnitCorrect && isValueCorrect)
{
double mul = factorDictionary[lastChar];
double val = double.Parse(value) * mul;
int third = 0;
if (val < 0.1)
{
MessageBox.Show("Otpornost ne moze da bude manja od 0.1 oma!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (val < 1)
{
val *= 100;
third = 10;
}
else if (val < 10)
{
val *= 10;
third = 11;
}
res = val.ToString();
if (res.Count() > 24)
{
MessageBox.Show("Pogresna vrednost!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
label15.BackColor = Color.FromName(colours[res[0] - '0']);
label16.BackColor = Color.FromName(colours[res[1] - '0']);
label17.BackColor = Color.FromName(colours[third != 0 ? third : res.Count() - 2]);
label6.Text = textBox1.Text;
textBox2.Text = colours[res[0] - '0'];
textBox3.Text = colours[res[1] - '0'];
textBox4.Text = colours[third != 0 ? third : res.Count() - 2];
}
if (comboBox1.Text == "4")
{
if (comboBox2.Text == "E24 (5%)")
{
label18.BackColor = Color.Gold;
textBox5.Text = "Gold";
}
if (comboBox2.Text == "E12 (10%)")
{
label18.BackColor = Color.Silver;
textBox5.Text = "Silver";
}
}
}
else
{
MessageBox.Show("Invalid value!", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
|
|
|
|
|
You already posted this on Sunday:
Resistor color code - C# Discussion Boards[^]
Repeatedly posting the same question to the forums to try to force the unpaid volunteers to answer your question faster will not end well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As far as I remember this part you should first select the resistance-row (E6 , E12 , E24 , ...).
According to this selection you get (or calculate) the base-values for the row - for example E12 means 1.0 , 1.2 , 1.5 , 1.8 , 2.2 , and so on.
Now you should calculate the row-multiplier. For example your Input was 1344 Ohm. Now your multiplier for the base-values is 1000.
You take this multiplier, iterate through the row-values and multiply those value with the multiplier and compare if one value is smaler (or equal) than your entered resistor-value.
Now you check, which difference is smaler : to the last value of the row or to the next value of the row. The one with the smalest difference should be your reference-resistor.
With this resistor-value you build your color-table - but remember not each resistance-row has the same count of color-rings.
I think, you should start with this ...
|
|
|
|
|
Can it be made like this for E12:
int i = 0;
for (i = 0; i < E12.Length; i++)
{
p = E12[i] * mul;
if (p <= val)
{
r = Math.Abs(p - val);
}
}
|
|
|
|
|
Hello everyone.
I make application by Android Studio, i want to disable all applications in my mobile except internet Wifi?.
Please anyone knows that. help me.
Thank you
|
|
|
|
|
Dr Kasa, thanks for taking the time to ask a question on Code Project. Unfortunately, you have chosen to ask your question in the C# forum which has nothing to do with developing an Android application in C# (which you would do in Xamarin). Please choose a more appropriate forum; the Android forum would be a better choice.
This space for rent
|
|
|
|
|
Why?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
To hijack the phone, with or without consent.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Was my guess - I couldn't think of a non-malicious use for it: but then I'm a Cynical Old Codger!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
With cynical, you mean 'experienced'?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No, just cynical ... my faith in humanity is at a low ebb today.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I am getting a long path exception while adding attachments to MailMessage. Our file path exceeds 260, but that's how it is and we want it to work.
Following is what I have done to avoid the exception:
private void CreateAttachments(MailMessage mailMessage, List<string> filesToAdd)
{
foreach (string fileToAdd in filesToAdd)
{
SafeFileHandle fileHandle = null;
try
{
fileHandle = Common.CreateFile(Common.prefixPath(fileToAdd), Common.GENERIC_READ, FileShare.Read, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
if (!fileHandle.IsInvalid)
{
using (FileStream fs = new FileStream(fileHandle, FileAccess.Read))
{
Attachment data = new Attachment(fs, fileToAdd);
mailMessage.Attachments.Add(data);
}
}
}
finally
{
if ((fileHandle != null) || fileHandle.IsInvalid)
fileHandle.Dispose();
}
}
}
Above LOC doesn't throw an exception while adding attachments. But, while sending(smtpClient.Send(mailMessage)) it throws an exception "Failure Sending Mail".
UPDATED CODE
modified 10-Oct-16 10:17am.
|
|
|
|
|
In this line;
Attachment data = new Attachment(fs, fileToAdd, "text/plain");
fileToAdd doesn't have to be the path to the original file, it's just a token so you can drop the path
Attachment data = new Attachment(fs, Path.GetFileName(fileToAdd), "text/plain");
|
|
|
|
|
Can someone please advise? Really appreciate your time and help.
|
|
|
|
|
Did you try the suggestion that was already made?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|