예제 #1
0
 /// <summary>
 /// 添加费用类别
 /// </summary>
 /// <param name="cInfo">实体</param>
 /// <returns>新增实体的主键</returns>
 public string Add(ContainerInfo cInfo)
 {
     if (string.IsNullOrEmpty(cInfo.编号))
     {
         throw new ArgumentNullException("编号不能为空。");
     }
     if (string.IsNullOrEmpty(cInfo.投保金额))
     {
         throw new ArgumentNullException("金额不能为空。");
     }
     return dal.Add(cInfo);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                int index = Convert.ToInt32(e.CommandArgument.ToString());
                GridViewRow gvr = (GridViewRow)gvList.Rows[index];
                HiddenField hfRelateId = (HiddenField)gvr.FindControl("hidRelateId");
                string relateId = hfRelateId.Value.ToString();

                if (e.CommandName == "btnDel")
                {
                    new Container().Delete(relateId);
                }
                else
                {
                    #region 控件
                    RadioButtonList rblType = (RadioButtonList)gvr.FindControl("rblType");
                    TextBox tb投保金额 = (TextBox)gvr.FindControl("tb投保金额");
                    TextBox tb编号 = (TextBox)gvr.FindControl("tb编号");
                    TextBox tb备注 = (TextBox)gvr.FindControl("tb备注");
                    #endregion

                    ContainerInfo info = new ContainerInfo();
                    info.投保金额 = tb投保金额.Text;
                    info.备注 = tb备注.Text;
                    info.编号 = tb编号.Text;
                    info.货柜类型 = rblType.SelectedValue; ;
                    info.ID = relateId;
                    info.InsuranceID = this.ID;

                    if (e.CommandName == "btnEdit")
                    {
                        new Container().Update(info);
                        ShowMsg("更新成功!");
                    }

                    if (e.CommandName == "btnAdd")
                    {
                        new Container().Add(info);
                    }
                }
                BindList(this.ID);
            }
            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)
 {
     IList<ContainerInfo> cList = new Container().GetList(id);
     ContainerInfo cInfo = new ContainerInfo();
     cList.Add(cInfo);
     gvList.DataSource = cList;
     gvList.DataBind();
 }
예제 #4
0
 /// <summary>
 /// 更新费用类别
 /// </summary>
 /// <param name="cInfo">实体</param>
 public void Update(ContainerInfo cInfo)
 {
     if (string.IsNullOrEmpty(cInfo.ID))
     {
         throw new ArgumentNullException("参数ID不能为空。");
     }
     dal.Update(cInfo);
 }
예제 #5
0
 /// <summary>
 /// 添加费用类别
 /// </summary>
 /// <param name="ID">实体主键</param>
 /// <returns></returns>
 public void Delete(string ID)
 {
     ContainerInfo cInfo = new ContainerInfo(ID);
     dal.Delete(cInfo);
 }