|
private void CheckContactNumber()
{
string checkContactNum = "SELECT COUNT(*) FROM Employee WHERE ContactNumber = " + addContactNum.Text + " "; //01234567890
OleDbCommand cmd = new OleDbCommand(checkContactNum, conn);
conn.Open();
OleDbDataReader dr = cmd.ExecuteReader();
//if (dr.Read() && addContactNum.Text != "")
if (dr.Read())
{
int count = (int)dr[0];
if(count>0)
{
err += "Contact number is already listed in the database\r\n";
errorContactNum.Visible = true;
uniqueContactNumber = false;
}
}
conn.Close();
}
|
|
|
|
|
t's not hard, it's easy - once you learn how to do it.
Just to add to what Richard gave you, the whole code is along the lines of:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT Age, Description FROM myTable WHERE ID = @ID", con))
{
cmd.Parameters.AddWithValue("@ID", myTextBox.Text);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int age = (int) reader["Age"];
string desc = (string) reader["Description"];
Console.WriteLine($"{age}\n{desc}");
}
}
}
}
|
|
|
|
|
I have c# windows form application which displays the real time data from a board. I want to plot this data in a point graph in c#. Help me with this. I have given my code below which displays the data from board.
namespace flowboard_v2
{
public partial class flow_click : Form
{
public flow_click()
{
InitializeComponent();
}
[DllImport("C:\\Users\\JivaSci\\Desktop\\fluigent\\bin\\SDK\\FRP\\C++\\Cpp_Windows\\frp_c_64.dll", CallingConvention = CallingConvention.StdCall)]
public static extern UInt64 frp_initialization(ushort serial);
[DllImport("C:\\Users\\JivaSci\\Desktop\\fluigent\\bin\\SDK\\FRP\\C++\\Cpp_Windows\\frp_c_64.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int64 frp_get_serial(UInt64 handle, ref ushort serial, ref ushort version);
[DllImport("C:\\Users\\JivaSci\\Desktop\\fluigent\\bin\\SDK\\FRP\\C++\\Cpp_Windows\\frp_c_64.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int64 frp_close(UInt64 handle);
[DllImport("C:\\Users\\JivaSci\\Desktop\\fluigent\\bin\\SDK\\FRP\\C++\\Cpp_Windows\\frp_c_64.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int64 frp_read_flow(UInt64 handle, byte index, ref byte timestamp, ref float flow);
[DllImport("C:\\Users\\JivaSci\\Desktop\\fluigent\\bin\\SDK\\FRP\\C++\\Cpp_Windows\\frp_c_64.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int64 frp_data_FU(UInt64 handle, byte index, ref byte cal, ref byte res, ref byte artcod, ref byte sf, ref byte unit, ref byte tb);
public void Test()
{
/* Flow board variable declaration */
UInt64 frpHandle = 0;
ushort Serial = 0;
ushort Version = 0;
/* Flow-rate acquisition variables */
byte sensor_index = 0; // sensor index coresponds to flow-unit port on the flowboard from 0 to 7
byte TimeCheck = 0;
float flow_rate = 0;
uint loop = 0;
frpHandle = frp_initialization(0);
RTBox.Text+=("\n FRP session initialized");
frp_get_serial(frpHandle, ref Serial, ref Version);
RTBox.Text += ("\n FLOWBOARD SN:" + Convert.ToInt32(Serial));
if (Serial != 0)
{
frp_read_flow(frpHandle, sensor_index, ref TimeCheck, ref flow_rate);
RTBox.Text += ("\n Flow-rate:" + Convert.ToSingle(flow_rate) + "\t ul/min");
}
frp_close(frpHandle);
RTBox.Text += ("\n FRP session closed");
}
private void button1_Click(object sender, EventArgs e)
{
Test();
}
|
|
|
|
|
|
I am trying to plot the flow rate value(micro litres) and time(seconds) . so flow rate is my y axis and time is my x axis . whenever i click on button a new flow rate value is obtained which should to be updated on the graph
|
|
|
|
|
Member 14652449 wrote: whenever i click on button a new flow rate value is obtained which should to be updated on the graph So what code do you have that is activated when you click on a button? You just need to update your plot values and redraw the graph.
|
|
|
|
|
I have this code in my DAL:
public async Task<IList<CompanyHeaderEntity>> GetCompanyHeadersAsync()
{
var t = await Task.Factory.StartNew(() =>
{
List<CompanyHeaderEntity> results = new List<CompanyHeaderEntity>();
using (var db = GetDataContext())
{
try
{
results = (from c in db.Companies
where !c.DeletedDT.HasValue
select new CompanyHeaderEntity
{
Id = c.Id,
CompanyName = c.CompanyName
}).OrderBy(x => x.CompanyName).ToList();
}
catch (Exception e)
{
throw;
}
return results;
}
});
return t;
}
What I'd like to do is pass in a delegate, so that I could say "Give me all Companies where [whatever]." But in all cases, I want to include the WHERE clause I already have in there.
where !c.DeletedDT.HasValue
So I somehow need to append the deleted check to whatever I pass in.
What's the right way to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Have you tried including a predicate as argument?
public async Task<IList<CompanyHeaderEntity>> GetCompanyHeadersAsync(Predicate<Company> predicate)
And then
where !c.DeletedDT.HasValue && predicate(c)
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Good idea. Thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
OK, so the predicate is referencing the DB entity 'Company', whereas my code references my ENTITY called CompanyHeaderEntity, so it doesn't compile
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I don't have the right schema, I just assumed the name of the class.
The type for the predicate is the type of the c variable.
And what is the compile error message by the way?
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
The c variable is the db entity. It complains because it's trying to convert a Company (DB record) to an CompanyHeaderEntity
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Please tell the exact error message, and also indicate the actual code. I cannot help you without this because none of what I proposed involves any conversion of some kind.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
While I have posted samq query in the link given below, I thought someone here could use their expertise in solving my requirement.
How to delete dynamically created Textbox using delete key on keyboard?[^]
I have used all types of coding to remove the textbox but no use. I found few posts on Google search but the textboxes are associated with either a button control or checkbox control, using which, the deletion happens. I want the textbox to be deleted, if it is selected (meaning, the cursor is blinking in the text input area). I also tried setting textBox.Enabled=false; but no use as a statement textBox.Enabled=true; doesn't bring the textbox to life at all.
Thanks in advance.
parthan
|
|
|
|
|
If it's dynamically created, you can enable, disable, or remove it very simply - provided you have the right instance.
And that means "finding" the exact TextBox that you issued a new statement on, and added to the PictureBox.Controls collection:
private void FrmMain_Shown(object sender, EventArgs e)
{
TextBox tb = new TextBox();
...
myPictureBox.Controls.Add(tb);
}
Unless you saved it in a class level variable, the simplest way to do that is probably to look in myPictureBox.Controls:
if (myPictureBox.Controls.Count > 0)
{
if (myPictureBox.Controls[0] is TextBox tb)
{
tb.Enabled = true;
tb.Enabled = false;
myPictureBox.Controls.Remove(tb);
}
}
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi, I tried implementing your code as shown below and commented as //New experiment...
But delete doesn't have any effect.
Please look into the code and let me know if something is amiss.
Thank you.
virtTxtBox.MouseDown += (ss, ee) =>
{
if (ee.Button == MouseButtons.Left)
{
//this.textBox1.Enabled = false;
firstPoint = Control.MousePosition;
if (virtTxtBox.BorderStyle == BorderStyle.None)
{
virtTxtBox.BorderStyle = BorderStyle.FixedSingle;
}
//else
//if (virtTxtBox.BorderStyle == BorderStyle.FixedSingle)
{// virtTxtBox.MouseEnter += (ssh, eeh) =>
{
KeyDown += (o, e2) =>
{
virtTxtBox.Focus().Equals(false);
if (e2.KeyCode == Keys.Delete)
{
TextBox TxtBox = (sender as TextBox);
//if (virtTxtBox.BorderStyle == BorderStyle.FixedSingle)
{
//Determine the Index of the Button.
int index = int.Parse(TxtBox.Name.Split('_')[1]);
label1.Text = index.ToString();
//Find the TextBox using Index and remove it.
TextBox txbx = (TextBox) pictureBox1.Controls.Find("txt_" + index, true)[0];
label1.Text = txbx.Name;
pictureBox1.Controls.Remove(pictureBox1.Controls.Find("txt_" + index, true)[0]);
pictureBox1.Controls.Clear();
virtTxtBox.Dispose();
//new experiment start
if (pictureBox1.Controls.Count > 0)
{
if (pictureBox1.Controls[0] is TextBox tb)
{
label1.Text = "YES entered tb";
tb.Enabled = true;
tb.Enabled = false;
pictureBox1.Controls.Remove(tb);
}
}
//new experiment end
}
}
};
virtTxtBox.BorderStyle = BorderStyle.None;
};
}
//virtTxtBox.Enabled = false;
}
};
parthan
|
|
|
|
|
Do us both a favour and look at your code:
pictureBox1.Controls.Clear();
virtTxtBox.Dispose();
if (pictureBox1.Controls.Count > 0) How many controls do you think there are left after you Clear the Controls collection?
And then look at the rest of it and see if it makes any sense at all - because that looks like it was thrown together while praying it will work, rather than designed in any way!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi, I said I experimented in various ways. Even after you commented about me using so many remove codes, i ensured they were not involved in the process and yet I could not achieve my objective of getting the textbox control(s) off my big picture box.
parthan
|
|
|
|
|
I searched online for 3 speech pronunciation libraries: "System.Speech.dll, Microsoft.Speech.dll and Interop.SpeechLib.dll". I want to know their time and origin, in which 3 libraries easy to use to write code ? Which library supports many countries' voices ? Which library is the most popular with programmers ? In the future, which 3 of the libraries will drop out ? et... ?
|
|
|
|
|
Look at the documentation for each library to decide which one will be the best fit for your application.
|
|
|
|
|
"But I want you to do all that research for me! It sounds like a lot of work and I'm busy with FaceBook today!"
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Just what I thought ... great minds eh?
|
|
|
|
|
In the future, which 3 of the libraries will drop out ? But we have a gift of foresight which he doesn't...
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
I found a speech pronunciation example that uses these libraries, I haven't found the source materials and the documentation for them, if someone who has programmed on this issue will answer it quickly, every time I don't know, thanks to you answers, I would say google search so what was the forum set up for ?
|
|
|
|
|
Member 2458467 wrote: so what was the forum set up for ? It was set up to answer specific technical questions; see How to get an answer to your question - C# Discussion Boards[^]. You are asking us to tell you which library of three is the best, which supports multiple languages, which may disappear in the future, etc. Apply the same question to any consumer product you care to think of and see why it is impossible to provide a definitive answer.
|
|
|
|