/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e) { try { string id = e.CommandArgument.ToString(); GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer; GridView gvList = gvr.Parent as GridView; ReportCatalog catalog = ReportCatalog.InsuranceOfContainer; if (e.CommandName == "btnDel") { new InstalmentOfCompensation().Delete(id); } else { #region 控件 DropDownList ddlListCurrency = (DropDownList)gvr.FindControl("ddlListCurrency"); TextBox tb支付金额 = (TextBox)gvr.FindControl("tb支付金额"); WebControlLib.Calendar c支付日期 = (WebControlLib.Calendar)gvr.FindControl("c支付日期"); TextBox tb备注 = (TextBox)gvr.FindControl("tb备注"); #endregion InstalmentOfCompensationInfo info = new InstalmentOfCompensationInfo(); info.Amount = tb支付金额.Text; info.Remark = tb备注.Text; info.CompensationID = this.ID; info.CurrencyID = ddlListCurrency.SelectedValue; ; info.ReportType = EnumHandler<ReportCatalog>.GetStringFromEnum(catalog); info.PayDate = DateTime.Parse(c支付日期.Text); if (e.CommandName == "btnEdit") { info.ID = id; new InstalmentOfCompensation().Update(info); ShowMsg("更新成功!"); } if (e.CommandName == "btnAdd") { new InstalmentOfCompensation().Add(info); } } BindList(this.ID, catalog); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e) { try { GridView gvList = sender as GridView; int index = Convert.ToInt32(e.CommandArgument.ToString()); GridViewRow gvr = (GridViewRow)gvList.Rows[index]; HiddenField hfRelateId = (HiddenField)gvr.FindControl("hidRelateId"); string relateId = hfRelateId.Value.ToString(); ReportCatalog catalog = ReportCatalog.InsuranceOfShip; if (gvList.ID == "gvCompensationList") { catalog = ReportCatalog.InsuranceOfCompensation; } if (e.CommandName == "btnDel") { new InstalmentOfCompensation().Delete(relateId); } else { #region 控件 DropDownList ddlListCurrency = (DropDownList)gvr.FindControl("ddlListCurrency"); TextBox tb支付金额 = (TextBox)gvr.FindControl("tb支付金额"); WebControlLib.Calendar c支付日期 = (WebControlLib.Calendar)gvr.FindControl("c支付日期"); TextBox tb备注 = (TextBox)gvr.FindControl("tb备注"); #endregion InstalmentOfCompensationInfo info = new InstalmentOfCompensationInfo(); info.Amount = tb支付金额.Text; info.Remark = tb备注.Text; info.CompensationID = this.ID; info.CurrencyID = ddlListCurrency.SelectedValue; ; info.ReportType = EnumHandler<ReportCatalog>.GetStringFromEnum(catalog); info.PayDate = DateTime.Parse(c支付日期.Text); if (e.CommandName == "btnEdit") { new InstalmentOfCompensation().Update(info); ShowMsg("更新成功!"); } if (e.CommandName == "btnAdd") { new InstalmentOfCompensation().Add(info); } } BindList(this.ID, catalog); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// /// </summary> /// <param name="id"></param> private void BindList(string id, ReportCatalog catalogEnum) { string catalog = EnumHandler<ReportCatalog>.GetStringFromEnum(catalogEnum); IList<InstalmentOfCompensationInfo> cList = new InstalmentOfCompensation().GetList(id, catalog); InstalmentOfCompensationInfo cInfo = new InstalmentOfCompensationInfo(); cList.Add(cInfo); gvList.DataSource = cList; gvList.DataBind(); }
/// <summary> /// /// </summary> /// <param name="id"></param> private void BindList(string id, ReportCatalog catalogEnum) { string catalog = EnumHandler<ReportCatalog>.GetStringFromEnum(catalogEnum); IList<InstalmentOfCompensationInfo> cList = new InstalmentOfCompensation().GetList(id, catalog); InstalmentOfCompensationInfo cInfo = new InstalmentOfCompensationInfo(); cList.Add(cInfo); if (catalogEnum == ReportCatalog.InsuranceOfShip) { gvShipList.DataSource = cList; gvShipList.DataBind(); } else if (catalogEnum == ReportCatalog.InsuranceOfCompensation) { gvCompensationList.DataSource = cList; gvCompensationList.DataBind(); } }