protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { string _name = (string)gv_List.DataKeys[e.NewSelectedIndex]["Name"]; ListTable <EWF_Flow_DataObject> lt = (ListTable <EWF_Flow_DataObject>)ViewState["ListTable"]; if (lt.Contains(_name)) { EWF_Flow_DataObject item = lt[_name]; ViewState["SelectedName"] = item["Name"]; tbx_Name.Text = item["Name"]; tbx_DisplayName.Text = item["DisplayName"]; ddl_DataType.SelectedValue = item["DataType"]; rbl_ReadOnly.SelectedValue = item["ReadOnly"]; rbl_Enable.SelectedValue = item["Enable"]; rbl_Visible.SelectedValue = item["Visible"]; ddl_ControlType.SelectedValue = item["ControlType"]; tbx_ControlWidth.Text = item["ControlWidth"] == "0" ? "" : item["ControlWidth"]; tbx_ControlHeight.Text = item["ControlHeight"] == "0" ? "" : item["ControlHeight"]; tbx_ControlStyle.Text = item["ControlStyle"]; tbx_ColSpan.Text = item["ColSpan"]; tbx_SortID.Text = item["SortID"]; rbl_IsRequireField.SelectedValue = item["IsRequireField"]; tbx_RegularExpression.Text = item["RegularExpression"]; tbx_FormatString.Text = item["FormatString"]; tbx_Description.Text = item["Description"]; if (int.Parse(item["RelationType"]) > 0) { rbl_RelationType.SelectedValue = item["RelationType"]; } rbl_RelationType_SelectedIndexChanged(null, null); if (rbl_RelationType.SelectedValue != "3") { if (ddl_RelationTableName != null || ddl_RelationTableName.Items.Count != 0) { ddl_RelationTableName.SelectedValue = item["RelationTableName"]; { ddl_RelationTableName_SelectedIndexChanged(null, null); } } if (ddl_RelationTextField != null || ddl_RelationTextField.Items.Count != 0) { ddl_RelationTextField.SelectedValue = item["RelationTextField"]; } if (ddl_RelationValueField != null || ddl_RelationValueField.Items.Count != 0) { ddl_RelationValueField.SelectedValue = item["RelationValueField"]; } } tbx_SearchPageURL.Text = item["SearchPageURL"]; bt_Add.Text = "修 改"; } }
protected void gv_FeeDetialList_RowDeleting(object sender, GridViewDeleteEventArgs e) { string _name = (string)gv_List.DataKeys[e.RowIndex]["Name"]; ListTable <EWF_Flow_DataObject> lt = (ListTable <EWF_Flow_DataObject>)ViewState["ListTable"]; if (lt.Contains(_name)) { lt.Remove(_name); } BindGrid(); }
protected void bt_AddDetail_Click(object sender, EventArgs e) { ListTable <CM_ContractDetail> _details = ViewState["Details"] as ListTable <CM_ContractDetail>; DateTime begindate = new DateTime(); DateTime enddate = new DateTime(); TextBox tbx_BeginDate = pl_detail.FindControl("CM_Contract_BeginDate") == null ? null : (TextBox)pl_detail.FindControl("CM_Contract_BeginDate"); TextBox tbx_EndDate = pl_detail.FindControl("CM_Contract_EndDate") == null ? null : (TextBox)pl_detail.FindControl("CM_Contract_EndDate"); if (tbx_BeginDate != null && tbx_EndDate != null) { DateTime.TryParse(tbx_BeginDate.Text, out begindate); DateTime.TryParse(tbx_EndDate.Text, out enddate); if (enddate < begindate) { MessageBox.Show(this, "协议终止日期不能小于起始日期。"); return; } } if (ddl_PayMode.SelectedValue == "0") { MessageBox.Show(this, "付款周期必选!"); return; } CM_ContractDetail item; if (ViewState["Selected"] == null) { //新增科目 if (_details.Contains(ddl_AccountTitle.SelectedValue)) { MessageBox.Show(this, "该科目已添加!"); return; } item = new CM_ContractDetail(); item.AccountTitle = int.Parse(ddl_AccountTitle.SelectedValue); if (TreeTableBLL.GetChild("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", item.AccountTitle).Rows.Count > 0) { MessageBox.Show(this, "费用科目必须选择最底级会计科目!" + ddl_AccountTitle.SelectedItem.Text); return; } } else {//修改科目 if (!_details.Contains(ddl_AccountTitle.SelectedValue)) { MessageBox.Show(this, "要修改的项目不存在!"); return; } item = _details[ViewState["Selected"].ToString()]; } item.ApplyLimit = decimal.Parse(tbx_ApplyLimit.Text); if (item.ApplyLimit == 0) { MessageBox.Show(this, "对不起,月费用金额不能为0!"); return; } item.PayMode = int.Parse(ddl_PayMode.SelectedValue); if (ViewState["Selected"] == null) { _details.Add(item); } else { _details.Update(item); } BindGrid(); tbx_ApplyLimit.Text = "0"; bt_AddDetail.Text = "新增"; ViewState["Selected"] = null; }
protected void bt_AddProduct_Click(object sender, EventArgs e) { #region 验证必填项 if (ViewState["Product"] == null || (int)ViewState["Product"] == 0) { lb_ErrInfo1.Text = "产品必填!"; return; } #endregion ListTable <PDT_ProductPrice_Detail> _details = ViewState["Details"] as ListTable <PDT_ProductPrice_Detail>; PDT_ProductPrice_Detail item; #region 产品存在与否判断 if (ViewState["Selected"] == null) { //新增产品 if (_details.Contains(ViewState["Product"].ToString())) { lb_ErrInfo1.Text = "该产品已添加!"; return; } item = new PDT_ProductPrice_Detail(); item.Product = (int)ViewState["Product"]; } else { //修改科目 if (!_details.Contains(ViewState["Product"].ToString())) { lb_ErrInfo1.Text = "要修改的产品不存在!"; return; } item = _details[ViewState["Selected"].ToString()]; select_ProductCode.Enabled = true; gv_List.SelectedIndex = -1; } #endregion lb_ProductName.ForeColor = System.Drawing.Color.Black; item.BuyingPrice = tbx_BuyingPrice.Text == "" ? 0 : decimal.Parse(tbx_BuyingPrice.Text); item.SalesPrice = tbx_SalesPrice.Text == "" ? 0 : decimal.Parse(tbx_SalesPrice.Text); if (ViewState["Selected"] == null) { _details.Add(item); //新增产品 } else { _details.Update(item); //更新产品 } BindGrid(); lb_ErrInfo1.Text = ""; tbx_BuyingPrice.Text = ""; tbx_SalesPrice.Text = ""; ViewState["Selected"] = null; }
protected void bt_Add_Click(object sender, EventArgs e) { #region 验证必填项 decimal costPrice = 0; if (ddl_Brand.SelectedValue == "0" || ddl_Brand.SelectedValue == "") { MessageBox.Show(this, "产品品牌必选!"); return; } else if (ddl_GiftCostClassify.SelectedValue == "0" || ddl_GiftCostClassify.SelectedValue == "") { MessageBox.Show(this, "赠品费用类别必选!"); return; } else if (!decimal.TryParse(tbx_CostPrice.Text, out costPrice)) { MessageBox.Show(this, "赠品费率必须是小数或整数!"); return; } #endregion ListTable <PDT_ClassifyGiftCostRate> _details = (ListTable <PDT_ClassifyGiftCostRate>)ViewState["Details"]; PDT_ClassifyGiftCostRate item; #region 产品存在与否判断 if (ViewState["Selected"] == null) { item = new PDT_ClassifyGiftCostRate(); if (select_Client.SelectValue == "" || select_Client.SelectValue == "0") { item.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue); } else { item.Client = int.Parse(select_Client.SelectValue.ToString()); item.OrganizeCity = new CM_ClientBLL(item.Client).Model.OrganizeCity; } item["InsertStaff"] = Session["UserID"].ToString(); ViewState["MAXID"] = ((int)ViewState["MAXID"]) + 1; item.ID = (int)ViewState["MAXID"]; } else { //修改科目 if (!_details.Contains(ViewState["Selected"].ToString())) { MessageBox.Show(this, "要修改的产品不存在!"); return; } item = _details[ViewState["Selected"].ToString()]; item["UpdateStaff"] = Session["UserID"].ToString(); gv_List.SelectedIndex = -1; } #endregion item["PDTBrand"] = ddl_Brand.SelectedValue; item["GiftCostClassify"] = ddl_GiftCostClassify.SelectedValue; item["Enabled"] = ddl_Enabled.SelectedValue; item["GiftCostRate"] = tbx_CostPrice.Text; item["UpdateStaff"] = Session["UserID"].ToString(); item.BeginMonth = int.Parse(ddl_BeginMonth.SelectedValue); int cycle = 0; if (int.TryParse(txt_Cycle.Text.Trim(), out cycle)) { item.Cycle = cycle; } item.Remark = tbx_Remark.Text.Trim(); if (ViewState["Selected"] == null) { foreach (PDT_ClassifyGiftCostRate p in _details.GetListItem()) { if (p.PDTBrand == item.PDTBrand && p.GiftCostClassify == item.GiftCostClassify) { MessageBox.Show(this, "已存在该分类的数据!"); return; } } _details.Add(item); } else { _details.Update(item); //更新产品 } BindGrid(); ddl_Brand.SelectedValue = "0"; ddl_GiftCostClassify.SelectedValue = "0"; ddl_Brand.Enabled = true; ddl_GiftCostClassify.Enabled = true; tbx_CostPrice.Text = ""; tbx_Remark.Text = ""; ViewState["Selected"] = null; bt_Add.Text = "增加"; }
protected void bt_AddProduct_Click(object sender, EventArgs e) { #region 验证必填项 if (ViewState["Product"] == null || (int)ViewState["Product"] == 0) { lb_ProductName.Text = "产品必填!"; lb_ProductName.ForeColor = System.Drawing.Color.Red; return; } #endregion ListTable <PDT_ProductCost> _details = (ListTable <PDT_ProductCost>)ViewState["Details"]; PDT_ProductCost item; #region 产品存在与否判断 if (ViewState["Selected"] == null) { //新增产品 if (_details.Contains(ViewState["Product"].ToString())) { lb_ProductName.Text = "该产品已添加!"; return; } item = new PDT_ProductCost(); item.Product = (int)ViewState["Product"]; item.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue); } else { //修改科目 if (!_details.Contains(ViewState["Product"].ToString())) { lb_ProductName.Text = "要修改的产品不存在!"; return; } item = _details[ViewState["Selected"].ToString()]; select_ProductCode.Enabled = true; gv_List.SelectedIndex = -1; } #endregion item["CostPrice"] = tbx_CostPrice.Text == "" ? "0" : tbx_CostPrice.Text; item["CostPrice2"] = tbx_CostPrice2.Text == "" ? "0" : tbx_CostPrice2.Text; item["CostPrice3"] = tbx_CostPrice3.Text == "" ? "0" : tbx_CostPrice3.Text; item["QuantityFactor"] = tbx_QuantityFactor.Text; if (ViewState["Selected"] == null) { _details.Add(item); //新增产品 } else { _details.Update(item); //更新产品 } BindGrid(); lb_ProductName.ForeColor = System.Drawing.Color.Black; select_ProductCode.SelectText = ""; tbx_CostPrice.Text = "0"; tbx_CostPrice2.Text = "0"; tbx_CostPrice3.Text = "0"; tbx_QuantityFactor.Text = "1"; ViewState["Selected"] = null; bt_AddProduct.Text = "增加"; }
//新增 protected void bt_Add_Click(object sender, EventArgs e) { ListTable <EWF_Flow_DataObject> lt = (ListTable <EWF_Flow_DataObject>)ViewState["ListTable"]; if (ViewState["SelectedName"] == null) { if (!lt.Contains(tbx_Name.Text)) { #region 新增数据字段 EWF_Flow_DataObject item = new EWF_Flow_DataObject(); item["App"] = ViewState["AppID"].ToString(); item["Name"] = tbx_Name.Text; item["DisplayName"] = tbx_DisplayName.Text; item["DataType"] = ddl_DataType.SelectedValue; item["ReadOnly"] = rbl_ReadOnly.SelectedValue; item["Enable"] = rbl_Enable.SelectedValue; item["Visible"] = rbl_Visible.SelectedValue; item["ControlType"] = ddl_ControlType.SelectedValue; item["ControlWidth"] = tbx_ControlWidth.Text; item["ControlHeight"] = tbx_ControlHeight.Text; item["ControlStyle"] = tbx_ControlStyle.Text; item["ColSpan"] = tbx_ColSpan.Text; item["SortID"] = tbx_SortID.Text; item["IsRequireField"] = rbl_IsRequireField.SelectedValue; item["RegularExpression"] = tbx_RegularExpression.Text; item["FormatString"] = tbx_FormatString.Text; item["Description"] = tbx_Description.Text; item["RelationType"] = rbl_RelationType.SelectedValue; if (item["RelationType"] != "3") { item["RelationTableName"] = ddl_RelationTableName.SelectedValue; if (item["RelationType"] == "2") { item["RelationValueField"] = ddl_RelationValueField.SelectedValue; item["RelationTextField"] = ddl_RelationTextField.SelectedValue; } } item["SearchPageURL"] = tbx_SearchPageURL.Text; lt.Add(item); #endregion } } else { if (lt.Contains((string)ViewState["SelectedName"])) { #region 修改数据字段 EWF_Flow_DataObject item = lt[(string)ViewState["SelectedName"]]; item["App"] = ViewState["AppID"].ToString(); item["Name"] = tbx_Name.Text; item["DisplayName"] = tbx_DisplayName.Text; item["DataType"] = ddl_DataType.SelectedValue; item["ReadOnly"] = rbl_ReadOnly.SelectedValue; item["Enable"] = rbl_Enable.SelectedValue; item["Visible"] = rbl_Visible.SelectedValue; item["ControlType"] = ddl_ControlType.SelectedValue; item["ControlWidth"] = tbx_ControlWidth.Text; item["ControlHeight"] = tbx_ControlHeight.Text; item["ControlStyle"] = tbx_ControlStyle.Text; item["ColSpan"] = tbx_ColSpan.Text; item["SortID"] = tbx_SortID.Text; item["IsRequireField"] = rbl_IsRequireField.SelectedValue; item["RegularExpression"] = tbx_RegularExpression.Text; item["FormatString"] = tbx_FormatString.Text; item["Description"] = tbx_Description.Text; item["RelationType"] = rbl_RelationType.SelectedValue; if (item["RelationType"] != "3") { item["RelationTableName"] = ddl_RelationTableName.SelectedValue; if (item["RelationType"] == "2") { item["RelationValueField"] = ddl_RelationValueField.SelectedValue; item["RelationTextField"] = ddl_RelationTextField.SelectedValue; } } item["SearchPageURL"] = tbx_SearchPageURL.Text; lt.Update(item); #endregion } ViewState["SelectedName"] = null; } bt_Add.Text = "新 增"; gv_List.SelectedIndex = -1; tbx_DisplayName.Text = ""; tbx_Name.Text = ""; tbx_SortID.Text = (int.Parse(tbx_SortID.Text) + 1).ToString(); BindGrid(); }