public static void InitSplitRate(FormDS.FormApplySplitRateDataTable tbSplitRate, DateTime BeginPeriod, DateTime EndPeriod) { int MonthCount = EndPeriod.Month - BeginPeriod.Month; if (MonthCount < 0 && MonthCount + 12 > 0 && MonthCount + 12 <= 12) { MonthCount += 12; } int UsedRate = 0; if (BeginPeriod != null && EndPeriod != null && MonthCount > 0) { for (int i = 0; i < MonthCount + 1; i++) { FormDS.FormApplySplitRateRow rowSplitRate = tbSplitRate.NewFormApplySplitRateRow(); rowSplitRate.FormApplyID = 0; if (i == MonthCount) { rowSplitRate.Rate = 100 - UsedRate; } else { decimal a = 100; rowSplitRate.Rate = decimal.ToInt32((decimal)100 / (decimal)(MonthCount + 1)); UsedRate += rowSplitRate.Rate; } rowSplitRate.Period = BeginPeriod.AddMonths(i); tbSplitRate.AddFormApplySplitRateRow(rowSplitRate); } } if (MonthCount > 0) { int tempRate = tbSplitRate[MonthCount].Rate; tbSplitRate[MonthCount].Rate = tbSplitRate[0].Rate; tbSplitRate[0].Rate = tempRate; } }
public bool IsSubmitValid() { if (this.FirstVolumeCtl.Text == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入第一个月销量!"); return(false); } else { try { int.Parse(this.FirstVolumeCtl.Text); } catch (Exception ex) { PageUtility.ShowModelDlg(this.Page, "第一个月销量必须为整数!"); return(false); } } if (this.SecondVolumeCtl.Text == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入第二个月销量!"); return(false); } else { try { int.Parse(this.SecondVolumeCtl.Text); } catch (Exception ex) { PageUtility.ShowModelDlg(this.Page, "第二个月销量必须为整数!"); return(false); } } if (this.ThirdVolumeCtl.Text == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入第三个月销量!"); return(false); } else { try { int.Parse(this.ThirdVolumeCtl.Text); } catch (Exception ex) { PageUtility.ShowModelDlg(this.Page, "第三个月销量必须为整数!"); return(false); } } if (this.SKUListView.Items.Count == 0) { PageUtility.ShowModelDlg(this.Page, "必须录入明细项"); return(false); } else { //如果是实物报销的话,只能有一条科目明细 //if (int.Parse(PaymentTypeDDL.SelectedValue) == (int)SystemEnums.PaymentType.ShiWu) { // if (this.InnerDS.FormApplyExpenseDetail.Count > 1) { // PageUtility.ShowModelDlg(this.Page, "支付方式为货补的话,有且只能有一条费用项,请检查"); // return false; // } //} foreach (FormDS.FormApplySKUDetailRow row in this.InnerDS.FormApplySKUDetail) { if (row.RowState != DataRowState.Deleted) { if (this.InnerDS.FormApplyExpenseDetail.Select("FormApplySKUDetailID = " + row.FormApplySKUDetailID.ToString()).Length == 0) { PageUtility.ShowModelDlg(this.Page, "每个产品项都需要有费用明细,请检查"); return(false); } } } } //促销期间和费用期间必须一致 DateTime PromotionBegin = DateTime.Parse(UCPromotionBegin.SelectedDate); DateTime PromotionEnd = DateTime.Parse(UCPromotionEnd.SelectedDate); DateTime BeginPeriodCtl = DateTime.Parse(this.ViewState["BeginPeriod"].ToString()); DateTime EndPeriodCt = DateTime.Parse(this.ViewState["EndPeriod"].ToString()); if (PromotionBegin.Year != BeginPeriodCtl.Year || PromotionBegin.Month != BeginPeriodCtl.Month) { PageUtility.ShowModelDlg(this.Page, "起始费用期间和促销开始日期必须一致,请检查"); return(false); } if (PromotionEnd.Year != EndPeriodCt.Year || PromotionEnd.Month != EndPeriodCt.Month) { PageUtility.ShowModelDlg(this.Page, "截止费用期间和促销截止日期必须一致,请检查"); return(false); } if (int.Parse(this.ViewState["ReimburseRequirements"].ToString()) <= 0) { PageUtility.ShowModelDlg(this.Page, "核销要求至少选一项,请检查"); return(false); } if (this.divSplitRate.Visible) { int RateTotal = 0; foreach (GridViewRow row in gvSplitRate.Rows) { if (row.RowType == DataControlRowType.DataRow) { FormDS.FormApplySplitRateRow detailRow = this.InnerDS.FormApplySplitRate[row.RowIndex]; RateTotal += detailRow.IsRateNull() ? 0 : detailRow.Rate; if (detailRow.IsRateNull() || detailRow.Rate <= 0) { if (row.RowIndex + 1 == InnerDS.FormApplySplitRate.Count && RateTotal < 100) { detailRow.Rate = 100 - RateTotal; } else { PageUtility.ShowModelDlg(this.Page, "分摊比例必须位数字且不能为空或零,请检查"); return(false); } } } } if (RateTotal != 100) { PageUtility.ShowModelDlg(this.Page, "分摊比例总和应为100,请检查"); return(false); } } return(true); }
public bool IsInputValid() { if (this.txtFormApplyName.Text == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入方案名称!"); return(false); } if (UCPromotionBegin.SelectedDate == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入促销开始日期!"); return(false); } if (UCPromotionEnd.SelectedDate == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入促销结束日期!"); return(false); } if (UCDeliveryBegin.SelectedDate == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入供货开始日期!"); return(false); } if (UCDeliveryEnd.SelectedDate == string.Empty) { PageUtility.ShowModelDlg(this.Page, "请录入供货结束日期!"); return(false); } DateTime promotionBegin = DateTime.Parse(UCPromotionBegin.SelectedDate); DateTime promotionEnd = DateTime.Parse(UCPromotionEnd.SelectedDate); if (promotionBegin > promotionEnd) { PageUtility.ShowModelDlg(this.Page, "促销结束日期必须大于开始日期!"); return(false); } DateTime deliveryBegin = DateTime.Parse(UCDeliveryBegin.SelectedDate); DateTime deliveryEnd = DateTime.Parse(UCDeliveryEnd.SelectedDate); if (deliveryBegin > deliveryEnd) { PageUtility.ShowModelDlg(this.Page, "供货结束日期必须大于开始日期!"); return(false); } if (this.SKUListView.EditIndex >= 0) { PageUtility.ShowModelDlg(this.Page, "所有费用明细项必须点击“更新产品”按钮,请检查!"); return(false); } int ReimburseRequirements = 0; foreach (ListItem Item in chkListReimburseRequirements.Items) { if (Item.Selected) { ReimburseRequirements += int.Parse(Item.Value); } } this.ViewState["ReimburseRequirements"] = ReimburseRequirements; foreach (GridViewRow row in gvSplitRate.Rows) { if (row.RowType == DataControlRowType.DataRow) { FormDS.FormApplySplitRateRow detailRow = this.InnerDS.FormApplySplitRate[row.RowIndex]; TextBox txtRate = (TextBox)row.FindControl("txtRate"); TextBox txtRemark = (TextBox)row.FindControl("txtRemark"); int Rate = 0; if (int.TryParse(txtRate.Text, out Rate)) { detailRow.Rate = Rate; } else { detailRow.Rate = 0; PageUtility.ShowModelDlg(this, "分摊比例只能为整数"); return(false); } detailRow.Remark = txtRemark.Text; } } return(true); }