大家好...
我有我的数据库中的数据保存到一个WinForm ...
但现在我想添加一个DateTimePicker和保存并显示在GridView,但我不知道它的代码...
可以请你帮我... IAM我给你保存额外的信息和显示代码...
这是我保存代码:
这是我的显示代码的方式显示在GridView IAM:try
{
da.InsertCommand = new SqlCommand("INSERT INTO Number VALUES(@Serial, @RegistrationNumber, @Size, @Color, @OwnerName, @AmountPaid)", cs);
da.InsertCommand.Parameters.Add("@Serial", SqlDbType.VarChar).Value = TxtSerial.Text;
da.InsertCommand.Parameters.Add("@RegistrationNumber", SqlDbType.VarChar).Value = TxtRegistrationNumber.Text;
da.InsertCommand.Parameters.Add("@Size", SqlDbType.VarChar).Value = TxtSize.Text;
da.InsertCommand.Parameters.Add("@Color", SqlDbType.VarChar).Value = TxtColor.Text;
da.InsertCommand.Parameters.Add("@OwnerName", SqlDbType.VarChar).Value = TxtOwnerName.Text;
da.InsertCommand.Parameters.Add("@AmountPaid", SqlDbType.VarChar).Value = TxtAmountPaid.Text;
cs.Open();
da.InsertCommand.ExecuteNonQuery();
cs.Close();
ds.Clear();
da.Fill(ds);
StatusLabel.Text = "Records have been saved";
}
catch (Exception)
{
MessageBox.Show(TxtRegistrationNumber.Text + " is already in the database");
}
{C}
请帮助我。| Maazatron:prajwal03 | |
的| Maazatron<script runat="server">
protected void calEventDate_SelectionChanged(object sender, EventArgs e)
{
tbxdateofjoining.Text = calEventDate.SelectedDate.ToString("d");
}
</script>
<script type="text/javascript">
function displayCalendar() {
var datePicker = document.getElementById('datePicker');
datePicker.style.display = 'block';
}
</script>
<style type="text/css">
#datePicker
{
display:none;
position:absolute;
border:solid 2px black;
background-color:white;
}
.content
{
width:400px;
background-color:white;
margin:auto;
padding:10px;
}
html
{
background-color:white;
}
</style>
<asp:TextBox ID="tbxdateofjoining" runat="server"
style="z-index: 1; left: 555px; top: 394px; position: absolute" ></asp:TextBox>
<img alt="" src="Images/calendar-schedulehs-thumb.png" onclick="displayCalendar()"
style="z-index: 1; left: 714px; top: 394px; position: absolute; height: 20px; width: 20px;" />
<div id="datePicker">
<asp:Calendar id="calEventDate" OnSelectionChanged="calEventDate_SelectionChanged" Runat="server" style="z-index: 1; left: 715px; top: 251px; position: absolute; height: 17px" />
</div>
ON ADD BUTTON CLICK.
protected void btnadd_Click(object sender, EventArgs e)
{
String connectionString = @"Data Source=TECH\SQLEXPRESS2008;Initial Catalog=employee;Integrated Security=True";
SqlConnection thisConnection = new SqlConnection(connectionString);
try
{
thisConnection.Open();
String thisQuery = "INSERT INTO EmployeeDetails(FirstName,MiddleName,LastName,Address,Telephone,MobileNo,DateOfBirth,Department,Designation,DateOfJoining,BloodGroup) VALUES ('" + tbxfirstname.Text + "', '" + tbxmiddlename.Text + "', '" + tbxlastname.Text + "', '" + tbxaddress.Text + "', '" + tbxtelephoneno.Text + "', '" + tbxmobileno.Text + "', '" + tbxdateofbirth.Text + "','" + tbxdepartment.Text + "','" + tbxdesignation.Text + "','" + tbxdateofjoining.Text + "','" + tbxbloodgroup.Text + "')";
SqlCommand thisCommand = new SqlCommand(thisQuery, thisConnection);
thisCommand.ExecuteNonQuery();
lblmessage.Text = "Record Added Successfully !!!";
thisConnection.Close();
}
catch (SqlException exp)
{
lblmessage.Text = exp.Message;
Console.WriteLine(exp.Message);
}
}