Generate no autumatically
Hello Sir I am developing inventory management project in asp.net.I want to generate Challen number automatically with string i.e AS001.How to write code for tht please help me.Its urgent
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Aug 28, 2014, 3:19 PM
DateTime dt = Calendar1.SelectedDate + DateTime.Now.TimeOfDay;
txtchin.Text = dt.ToString("yyyyMMdd HH:mm:ss");
VulpesPosted Aug 29, 2014, 7:15 PM
However, if you use a full date/time including seconds (and possibly milliseconds), then you should be OK as the times when individual records are saved should then be unique.
Amol SonavanePosted Aug 29, 2014, 2:27 AM
Amol SonavanePosted Aug 29, 2014, 2:00 AM
Amol SonavanePosted Aug 28, 2014, 2:09 PM
Amol SonavanePosted Aug 28, 2014, 2:08 PM
VulpesPosted Aug 28, 2014, 1:09 PM
Amol SonavanePosted Aug 28, 2014, 12:48 PM
VulpesPosted Aug 28, 2014, 12:46 PM
Also is the column type in the database one that supports both date and time - in other words is it something other than the 'date' type which only supports dates?
Amol SonavanePosted Aug 28, 2014, 12:28 PM
VulpesPosted Aug 28, 2014, 11:48 AM
If you want both the date and time and want to be reasonably sure the datebase will accept it, I'd use: ToString ("yyyyMMdd HH:mm:ss").
Amol SonavanePosted Aug 28, 2014, 11:27 AM
Amol SonavanePosted Aug 28, 2014, 11:22 AM
VulpesPosted Aug 28, 2014, 11:06 AM
If you want to graft the current time onto whatever the selected date is, you could do this:
DateTime dt = Calendar1.SelectedDate + DateTime.Now.TimeOfDay;
As I said earlier I don't use Crystal Reports. I'd look for a suitable article of which there are plenty on this site alone:
http://www.c-sharpcorner.com/tags/1/Crystal-Reports/
Amol SonavanePosted Aug 28, 2014, 10:51 AM
Amol SonavanePosted Aug 28, 2014, 10:50 AM
VulpesPosted Aug 28, 2014, 5:56 AM
If you want to insert the current date and time , I'd use DateTime.Now rather than Calendar1.SelectedDate.
Sorry, I don't use Crystal Reports. I'd either search for an article on it or ask the question again in a new thread.
Amol SonavanePosted Aug 28, 2014, 3:31 AM
Amol SonavanePosted Aug 21, 2014, 6:00 AM
Amol SonavanePosted Aug 20, 2014, 4:00 PM
VulpesPosted Aug 20, 2014, 12:42 PM
Anyway, I've tried to reconstruct it below. Unfortunately, I can't test this as I don't have any ASP.NET stuff on the machine I'm using just now so there may be bugs.
Ideally, the SqlConnection object should be stored globally but I've stored it in Session state for now. I wouldn't bother storing the SqlCommand and SqlDataReader objects - I'd just create them as needed.
Amol SonavanePosted Aug 20, 2014, 10:53 AM
Amol SonavanePosted Aug 20, 2014, 9:08 AM
Amol SonavanePosted Aug 20, 2014, 9:08 AM
VulpesPosted Aug 20, 2014, 6:01 AM
Can you post your code and I'll have another look at it when I have more time.
Amol SonavanePosted Aug 20, 2014, 5:00 AM
Amol SonavanePosted Aug 20, 2014, 1:17 AM
Amol SonavanePosted Aug 20, 2014, 1:15 AM
VulpesPosted Aug 19, 2014, 2:46 PM
If you click on the imagebutton, then I can't think of any obvious reason why the code wouldn't work the same as for an 'ordinary' button.
However, if you click on the calendar control, then there isn't a Click event as such. However, there is a SelectionChanged event.
Can you clarify the position here.
Amol SonavanePosted Aug 19, 2014, 11:58 AM
Amol SonavanePosted Aug 19, 2014, 11:55 AM
VulpesPosted Aug 19, 2014, 11:30 AM
Amol SonavanePosted Aug 17, 2014, 10:55 AM
Amol SonavanePosted Aug 17, 2014, 9:10 AM
Amol SonavanePosted Aug 17, 2014, 5:48 AM
VulpesPosted Aug 12, 2014, 9:55 AM
Amol SonavanePosted Aug 12, 2014, 9:45 AM
VulpesPosted Aug 10, 2014, 11:28 AM
string conStr = "whatever";
SqlConnection con = new SqlConnection(conStr);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT TOP 1 challen FROM sometable ORDER BY challen DESC";
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
string challen = "AS000";
if (reader.HasRows)
{
reader.Read())
challen = reader["challen"].ToString();
}
reader.Close();
con.Close();
Label1.Text = challen;
Session["Challen"] = challen;
Amol SonavanePosted Aug 10, 2014, 11:08 AM
VulpesPosted Aug 10, 2014, 10:46 AM