private void btnDele_Click(object sender, EventArgs e) { SqlDal db = new SqlDal(); if (cbTruncateZhuBi.Checked) { db.TruncateZhuBi(); } else { string maxDate = dtpEnd.Value.Year.ToString() + ("0" + dtpEnd.Value.Month.ToString()).Substring(("0" + dtpEnd.Value.Month.ToString()).Length - 2, 2) + ("0" + dtpEnd.Value.Day.ToString()).Substring(("0" + dtpEnd.Value.Day.ToString()).Length - 2, 2); string minDate = dtpStart.Value.Year.ToString() + ("0" + dtpStart.Value.Month.ToString()).Substring(("0" + dtpStart.Value.Month.ToString()).Length - 2, 2) + ("0" + dtpStart.Value.Day.ToString()).Substring(("0" + dtpStart.Value.Day.ToString()).Length - 2, 2); db.DeleZhuBiByDate(maxDate, minDate); } this.Close(); }