/// <summary>
 /// 更新费用类别
 /// </summary>
 /// <param name="cInfo">实体</param>
 public void Update(InsuranceOfFreightTransportInfo cInfo)
 {
     if (string.IsNullOrEmpty(cInfo.ID))
     {
         throw new ArgumentNullException("参数ID不能为空。");
     }
     dal.Update(cInfo);
 }
 /// <summary>
 /// 添加费用类别
 /// </summary>
 /// <param name="cInfo">实体</param>
 /// <returns>新增实体的主键</returns>
 public string Add(InsuranceOfFreightTransportInfo cInfo)
 {
     return dal.Add(cInfo);
 }
 /// <summary>
 /// 添加费用类别
 /// </summary>
 /// <param name="ID">实体主键</param>
 /// <returns></returns>
 public void Delete(string ID)
 {
     InsuranceOfFreightTransportInfo cInfo = new InsuranceOfFreightTransportInfo(ID);
     dal.Delete(cInfo);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             TitleInitial("内贸线货运险投保货量及保费输入", "用户可以维护内贸线货运险投保货量及保费输入相关信息。");
             this.DimID = GetRequest("dimID");
             string shipID = string.Empty;
             BindShip(shipID);
             BindCurrency();
             this.ID = GetRequest("ID");
             InsuranceOfFreightTransportInfo wInfo = new InsuranceOfFreightTransportInfo();
             if (string.IsNullOrEmpty(this.ID) == false)
             {
                 wInfo = new BLL.InsuranceOfFreightTransport().GetByID(this.ID);
             }
             SetPageValue(wInfo);
             BindRate();
         }
     }
     catch (ArgumentNullException aex)
     {
         ShowMsg(aex.Message);
     }
     catch (Exception ex)
     {
         ShowMsg(ex.Message);
         Log(ex);
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                InsuranceOfFreightTransportInfo wInfo = new InsuranceOfFreightTransportInfo();
                if (string.IsNullOrEmpty(this.ID) == false)
                {
                    wInfo = new BLL.InsuranceOfFreightTransport().GetByID(this.ID);
                }

                wInfo.VoyageID = ddlVoyage.SelectedValue;
                wInfo.InputUserID = this.UserCacheInfo.ID;
                string year = tbYear.Text;
                string month = tbMonth.Text;
                string dimTimeID = new DimTime().GetIDByMonth(year, month);
                wInfo.DimTimeID = dimTimeID;
                wInfo.CurrencyID = ddlCurrency.SelectedValue;
                wInfo.ExchangeRateID = this.RateID;
                wInfo.Amount50kilo20feet = tb20英尺.Text;
                wInfo.Amount50kilo40feet = tb40英尺.Text;
                wInfo.备注 = tb备注.Text;

                tb总保费.Text = wInfo.总保费;
                lb总重柜量.Text = wInfo.总重柜量;

                if (string.IsNullOrEmpty(this.ID) == true)
                {
                    this.ID = new BLL.InsuranceOfFreightTransport().Add(wInfo);
                    wInfo.ID = this.ID;
                    SetPageValue(wInfo);
                }
                else
                {
                    new BLL.InsuranceOfFreightTransport().Update(wInfo);
                }
                ShowMsg("报表保存成功。");
            }
            catch (ArgumentNullException aex)
            {
                ShowMsg(aex.Message);
            }
            catch (Exception ex)
            {
                ShowMsg(ex.Message);
                Log(ex);
            }
        }
        /// <summary>
        /// 根据页面实体设置页面值
        /// </summary>
        /// <param name="wInfo"></param>
        private void SetPageValue(InsuranceOfFreightTransportInfo wInfo)
        {
            tbUserName.Text = this.UserCacheInfo.Name;
            tbCreateTime.Text = wInfo.CreateTime.ToShortDateString();
            tbYear.Text = wInfo.CreateTime.Year.ToString();
            tbMonth.Text = wInfo.CreateTime.Month.ToString();
            if (string.IsNullOrEmpty(wInfo.ID))
            {
                return;
            }
            DimTimeInfo dInfo = new DimTime().GetDimTimeInfo(wInfo.DimTimeID);
            tbMonth.Text = dInfo.MonthNumOfYear.ToString();
            tbYear.Text = dInfo.Year.ToString();

            ddlVoyage.SelectedValue = wInfo.VoyageID;
            VoyageInfo vInfo = new Voyage().GetByID(wInfo.VoyageID);
            ddlShip.SelectedValue = vInfo.ShipID.ToString();
            ddlCurrency.SelectedValue = wInfo.CurrencyID;
            ddlYear.SelectedValue = dInfo.Year.ToString();
            ddlMonth.SelectedValue = dInfo.MonthNumOfYear.ToString();

            tb20英尺.Text = wInfo.Amount50kilo20feet;
            tb40英尺.Text = wInfo.Amount50kilo40feet;
            BindList(this.ID);

            tb总保费.Text = wInfo.总保费;
            lb总重柜量.Text = wInfo.总重柜量;
            tb备注.Text = wInfo.备注;
        }