protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { ReceiptAdapter ra = new ReceiptAdapter(); if (e.Row.RowType == DataControlRowType.DataRow) { HiddenField hnfCheckStatus = e.Row.Cells[0].FindControl("hnf_check_status") as HiddenField; int check_status = Int32.Parse(hnfCheckStatus.Value); if (check_status == 2) { Button btn_delete = e.Row.Cells[0].FindControl("btnDelete") as Button; btn_delete.Enabled = false; btnSave.Enabled = false; } string type = e.Row.Cells[5].Text; if (type == "R") { e.Row.Cells[5].Text = "扣 款"; } else { e.Row.Cells[5].Text = "补 款"; } } }
private void GridViewBand() { ReceiptAdapter da = new ReceiptAdapter(); DataSet ds = da.getReceipts(); GridView1.DataSource = ds; GridView1.DataBind(); }
private void ddlReceiptTypeBind() { ReceiptAdapter ra = new ReceiptAdapter(); DataSet ds = ra.getReceipts(); ddl_receipt_type.DataTextField = "name"; ddl_receipt_type.DataValueField = "code"; ddl_receipt_type.DataSource = ds; ddl_receipt_type.DataBind(); }
protected void updateUser_Click(object sender, EventArgs e) { ReceiptAdapter da = new ReceiptAdapter(); T_Receipt item = new T_Receipt(); item.Code = this.txt_code.Text.Trim(); item.Name = this.txt_name.Text.Trim(); if (string.IsNullOrEmpty(item.Code)) { Label1.Text = "部门代码不能为空"; return; } if (string.IsNullOrEmpty(item.Name)) { Label1.Text = "部门名称不能为空"; return; } if (string.IsNullOrEmpty(HiddenField1.Value)) { //新增 try { da.addReceipt(item); Label1.Text = "新增成功"; init(); GridViewBand(); } catch (Exception ex) { Label1.Text = ex.Message; } } else { //更新 item.Id = Int32.Parse(HiddenField1.Value); try { da.updateReceipt(item); Label1.Text = "保存成功"; init(); GridViewBand(); } catch (Exception ex) { Label1.Text = ex.Message; } } }
protected void benDelete_Click(object sender, EventArgs e) { Button btn_del = sender as Button; GridViewRow row = btn_del.Parent.Parent as GridViewRow; int id = Int32.Parse((row.Cells[0].FindControl("hdfId") as HiddenField).Value); try { ReceiptAdapter da = new ReceiptAdapter(); da.DeleteReceiptById(id); Label1.Text = "保存成功"; init(); GridViewBand(); } catch (Exception ex) { Label1.Text = ex.Message; } }
public ReceiptForm(ReceiptAdapter adapter) { InitializeComponent(); this.adapter = adapter; }