更改日期时更新文本框值

时间:2015-10-15 07:56:36

标签: c# asp.net sql-server-2008

我已将这些详细信息保存在数据库中并绑定到网格视图

每当开始日期超过一个月时,我想将付款金额更新为双倍 就像我想要更新3个月的付款(例如3个月5000 + 5000 + 5000 = 15000)

这是我的代码

SqlConnection con = new SqlConnection(@"server=SYS8\SQLSERVER2008DE;database=Naresh;Integrated Security=true");
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("select * from ValueUpdate", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    protected void txtStartDate_TextChanged(object sender, EventArgs e)
    {
        string inputString = txtStartDate.Text;
        DateTime dt = DateTime.ParseExact(inputString, "MM/dd/yyyy", CultureInfo.InvariantCulture);
        dt = dt.AddMonths(Convert.ToInt32(ddlmonths.SelectedItem.ToString()));
        txtEndDate.Text = dt.ToString("MM/dd/yyyy");

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        con.Open();

        SqlCommand cmd = new SqlCommand("Insert into ValueUpdate (NoOfMonths,StartDate,EndDate,Payment) values('" + ddlmonths.SelectedItem + "','" + txtStartDate.Text + "','" + txtEndDate.Text + "','" + txtMonthlyPay.Text + "')", con);

        cmd.ExecuteNonQuery();

1 个答案:

答案 0 :(得分:0)

您如何确认开始日期已超过一个月?什么是基准日期?