I want to save in tblDate
Name: A
Room: 1
Date: 12-06-2021
finally
I have a data like that
Name Room Ticket Date
A 1 001 12-06-2021
B 1 002 12-06-2021
C 1 003 12-06-2021
D 1 001 13-06-2021
E 1 002 14-06-2021
F 1 003 14-06-2021
i want to get ticket 001 to onward daily based on date. how to get solution?
It is not increasing autonumber based on date
here is my code
private void btnPlay_Click(object sender, EventArgs e)
{
string today = DateTime.Today.ToString("yyyy-MM-dd");
int seq = 1;
string ss = string.Format("IACN-{0}-{1}", today, seq.ToString("D4"));
lblNo.Text = ss.ToString();
try
{
if (string.IsNullOrEmpty(txtDoc.Text) || string.IsNullOrEmpty(txtDoc.Text))
{
MessageBox.Show("Missing Data is required! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int counter = 0;
con = new SqlDbConnect();
con.SqlQuery("select Num from tblDoctorCalls where Num=@Id");
con.Cmd.Parameters.Add(new SqlParameter("@Id", this.lblNo.Text.Trim()));
con.RdrEx();
if (con.Rdr.HasRows)
{
while (con.Rdr.Read())
{
counter = con.Rdr.GetInt32(0);
counter += 1;
};
}
else
{
counter = 1;
}
con.Rdr.Close();
//con.SqlQuery("Insert into tblTest(C_Date,D_Name,Desk,Service,P_Name,Ticket,Num) values (@Date,@DName,@Desk,@Service,@PName,@Ticket,@Num)");
con.SqlQuery("Insert into tblTests(C_Date,D_Name,Desk,Service,P_Name,Num) values (@Date,@DName,@Desk,@Service,@PName,@Num)");
string paracounter = DateTime.Now.ToString("yyyy-MM-dd") + counter.ToString("D" + 3);
con.Cmd.Parameters.Add(new SqlParameter("@Date", this.dtpDate.Text));
con.Cmd.Parameters.Add(new SqlParameter("@DName", this.txtDoc.Text.Trim()));
con.Cmd.Parameters.Add(new SqlParameter("@Desk", this.txtDe.Text.Trim()));
con.Cmd.Parameters.Add(new SqlParameter("@Service", this.txtService.Text.Trim()));
con.Cmd.Parameters.Add(new SqlParameter("@PName", this.txtPatient.Text.Trim()));
//con.Cmd.Parameters.Add(new SqlParameter("@Ticket", this.txtTicket.Text.Trim()));
con.Cmd.Parameters.Add(new SqlParameter("@Num", paracounter));
con.NonQueryEx();
con.conClose();
MessageBox.Show("Patient Called...", "Sharaf Hospital", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}