/// <summary> /// 删除 /// </summary> protected void DeleteButton_Click(object sender, EventArgs e) { bool deleted = false; var dateModel = LocalGlobal.GetDateModel(); SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; try { using (ContractProvider contProvider = new ContractProvider()) { foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string orno = List.DataKeys[row.RowIndex]["ORDNO"].ToString().Trim(); //合同 cmd.CommandText = contProvider.DeleteContractSql(orno); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteContractDetailSql(orno); cmd.ExecuteNonQuery(); //收款进度 cmd.CommandText = contProvider.DeleteArprocessSql(orno, LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteArprocessDetailSql(orno, LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); //有项被删除 deleted = true; } } } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage(this.GetGlobalResourceString("DeleteErrorMessage") + error.Message); return; } tran.Commit(); if (deleted) { this.BindList(); } else { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); } }