private void toolDelete_Click(object sender, EventArgs e) { if (dgvUntreadGatherBill.RowCount == 0) { return; } if (GlobalProperty.OperatorCode != dgvUntreadGatherBill.CurrentRow.Cells["OperatorCode"].Value.ToString()) { MessageBox.Show("非本记录的录入人员,不许允许删除!", "软件提示"); return; } if (MessageBox.Show("确定要删除吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { RetailUntreadGatherBill rugb = new RetailUntreadGatherBill(); DataGridViewRow dgvr = dgvUntreadGatherBill.CurrentRow; int intId = Convert.ToInt32(dgvr.Cells["Id"].Value); String strSql = "Delete From UntreadGatherBill Where Id = " + intId; if (rugb.Delete(strSql)) { dgvUntreadGatherBill.Rows.Remove(dgvr); MessageBox.Show("删除成功!", "软件提示"); } else { MessageBox.Show("删除失败!", "软件提示"); } } }
private void btnQuery_Click(object sender, EventArgs e) { RetailUntreadGatherBill rugb = new RetailUntreadGatherBill(); string strSql = null; if (!chbIsCDNo.Checked) //没有选中光盘号查询 { if (!String.IsNullOrEmpty(txtCustomerName.Text.Trim())) { strSql += " and CustomerName like '%" + txtCustomerName.Text.Trim() + "%'"; } if (!(cbxProvinceCode.SelectedValue == null)) { strSql += " and ProvinceCode = '" + cbxProvinceCode.SelectedValue.ToString() + "'"; } if (!String.IsNullOrEmpty(txtAddress.Text.Trim())) { strSql += " and Address like '%" + txtAddress.Text.Trim() + "%'"; } if (!String.IsNullOrEmpty(txtPhoneNumber.Text.Trim())) { strSql += " and PhoneNumber like '%" + txtPhoneNumber.Text.Trim() + "%'"; } if (!String.IsNullOrEmpty(txtUntreadBillNo.Text.Trim())) { strSql += " and UntreadGatherBill.UntreadBillNo like '%" + txtUntreadBillNo.Text.Trim() + "%'"; } if (!(cbxGoodsTypeCode.SelectedValue == null)) { strSql += " and GoodsTypeCode = '" + cbxGoodsTypeCode.SelectedValue.ToString() + "'"; } if (!(cbxGoodsSeriesCode.SelectedValue == null)) { strSql += " and GoodsSeriesCode = '" + cbxGoodsSeriesCode.SelectedValue.ToString() + "'"; } if (dtpSignDate2.Checked) { strSql += " and UntreadGatherBill.SignDate2 = '" + dtpSignDate2.Value.Date + "'"; } if (dtpAppendDate.Checked) { strSql += " and UntreadGatherBill.AppendDate = '" + dtpAppendDate.Value.Date + "'"; } strSql = rugb.UntreadGatherBillSql + strSql; } if (chbIsCDNo.Checked) //选中光盘号查询 { if (String.IsNullOrEmpty(txtCDNo.Text.Trim())) { MessageBox.Show("请输入光盘号!", "软件提示"); txtCDNo.Focus(); return; } strSql = rugb.UntreadGatherBill_CDNo_Sql + " and UntreadCDRecord.CDNo = '" + txtCDNo.Text.Trim() + "'"; } formRetailUntreadGatherBill.bsUntreadGatherBill.DataSource = rugb.GetDataTable(strSql); formRetailUntreadGatherBill.dgvUntreadGatherBill.DataSource = formRetailUntreadGatherBill.bsUntreadGatherBill; this.Close(); }