protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); if ((int)ViewState["ID"] > 0) { BindData(); } if (Request.QueryString["ClientID"] != null) { int clientid = int.Parse(Request.QueryString["ClientID"]); MCSSelectControl control = (MCSSelectControl)UC_DetailView1.FindControl("CM_LinkMan_ClientID"); if (control != null) { CM_ClientBLL client = new CM_ClientBLL(clientid); control.SelectValue = clientid.ToString(); control.SelectText = client.Model.FullName; control.Enabled = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); ViewState["ClientID"] = Request.QueryString["ClientID"] == null ? 0 : int.Parse(Request.QueryString["ClientID"]); if ((int)ViewState["ID"] == 0) { if (ViewState["ClientID"] != null) { CM_ClientBLL client = new CM_ClientBLL((int)ViewState["ClientID"]); MCSSelectControl select_Client = UC_DetailView1.FindControl("FNA_ClientPaymentForcast_Client") == null ? null : (MCSSelectControl)UC_DetailView1.FindControl("FNA_ClientPaymentForcast_Client"); if (select_Client != null) { select_Client.SelectValue = ViewState["ClientID"].ToString(); select_Client.SelectText = client.Model.FullName; select_Client.Enabled = false; } } bt_Approve.Visible = false; btn_CancleApprove.Visible = false; } else { BindData(); } } }
void ddl_State_SelectedIndexChanged(object sender, EventArgs e) { MCSSelectControl select_MasterProduct = (MCSSelectControl)pl_detail.FindControl("PDT_Product_MasterProduct"); if (select_MasterProduct == null) { return; } PDT_Product m = new PDT_Product(); pl_detail.GetData(m); if (m.State != 3) { select_MasterProduct.SelectText = ""; select_MasterProduct.SelectValue = ""; select_MasterProduct.Enabled = false; } else { select_MasterProduct.Enabled = true; select_MasterProduct.PageUrl = "~/SubModule/Product/Pop_Search_Product.aspx?ID=" + select_MasterProduct.SelectValue + "&IsOpponent=" + ViewState["IsOpponent"].ToString() + "&ExtCondition=\"Brand=" + m.Brand.ToString() + " AND Classify=" + m.Classify.ToString() + "\""; } }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); if ((int)ViewState["ID"] == 0) { if (Request.QueryString["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]); Session["ClientID"] = ViewState["ClientID"]; } else if (Session["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString()); } } #endregion BindDropDown(); if ((int)ViewState["ID"] != 0) { BindData(); } else { if (ViewState["ClientID"] != null) { MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("CM_KPI_Client"); CM_ClientBLL client = new CM_ClientBLL((int)ViewState["ClientID"]); select_Client.SelectValue = ViewState["ClientID"].ToString(); select_Client.SelectText = client.Model.FullName; //select_Client.Enabled = false; } DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("CM_KPI_AccountMonth"); ddl_Month.SelectedValue = AC_AccountMonthBLL.GetCurrentMonth().ToString(); bt_Approve.Visible = false; bt_Delete.Visible = false; } } #region 增加计算合计得分按钮 if (bt_OK.Visible) { Label lb_TotalScore = (Label)UC_DetailView1.FindControl("CM_KPI_TotalScore"); Button bt_Compute = new Button(); bt_Compute.ID = "bt_Compute"; bt_Compute.Text = "计算总分"; bt_Compute.Click += new EventHandler(bt_Compute_Click); lb_TotalScore.Parent.Controls.Add(bt_Compute); } #endregion }
protected void btn_SalesForcast_Click(object sender, EventArgs e) { #region 已有分配单展示,没有则生成 MCSTreeControl tr_OrganizeCity = (MCSTreeControl)UC_DetailView1.FindControl("SVM_ClassifyForcast_OrganizeCity"); MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("SVM_ClassifyForcast_Client"); DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_ClassifyForcast_AccountMonth"); int id = SVM_ClassifyForcastBLL.Init(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_Month.SelectedValue), int.Parse(select_Client.SelectValue == "" ? "0" : select_Client.SelectValue), (int)Session["UserID"]); Response.Redirect("ClassifyForcastDetail.aspx?ForcastID=" + id.ToString()); #endregion }
protected void Page_Load(object sender, EventArgs e) { #region 获取界面控件 ddl_Transport = (DropDownList)pn_detail.FindControl("FNA_EvectionRoute_Transport"); if (ddl_Transport != null) { ddl_Transport.AutoPostBack = true; ddl_Transport.SelectedIndexChanged += new EventHandler(ddl_Transport_SelectedIndexChanged); } ddl_CarID = (DropDownList)pn_detail.FindControl("Car_DispatchRide_CarID"); if (ddl_CarID != null) { ddl_CarID.AutoPostBack = true; ddl_CarID.SelectedIndexChanged += new EventHandler(ddl_CarID_SelectedIndexChanged); } #endregion if (!IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); BindDropDown(); if ((int)ViewState["ID"] != 0) { BindData(); } else { Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]); MCSSelectControl select_Staff = (MCSSelectControl)pn_detail.FindControl("FNA_EvectionRoute_RelateStaff"); select_Staff.SelectText = staff.Model.RealName; select_Staff.SelectValue = staff.Model.ID.ToString(); TextBox tbx_BeginDate = (TextBox)pn_detail.FindControl("FNA_EvectionRoute_BeginDate"); if (tbx_BeginDate != null) { tbx_BeginDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); } TextBox tbx_EndDate = (TextBox)pn_detail.FindControl("FNA_EvectionRoute_EndDate"); if (tbx_EndDate != null) { tbx_EndDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); } bt_Delete.Visible = false; pn_detail.SetPanelVisible("Panel_OA_Car_DispatchRide_ByEvectionRoute", false); } } }
protected void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e) { Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity"); lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", e.CurSelectIndex); Label lb_SheetCode = (Label)pn_OrderApply.FindControl("ORD_OrderApply_SheetCode"); lb_SheetCode.Text = ORD_OrderApplyBLL.GenerateSheetCode(e.CurSelectIndex, AC_AccountMonthBLL.GetCurrentMonth()); MCSSelectControl select_Client = (MCSSelectControl)pn_OrderApply.FindControl("ORD_OrderApply_Client"); select_Client.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCity=" + e.CurSelectIndex; }
protected void select_StageClient_SelectChange(object sender, SelectChangeEventArgs e) { MCSSelectControl select_StageClient = (MCSSelectControl)pl_detail.FindControl("CAT_Activity_StageClient"); int client = 0; if (int.TryParse(select_StageClient.SelectValue, out client) && client > 0) { CM_ClientBLL _c = new CM_ClientBLL(client); TextBox tbx_Address = (TextBox)pl_detail.FindControl("CAT_Activity_Address"); if (tbx_Address != null && _c.Model != null) { tbx_Address.Text = _c.Model.Address; } } }
protected void Page_Load(object sender, EventArgs e) { DropDownList ddl_PayType = UC_DetailView1.FindControl("FNA_ClientPaymentInfo_PayType") == null ? null : (DropDownList)UC_DetailView1.FindControl("FNA_ClientPaymentInfo_PayType"); if (ddl_PayType != null) { ddl_PayType.SelectedIndexChanged += new EventHandler(ddl_PayType_SelectedIndexChanged); ddl_PayType.AutoPostBack = true; } if (!IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); if ((int)ViewState["ID"] == 0) { if (Request.QueryString["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]); Session["ClientID"] = ViewState["ClientID"]; } else if (Session["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString()); } if (ViewState["ClientID"] != null) { CM_ClientBLL client = new CM_ClientBLL((int)ViewState["ClientID"]); MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("FNA_ClientPaymentInfo_Client"); select_Client.SelectValue = ViewState["ClientID"].ToString(); select_Client.SelectText = client.Model.FullName; select_Client.Enabled = false; } TextBox tbx_ConfirmDate = (TextBox)UC_DetailView1.FindControl("FNA_ClientpaymentInfo_ConfirmDate"); bt_Approve.Visible = false; btn_CanclePass.Visible = false; UploadFile1.Visible = false; } else { BindData(); } } }
void rbl_HasSynergeticStaff_SelectedIndexChanged(object sender, EventArgs e) { MCSSelectControl select_SynergeticStaff = (MCSSelectControl)pl_detail.FindControl("JN_Journal_SynergeticStaff"); if (select_SynergeticStaff != null && rbl_HasSynergeticStaff != null) { if (rbl_HasSynergeticStaff.SelectedValue == "1") { select_SynergeticStaff.Enabled = true; } else { select_SynergeticStaff.Enabled = false; select_SynergeticStaff.SelectText = ""; select_SynergeticStaff.SelectValue = ""; } } }
protected void btn_SalesTarget_Click(object sender, EventArgs e) { #region 已有分配单展示,没有则生成 MCSTreeControl tr_OrganizeCity = (MCSTreeControl)UC_DetailView1.FindControl("SVM_SalesTarget_OrganizeCity"); MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("SVM_SalesTarget_Client"); DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_SalesTarget_AccountMonth"); if (tr_OrganizeCity.SelectValue == "0" || select_Client.SelectValue == "") { lb_Msg.Text = "必填先选择要填报的客户!"; MessageBox.Show(this, "必填先选择要填报的客户!" + tr_OrganizeCity.SelectValue + "|" + select_Client.SelectValue); return; } int id = SVM_SalesTargetBLL.InitProductList(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_Month.SelectedValue), int.Parse(select_Client.SelectValue == "" ? "0" : select_Client.SelectValue), (int)Session["UserID"]); Response.Redirect("SalesTargetDetail.aspx?TargetID=" + id.ToString()); #endregion }
protected void btn_Inventory_Click(object sender, EventArgs e) { #region 创建空的销量列表 MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("SVM_Inventory_Client"); DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_Inventory_AccountMonth"); if (select_Client.SelectValue != "") { TextBox tbx_InventoryDate = (TextBox)UC_DetailView1.FindControl("SVM_Inventory_InventoryDate"); if (tbx_InventoryDate != null) { int id = SVM_InventoryBLL.InitProductList(int.Parse(ddl_Month.SelectedValue), int.Parse(select_Client.SelectValue), DateTime.Parse(tbx_InventoryDate.Text), (int)Session["UserID"], (bool)ViewState["IsCXP"]); //空的 Response.Redirect("InventoryBatchInput.aspx?InventoryID=" + id.ToString() + "&Flag=1&IsCXP=" + ((bool)ViewState["IsCXP"] ? "1" : "0")); } } #endregion }
void control_Init(object sender, EventArgs e) { base.OnInit(e); MCSSelectControl control = (MCSSelectControl)sender; Rpt_DataSetParams param = ParamControlsInfo[control.ID]; if (param.DefaultValue != "") { control.SelectValue = GetDefaule(param.DefaultValue); control.SelectText = GetRelateTextByValue(param, GetDefaule(param.DefaultValue)); if (param.DefaultValue == "$TDPClient$" && control.SelectValue != "0" && control.SelectValue != "") { control.Enabled = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); if ((int)ViewState["ID"] == 0) { MCSSelectControl select_PrincipalStaff = (MCSSelectControl)pl_detail.FindControl("EWF_ApproveAgency_PrincipalStaff"); if (select_PrincipalStaff != null) { select_PrincipalStaff.SelectText = Session["UserRealName"].ToString(); select_PrincipalStaff.SelectValue = Session["UserID"].ToString(); } TextBox tbx_BeginDate = (TextBox)pl_detail.FindControl("EWF_ApproveAgency_BeginDate"); if (tbx_BeginDate != null) { tbx_BeginDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); } Label lb_EnableFlag = (Label)pl_detail.FindControl("EWF_ApproveAgency_EnableFlag"); if (lb_EnableFlag != null) { lb_EnableFlag.Text = "有效"; } BindAppList(false); tr_AppList.Visible = true; bt_Disable.Visible = false; } else { BindData(); } } }
protected void Page_Load(object sender, System.EventArgs e) { select_RelateClient = (MCSSelectControl)pl_detail.FindControl("JN_Journal_RelateClient"); select_RelateClient.SelectChange += new SelectChangeEventHandler(select_RelateClient_SelectChange); // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 if (Request.QueryString["ID"] != null) { ViewState["ID"] = Int32.Parse(Request.QueryString["ID"]); } #endregion BindDropDown(); if (ViewState["ID"] != null) { BindData(); } else { ((TextBox)pl_detail.FindControl("JN_Journal_BeginTime")).Text = DateTime.Today.ToString("yyyy-MM-dd"); //Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"], true); //tr_OfficialCity.SelectValue = staff.Model.OfficialCity.ToString(); //tbx_IPAddress.Text = Request.UserHostAddress; bt_Delete.Visible = false; tr_comment.Visible = false; tr_uploadfile.Visible = false; } } }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { if (DataSet == Guid.Empty) return; IList<Rpt_DataSetParams> paramfields = new Rpt_DataSetBLL(DataSet, true).GetParams(); if (paramfields.Count == 0) return; //无参数 HtmlTable T_Content = new HtmlTable(); string[] tablestyles = new string[] { "tabForm", "dataLabel", "dataField" }; T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = "DataSetParamPanel"; HtmlTableCell tc_panel = new HtmlTableCell(); #region The title of the panel HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>请设置统计报表参数信息</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); #endregion #region The content of the panel int FieldCount = 3; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = tablestyles[0]; int i = 0; foreach (Rpt_DataSetParams param in paramfields) { string ControlID = "Param_" + param.ParamName.Replace("@", ""); //判断该控件是否已存在 if (ParamControlsInfo.ContainsKey(ControlID)) continue; ParamControlsInfo.Add(ControlID, param); if (param.Visible == "Y") { #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = tablestyles[1]; tc_displayname.InnerText = param.DisplayName; if (tc_displayname.InnerText.Length <= 6) tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; else tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = tablestyles[2]; i++; WebControl control = null; int RelationType = param.RelationType; string RelationTableName = param.RelationTableName; string RelationValueField = param.RelationValueField; string RelationTextField = param.RelationTextField; #region 根据控件类型生成相应的控件 switch (param.ControlType) { case 1://Label control = new Label(); ((Label)control).Text = GetDefaule(param.DefaultValue); break; case 2://TextBox control = new TextBox(); if (param.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 3://DropDownList control = new DropDownList(); if (RelationType == 1)//Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (param.DataType != 5) ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); else ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); if (param.DefaultValue != "") { if (((DropDownList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) ((DropDownList)control).SelectedValue = GetDefaule(param.DefaultValue); } break; case 4://RadioButtonList control = new RadioButtonList(); if (RelationType == 1)//Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) ((RadioButtonList)control).SelectedIndex = 0; if (param.DefaultValue != "") { if (((RadioButtonList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) ((RadioButtonList)control).SelectedValue = GetDefaule(param.DefaultValue); } break; case 5://MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 6://TextBox supports search control = new MCSSelectControl(); control.ID = ControlID; if (param.SearchPageURL != "") ((MCSSelectControl)control).PageUrl = param.SearchPageURL; if (param.DefaultValue != "") { control.Init += new EventHandler(control_Init); } break; case 7://MCSTreeControl control = new MCSTreeControl(); control.ID = ControlID; if (param.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } if (param.DefaultValue != "") { if (((MCSTreeControl)control).SelectValue == "0" || ((MCSTreeControl)control).SelectValue == "") ((MCSTreeControl)control).SelectValue = GetDefaule(param.DefaultValue); } break; } #endregion control.ID = ControlID; control.Enabled = param["Enable"] != "N"; int controlwidth = 0; if (int.TryParse(param["ControlWidth"], out controlwidth)) control.Width = new Unit(controlwidth); tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (param["IsRequireField"] == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (param.ControlType == 2 || param.ControlType == 5) { if (param["IsRequireField"] == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(_requiredfieldvalidator); } if (param.DataType == 1 || param.DataType == 2 || param.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; if (param.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (param.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (param.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (param.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = param.RegularExpression; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion } } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); #region 如果非总部职位,其只能选择自己职位及以下职位 Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]); Org_Position p = new Org_PositionBLL(staff.Model.Position).Model; MCSTreeControl tr_Position = (MCSTreeControl)panel1.FindControl("Org_Staff_Position"); if (tr_Position != null) { if (p != null && p.IsHeadOffice != "Y" && p.Remark != "OfficeHR") //备注为"OfficeHR":人事经理,可以选择全部职位 { tr_Position.RootValue = p.SuperID.ToString(); tr_Position.SelectValue = staff.Model.Position.ToString(); } else { tr_Position.RootValue = "1"; tr_Position.SelectValue = "1"; } } #endregion DropDownList ddl_Dimission = (DropDownList)panel1.FindControl("Org_Staff_Dimission"); if (ddl_Dimission != null) { ddl_Dimission.Enabled = false; } TextBox tbx_EndWorkTime = (TextBox)panel1.FindControl("Org_Staff_EndWorkTime"); if (tbx_EndWorkTime != null) { tbx_EndWorkTime.Enabled = false; } #region 非平台用户只能新增本层级用户 if ((int)Session["OwnerType"] == 2 || (int)Session["OwnerType"] == 3) { DropDownList ddl_OwnerType = (DropDownList)panel1.FindControl("Org_Staff_OwnerType"); MCSSelectControl select_OwnerClient = (MCSSelectControl)panel1.FindControl("Org_Staff_OwnerClient"); if (ddl_OwnerType != null && select_OwnerClient != null) { ddl_OwnerType.SelectedValue = Session["OwnerType"].ToString(); ddl_OwnerType.Enabled = false; select_OwnerClient.SelectValue = Session["OwnerClient"].ToString(); select_OwnerClient.SelectText = Session["OwnerClientName"].ToString(); select_OwnerClient.Enabled = false; } } #endregion if ((int)ViewState["ID"] > 0) { BindData(); } else { tr_LoginUser.Visible = false; tr_StaffInOrganizeCity.Visible = false; UploadFile1.Visible = false; bt_AddApply.Visible = false; bt_RevocationApply.Visible = false; bt_Approve.Visible = false; bt_Print.Visible = false; if (ddl_Dimission != null) { ddl_Dimission.SelectedValue = "1"; } RadioButtonList rbl_ApproveFlag = (RadioButtonList)panel1.FindControl("Org_Staff_ApproveFlag"); if (rbl_ApproveFlag != null) { rbl_ApproveFlag.SelectedValue = "2"; } DropDownList ddl_SalaryFlag = (DropDownList)panel1.FindControl("Org_Staff_SalaryFlag"); if (ddl_SalaryFlag != null) { ddl_SalaryFlag.SelectedValue = "1"; } } } }
protected bool bNoDelivery = false; //未发货,界面发货数量字段可编辑 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); ViewState["Client"] = Request.QueryString["Client"] == null ? 0 : int.Parse(Request.QueryString["Client"]); BindDropDown(); pn_OrderDelivery.SetPanelVisible("Panel_LGS_OrderDeliveryDetail00_02", false); if ((int)ViewState["ID"] == 0) { if ((int)ViewState["Client"] == 0) { return; } #region 新增发货单时,初始化界面 CM_Client client = new CM_ClientBLL((int)ViewState["Client"]).Model; if (client != null) { ViewState["OrganizeCity"] = client.OrganizeCity; Label lb_Client = (Label)pn_OrderDelivery.FindControl("ORD_OrderDelivery_Client"); if (lb_Client != null) { lb_Client.Text = client.FullName; } MCSSelectControl select_Store = (MCSSelectControl)pn_OrderDelivery.FindControl("ORD_OrderDelivery_Store"); if (select_Store != null && client.Supplier != 0) { select_Store.SelectText = new CM_ClientBLL(client.Supplier).Model.FullName; select_Store.SelectValue = client.Supplier.ToString(); } TextBox tbx_DeliveryTime = (TextBox)pn_OrderDelivery.FindControl("ORD_OrderDelivery_DeliveryTime"); if (tbx_DeliveryTime != null) { tbx_DeliveryTime.Text = DateTime.Today.ToString("yyyy-MM-dd"); } TextBox tbx_PreArrivalDate = (TextBox)pn_OrderDelivery.FindControl("ORD_OrderDelivery_PreArrivalDate"); if (tbx_PreArrivalDate != null) { tbx_PreArrivalDate.Text = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"); } bNoDelivery = true; bt_Delete.Visible = false; } #endregion #region 创建空的列表 ListTable <ORD_OrderDeliveryDetail> _details = new ListTable <ORD_OrderDeliveryDetail> (new List <ORD_OrderDeliveryDetail>(), "Product"); DataTable dtProduct = ORD_OrderDeliveryBLL.InitProductList((int)ViewState["Client"], 0); foreach (DataRow row in dtProduct.Rows) { ORD_OrderDeliveryDetail item = new ORD_OrderDeliveryDetail(); item.Product = (int)row["Product"]; item.FactoryPrice = (decimal)row["FactoryPrice"]; item.Price = (decimal)row["SalesPrice"]; item.Client = (int)ViewState["Client"]; item.DeliveryQuantity = 0; item.SignInQuantity = 0; item.BadQuantity = 0; item.LostQuantity = 0; _details.Add(item); } ViewState["Details"] = _details; #endregion BindGrid(); } else { BindData(); } } }
protected void Page_Load(object sender, System.EventArgs e) { CM_Client_Classification = pl_detail.FindControl("CM_Client_Classification") != null ? (DropDownList)pl_detail.FindControl("CM_Client_Classification") : null; // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 if (Request.QueryString["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]); Session["ClientID"] = ViewState["ClientID"]; } else if (Session["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString()); } #endregion //Session["MCSMenuControl_FirstSelectIndex"] = "11"; if (ViewState["ClientID"] != null) { BindData(); BindDropDown(); } else if (Request.QueryString["Mode"] == "New") { #region 新增门店时的初始值 Org_Staff staff = new Org_StaffBLL((int)Session["UserID"]).Model; if (staff == null) { Response.Redirect("~/SubModule/Desktop.aspx"); } #region 新增客户时,详细资料界面控件初始化 DropDownList ddl_ActiveFlag = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag"); if (ddl_ActiveFlag != null) { ddl_ActiveFlag.SelectedValue = "4"; } TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime"); if (tbx_OpenTime != null) { tbx_OpenTime.Text = DateTime.Today.ToString("yyyy-MM-dd"); } MCSTreeControl tr_OrganizeCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OrganizeCity"); if (tr_OrganizeCity != null) { tr_OrganizeCity.SelectValue = staff.OrganizeCity.ToString(); } MCSTreeControl tr_OfficalCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OfficalCity"); if (tr_OfficalCity != null) { tr_OfficalCity.SelectValue = staff.OfficialCity.ToString(); } MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager"); if (select_ClientManager != null) { select_ClientManager.SelectText = staff.RealName; select_ClientManager.SelectValue = staff.ID.ToString(); } DropDownList ddl_ChiefLinkMan = pl_detail.FindControl("CM_Client_ChiefLinkMan") != null ? (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan") : null; if (ddl_ChiefLinkMan != null) { ddl_ChiefLinkMan.Items.Clear(); ddl_ChiefLinkMan.Enabled = false; } DropDownList ddl_RTClassify = (DropDownList)pl_detail.FindControl("CM_Client_RTClassify"); if (ddl_RTClassify != null) { if (ddl_RTClassify.Items.FindByValue("1") != null) { ddl_RTClassify.SelectedValue = "1"; } } #endregion bt_AddLinkMan.Visible = false; bt_Approve.Visible = false; tr_Contract.Visible = false; tr_LinkMan.Visible = false; tr_Promotor.Visible = false; bt_Analysis.Visible = false; bt_AddApply.Visible = false; bt_RevocationApply.Visible = false; bt_Record.Visible = false; bt_ReplaceClientManager.Visible = false; #endregion } else { MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery); } } #region 给活跃标志加事件 DropDownList ddl_ActiveFlag_1 = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag"); ddl_ActiveFlag_1.AutoPostBack = true; ddl_ActiveFlag_1.SelectedIndexChanged += new EventHandler(ddl_ActiveFlag_SelectedIndexChanged); #endregion TextBox tbx_Code = (TextBox)pl_detail.FindControl("CM_Client_Code"); tbx_Code.AutoPostBack = true; tbx_Code.TextChanged += new EventHandler(tbx_Code_TextChanged); CM_Client_MarketType = pl_detail.FindControl("CM_Client_MarketType") != null ? (DropDownList)pl_detail.FindControl("CM_Client_MarketType") as DropDownList : null; CM_Client_OfficalCity = pl_detail.FindControl("CM_Client_OfficalCity") != null ? (MCSTreeControl)pl_detail.FindControl("CM_Client_OfficalCity") : null; if (CM_Client_OfficalCity != null) { CM_Client_OfficalCity.AutoPostBack = true; CM_Client_OfficalCity.Selected += new SelectedEventHandler(CM_Client_OfficalCity_Selected); } TextBox tbx_FullName = pl_detail.FindControl("CM_Client_FullName") == null ? null : (TextBox)pl_detail.FindControl("CM_Client_FullName"); if (tbx_FullName != null) { tbx_FullName.AutoPostBack = true; tbx_FullName.TextChanged += new EventHandler(tbx_FullName_TextChanged); } #region 注册弹出窗口脚本 string script = "function PopReplaceClientManager(id,clienttype){\r\n"; script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../ReplaceClientManager.aspx") + "?ClientManager=' + id + '&ClientType='+clienttype+'&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=260px;status:yes;resizable=yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopReplaceClientManager", script, true); #endregion //ddl_RTChannel = pl_detail.FindControl("CM_Client_RTChannel") as DropDownList; //ddl_RTChannel.AutoPostBack = true; //ddl_RTChannel.SelectedIndexChanged += new EventHandler(ddl_RTChannel_SelectedIndexChanged); DropDownList ddl_IsRMSClient = pl_detail.FindControl("CM_Client_IsRMSClient") as DropDownList; //ddl_IsRMSClient.AutoPostBack = true; //ddl_IsRMSClient.SelectedIndexChanged += new EventHandler(ddl_IsRMSClient_SelectedIndexChanged); //foreach (ListItem item in ddl_IsRMSClient.Items) //{ // if (item.Value == "1" && item.Text == "已启动") // { // item.Attributes.Add("disabled", "true"); // } //} //非"雅慧电商"的流通店 不允许选择积分店状态 //DropDownList ddl_RTClassifyTemp = pl_detail.FindControl("CM_Client_RTClassify") as DropDownList; //if (ddl_RTClassifyTemp != null && ddl_RTClassifyTemp.SelectedValue == "1" && ddl_RTChannel.SelectedValue != "20") //{ // ddl_IsRMSClient.SelectedValue = "2"; // ddl_IsRMSClient.Enabled = false; // DropDownList ddl_RMSAccountEnabled = pl_detail.FindControl("CM_Client_RMSAccountEnabled") as DropDownList; // ddl_RMSAccountEnabled.SelectedValue = "2"; //} //this.ddl_RMSAccountEnabled_Select(); //this.ShowRMSCloseDate(); }
protected void Page_Load(object sender, System.EventArgs e) { #region 初始化页面控件 Page.ClientScript.RegisterClientScriptInclude("meizzDate", Page.ResolveClientUrl("~/App_Themes/basic/meizzDate.js")); select_RelateClient = (MCSSelectControl)pl_detail.FindControl("JN_Journal_RelateClient"); if (select_RelateClient != null) { select_RelateClient.SelectChange += new SelectChangeEventHandler(select_RelateClient_SelectChange); } ddl_RelateLinkMan = (DropDownList)pl_detail.FindControl("JN_Journal_RelateLinkMan"); if (ddl_RelateLinkMan != null) { ddl_RelateLinkMan.DataTextField = "Name"; ddl_RelateLinkMan.DataValueField = "ID"; } rbl_HasSynergeticStaff = (RadioButtonList)pl_detail.FindControl("JN_Journal_HasSynergeticStaff"); if (rbl_HasSynergeticStaff != null) { rbl_HasSynergeticStaff.AutoPostBack = true; rbl_HasSynergeticStaff.SelectedIndexChanged += new EventHandler(rbl_HasSynergeticStaff_SelectedIndexChanged); } ddl_RelateActivity = (DropDownList)pl_detail.FindControl("JN_Journal_RelateActivity"); if (ddl_RelateActivity != null) { ddl_RelateActivity.DataTextField = "Topic"; ddl_RelateActivity.DataValueField = "ID"; ddl_RelateActivity.AutoPostBack = true; ddl_RelateActivity.SelectedIndexChanged += new EventHandler(ddl_RelateActivity_SelectedIndexChanged); } #endregion // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null?Int32.Parse(Request.QueryString["ID"]) : 0; #endregion BindDropDown(); if ((int)ViewState["ID"] != 0) { if (rbl_HasSynergeticStaff != null) { rbl_HasSynergeticStaff.SelectedValue = "2"; //默认非协同拜访 } BindData(); } else { if (Request.QueryString["Day"] != null && Request.QueryString["Day"] != "0") { tbx_begindate.Text = DateTime.Today.AddDays(int.Parse(Request.QueryString["Day"]) - DateTime.Today.DayOfYear).ToString("yyyy-MM-dd"); } else { tbx_begindate.Text = DateTime.Today.ToString("yyyy-MM-dd"); } #region 获取日志填报人信息 Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"], true); select_Staff.SelectText = staff.Model.RealName; select_Staff.SelectValue = Session["UserID"].ToString(); Org_PositionBLL position = new Org_PositionBLL(staff.Model.Position); lbl_Position.Text = position.Model.Name; MCSTreeControl tr_OfficialCity = pl_detail.FindControl("JN_Journal_OfficialCity") != null ? (MCSTreeControl)pl_detail.FindControl("JN_Journal_OfficialCity") : null; if (tr_OfficialCity != null) { tr_OfficialCity.SelectValue = staff.Model.OfficialCity.ToString(); } #endregion #region 获取本机IP TextBox tbx_IPAddress = pl_detail.FindControl("JN_Journal_IPAddress") != null ? (TextBox)pl_detail.FindControl("JN_Journal_IPAddress") : null; if (tbx_IPAddress != null) { tbx_IPAddress.Text = Request.UserHostAddress; TextBox tbx_IPLocation = pl_detail.FindControl("JN_Journal_IPLocation") != null ? (TextBox)pl_detail.FindControl("JN_Journal_IPLocation") : null; userAddress = Const_IPLocationBLL.FindByIP(Request.UserHostAddress); if (tbx_IPLocation != null) { tbx_IPLocation.Text = userAddress != null ? userAddress.Location : ""; } } #endregion #region 新增日志时,联系人字段不可编辑 if (ddl_RelateLinkMan != null) { ddl_RelateLinkMan.Items.Clear(); ddl_RelateLinkMan.Enabled = false; } #endregion pl_detail.SetPanelVisible("Panel_OA_JournalDetail_02", false); pl_detail.SetPanelVisible("Panel_OA_JournalDetail_03", false); pl_detail.SetPanelVisible("Panel_OA_JournalDetail_04", false); #region 默认无领导协同拜访 if (rbl_HasSynergeticStaff != null) { rbl_HasSynergeticStaff.SelectedValue = "2"; //默认非协同拜访 rbl_HasSynergeticStaff_SelectedIndexChanged(null, null); } #endregion bt_AddNewClient.Visible = false; bt_Delete.Visible = false; tbl_comment.Visible = false; UploadFile1.Visible = false; bt_ToEvectionRoute.Visible = false; } } #region 注册脚本 string script = "function OpenClientInput(Journalid,OfferMan,Activityid){\r\n"; script += "window.open('../../CSO/CSO_SampleOfferDetail.aspx?JournalID='+Journalid+'&OfferMan='+OfferMan+'&ActivityID='+Activityid);}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OpenClientInput", script, true); #endregion }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); UD_DetailViewBLL _DetailViewBll = new UD_DetailViewBLL(DetailViewCode, true); IList<UD_Panel> _panellist = _DetailViewBll.GetDetailPanels(); Hashtable _htFieldControlsInfo = new Hashtable(); foreach (UD_Panel _panelmodel in _panellist) { HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = _panelmodel.Code; if (_panelmodel.Enable.ToUpper() == "N") tr_panel.Visible = false; HtmlTableCell tc_panel = new HtmlTableCell(); string _tablestytle = _panelmodel.TableStyle; string[] _tablestyles = _panelmodel.TableStyle.Split(new char[] { ',' }); if (_tablestyles.Length < 3) _tablestyles = ("tabForm,dataLabel,dataField").Split(new char[] { ',' }); #region The title of the panel if (_panelmodel.Name != "") { HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>" + _panelmodel.Name + "</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); } #endregion #region The content of the panel IList<UD_Panel_ModelFields> fields = new UD_PanelBLL(_panelmodel.ID, true).GetModelFields(); int FieldCount = _panelmodel.FieldCount; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = _tablestyles[0]; int i = 0; foreach (UD_Panel_ModelFields _panel_modelfields in fields) { if (_panel_modelfields.Visible == "N") continue; UD_ModelFields _modelfieldsmodel = new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model; UD_TableList _tablemodel = new UD_TableListBLL(_modelfieldsmodel.TableID, true).Model; #region 判断该控件是否已存在 if (_htFieldControlsInfo.Contains(_tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName)) continue; #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = _tablestyles[1]; tc_displayname.InnerText = string.IsNullOrEmpty(_panel_modelfields.LabelText) ? _modelfieldsmodel.DisplayName : _panel_modelfields.LabelText; if (tc_displayname.InnerText.Length <= 6) tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; else tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = _tablestyles[2]; if (_panel_modelfields.ColSpan > 0) { if (i + _panel_modelfields.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _panel_modelfields.ColSpan - 1; i = i + _panel_modelfields.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _modelfieldsmodel.RelationType; string RelationTableName = _modelfieldsmodel.RelationTableName; string RelationValueField = _modelfieldsmodel.RelationValueField; string RelationTextField = _modelfieldsmodel.RelationTextField; #region 根据控件类型生成相应的控件 switch (_panel_modelfields.ControlType) { case 1://Label control = new Label(); break; case 2://TextBox control = new TextBox(); if (_modelfieldsmodel.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } break; case 3://DropDownList control = new DropDownList(); if (RelationType == 1)//Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (_modelfieldsmodel.DataType != 5) ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); else ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); break; case 4://RadioButtonList control = new RadioButtonList(); if (RelationType == 1)//Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) ((RadioButtonList)control).SelectedIndex = 0; break; case 5://MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_panel_modelfields.ControlHeight > 0) ((TextBox)control).Height = new Unit(_panel_modelfields.ControlHeight); break; case 6://TextBox supports search control = new MCSSelectControl(); if (RelationType == 2)//Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_panel_modelfields.SearchPageURL != "") ((MCSSelectControl)control).PageUrl = _panel_modelfields.SearchPageURL; else if (_modelfieldsmodel.SearchPageURL != "") ((MCSSelectControl)control).PageUrl = _modelfieldsmodel.SearchPageURL; } break; case 7://MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2)//Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取所能管辖的片区 if (System.Web.HttpContext.Current.Session["AccountType"] == null || (int)System.Web.HttpContext.Current.Session["AccountType"] == 1) { //员工 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } else if ((int)System.Web.HttpContext.Current.Session["AccountType"] == 2 && System.Web.HttpContext.Current.Session["OrganizeCity"] != null) { //商业客户 int city = (int)System.Web.HttpContext.Current.Session["OrganizeCity"]; Addr_OrganizeCityBLL citybll = new Addr_OrganizeCityBLL(city); ((MCSTreeControl)control).DataSource = citybll.GetAllChildNodeIncludeSelf(); ((MCSTreeControl)control).RootValue = citybll.Model.SuperID.ToString(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = city.ToString(); } #endregion } else if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") { ((MCSTreeControl)control).TableName = "MCS_SYS.dbo.Addr_OfficialCity"; ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; control.Enabled = _panel_modelfields.Enable.ToUpper() == "Y"; if (_panel_modelfields.ControlWidth > 0) control.Width = _panel_modelfields.ControlWidth; tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_panel_modelfields.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (_panel_modelfields.ControlType == 2 || _panel_modelfields.ControlType == 5) { if (_panel_modelfields.IsRequireField == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_panel_modelfields.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _panel_modelfields.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } else { if (_modelfieldsmodel.DataType == 1 || _modelfieldsmodel.DataType == 2 || _modelfieldsmodel.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_modelfieldsmodel.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_modelfieldsmodel.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_modelfieldsmodel.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } } } #endregion if (!string.IsNullOrEmpty(_panel_modelfields.Description)) { Label lb = new Label(); lb.Text = " " + _panel_modelfields.Description; tc_control.Controls.Add(lb); } tr_panel_detail.Cells.Add(tc_control); #endregion #region 将控件记录到字段控件HashTable中 FieldControlInfo fieldcontrolinfo = new FieldControlInfo(); fieldcontrolinfo.FieldID = _modelfieldsmodel.ID; fieldcontrolinfo.FieldName = _modelfieldsmodel.FieldName; fieldcontrolinfo.ModelName = _tablemodel.ModelClassName; fieldcontrolinfo.ControlType = _panel_modelfields.ControlType; fieldcontrolinfo.ControlName = control.ID; fieldcontrolinfo.DisplayMode = _panel_modelfields.DisplayMode; fieldcontrolinfo.Panel_Field_ID = _panel_modelfields.ID; _htFieldControlsInfo.Add(fieldcontrolinfo.ControlName, fieldcontrolinfo); #endregion } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); } ViewState["FieldControlsInfo"] = _htFieldControlsInfo; }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { Hashtable _htDataObjectdControlsInfo = new Hashtable(); HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow T_tr_title = new HtmlTableRow(); HtmlTableCell T_tc_title = new HtmlTableCell(); T_tr_title.Cells.Add(T_tc_title); T_Content.Rows.Add(T_tr_title); #region The title of the panel HtmlTable tb_title = new HtmlTable(); T_tc_title.Controls.Add(tb_title); tb_title.CellPadding = 0; tb_title.CellSpacing = 0; tb_title.Width = "100%"; tb_title.Height = "30px"; tb_title.Border = 0; tb_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_title = new HtmlTableRow(); HtmlTableCell tc_title = new HtmlTableCell(); tr_title.Cells.Add(tc_title); tb_title.Rows.Add(tr_title); tc_title.InnerHtml = "<h3>工作流提交的数据字段内容</h3>"; #endregion #region The content of the panel HtmlTableRow T_tr_panelcontent = new HtmlTableRow(); T_tr_panelcontent.ID = "T_tr_panelcontent"; HtmlTableCell T_tc_panelcontent = new HtmlTableCell(); T_tr_panelcontent.Cells.Add(T_tc_panelcontent); T_Content.Rows.Add(T_tr_panelcontent); HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = "tabForm"; T_tc_panelcontent.Controls.Add(tb_panel_content); IList <EWF_Flow_DataObject> _dataobjects = new EWF_Flow_AppBLL(App).GetDataObjectList(); int i = 0; foreach (EWF_Flow_DataObject _dataobject in _dataobjects) { if (_dataobject.Visible == "N") { continue; } #region 判断该控件是否已存在 if (_htDataObjectdControlsInfo.Contains(_dataobject.Name)) { continue; } #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = "dataLabel"; tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tc_displayname.InnerText = _dataobject.DisplayName; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = "dataField"; if (_dataobject.ColSpan > 0) { if (i + _dataobject.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _dataobject.ColSpan - 1; i = i + _dataobject.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _dataobject.RelationType; string RelationTableName = _dataobject.RelationTableName; string RelationValueField = _dataobject.RelationValueField; string RelationTextField = _dataobject.RelationTextField; #region 根据控件类型生成相应的控件 switch (_dataobject.ControlType) { case 1: //Label control = new Label(); break; case 2: //TextBox control = new TextBox(); if (_dataobject.DataType == 4) { control.Attributes["onfocus"] = "setday(this);"; } break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_dataobject.ControlHeight > 0) { ((TextBox)control).Height = new Unit(_dataobject.ControlHeight); } break; case 6: //TextBox supports search control = new MCSSelectControl(); control.ID = "C_" + _dataobject.Name.ToString(); if (RelationType == 2) //Relation to the model table { ((MCSSelectControl)control).PageUrl = _dataobject.SearchPageURL; } break; case 7: //MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2) //Relation to the model table { control.ID = "C_" + _dataobject.Name.ToString(); //在设置控件DataSource之前,必须要有ID属性 Shen Gang 20090110 if (_dataobject.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = "C_" + _dataobject.Name.ToString(); control.Enabled = _dataobject.Enable.ToUpper() == "Y"; control.ToolTip = _dataobject.Description; if (_dataobject.ControlWidth > 0) { control.Width = _dataobject.ControlWidth; } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_dataobject.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = "*"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } //add validate control for the textbox if (_dataobject.ControlType == 2 || _dataobject.ControlType == 5) { RequiredFieldValidator _requiredfieldvalidator = null; CompareValidator _comparevalidator = null; RegularExpressionValidator _regularexpressionvalidator = null; if (_dataobject.IsRequireField == "Y") { _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_dataobject.DataType == 1 || _dataobject.DataType == 2 || _dataobject.DataType == 4) //非varchar 字符串 { _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_dataobject.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_dataobject.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_dataobject.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (_dataobject.RegularExpression != "") { _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _dataobject.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion #region Record the info of the control created DataObjectControlInfo dataobjectcontrolinfo = new DataObjectControlInfo(); dataobjectcontrolinfo.ControlName = control.ID; dataobjectcontrolinfo.ControlType = _dataobject.ControlType; dataobjectcontrolinfo.DataObjectID = _dataobject.ID; dataobjectcontrolinfo.DataObjectName = _dataobject.Name; _htDataObjectdControlsInfo.Add(dataobjectcontrolinfo.DataObjectName, dataobjectcontrolinfo); #endregion } #endregion ViewState["HTDataObjectControlInfo"] = _htDataObjectdControlsInfo; if (new EWF_Flow_AppBLL(App).Model.RelateBusiness.ToUpper() == "Y") { SetPanelEnable(false); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { #region 获取页面参数 ViewState["InventoryID"] = Request.QueryString["InventoryID"] == null ? 0 : int.Parse(Request.QueryString["InventoryID"]); ViewState["ClientID"] = Request.QueryString["ClientID"] == null ? 0 : int.Parse(Request.QueryString["ClientID"]); ViewState["IsCXP"] = Request.QueryString["IsCXP"] == null ? false : int.Parse(Request.QueryString["IsCXP"]) != 0; //是否是赠品销量录入 0:成品 1:赠品 #endregion ViewState["EditEnable"] = true; if ((int)ViewState["InventoryID"] != 0) { if (Request.QueryString["Flag"] == null) { cb_OnlyDisplayUnZero.Checked = true; } BindData(); btn_Inventory.Visible = false; TextBox tbx_InventoryDate = UC_DetailView1.FindControl("SVM_Inventory_InventoryDate") != null ? (TextBox)UC_DetailView1.FindControl("SVM_Inventory_InventoryDate") : null; } else { if ((int)ViewState["ClientID"] == 0) { Response.Redirect("InventoryList.aspx"); } #region 新增库存 CM_Client c = new CM_ClientBLL((int)ViewState["ClientID"]).Model; MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("SVM_Inventory_Client"); if (select_Client != null) { select_Client.SelectValue = ViewState["ClientID"].ToString(); select_Client.SelectText = c.FullName; select_Client.Enabled = false; } MCSTreeControl tr_OrganizeCity = (MCSTreeControl)UC_DetailView1.FindControl("SVM_Inventory_OrganizeCity"); if (tr_OrganizeCity != null) { tr_OrganizeCity.SelectValue = c.OrganizeCity.ToString(); tr_OrganizeCity.Enabled = false; } DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_Inventory_AccountMonth"); if (ddl_Month != null) { double JXCDelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["JXCDelayDays"]); ddl_Month.SelectedValue = AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-JXCDelayDays)).ToString(); } #region 判断是否有未审核销售 //if (c.ClientType == 2 && SVM_SalesVolumeBLL.GetModelList("Supplier=" + c.ID.ToString() + " AND ApproveFlag=2 AND AccountMonth=" + ddl_Month.SelectedValue).Count > 0) //{ // MessageBox.ShowAndRedirect(this, "该经销商本月还有未审核销量,请先审核销量再作此操作。", "SalesVolumeList.aspx?Type=2&SellOutClientID=" + c.ID.ToString()); // return; //} #endregion TextBox tbx_InventoryDate = (TextBox)UC_DetailView1.FindControl("SVM_Inventory_InventoryDate"); if (tbx_InventoryDate != null) { tbx_InventoryDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); } bt_Del.Visible = false; bt_Save.Visible = false; bt_Approve.Visible = false; bt_Submit.Visible = false; bt_Approve.Visible = false; bt_Re_Approve.Visible = false; tb_AddProduct.Visible = false; #endregion } BindDropDown(); #region 确定页面权限 if ((int)ViewState["ClientID"] != 0) { CM_Client _r = new CM_ClientBLL((int)ViewState["ClientID"]).Model; ViewState["ClientType"] = _r.ClientType; if (_r.ClientType == 3) { Header.Attributes["WebPageSubCode"] += "ClientType=3"; bt_Submit.Enabled = false; ViewState["EditEnable"] = false; lbl_Notice.Text = "请以最小单位数量填报"; } else if (_r.ClientType == 2) { Header.Attributes["WebPageSubCode"] += "ClientType=2&DIClassify=" + _r["DIClassify"]; } } #endregion } }
protected void Page_Load(object sender, System.EventArgs e) { #region 初始化页面控件 Page.ClientScript.RegisterClientScriptInclude("meizzDate", Page.ResolveClientUrl("~/App_Themes/basic/meizzDate.js")); select_RelateClient = (MCSSelectControl)pl_detail.FindControl("JN_Journal_RelateClient"); if (select_RelateClient != null) select_RelateClient.SelectChange += new SelectChangeEventHandler(select_RelateClient_SelectChange); ddl_RelateLinkMan = (DropDownList)pl_detail.FindControl("JN_Journal_RelateLinkMan"); if (ddl_RelateLinkMan != null) { ddl_RelateLinkMan.DataTextField = "Name"; ddl_RelateLinkMan.DataValueField = "ID"; } rbl_HasSynergeticStaff = (RadioButtonList)pl_detail.FindControl("JN_Journal_HasSynergeticStaff"); if (rbl_HasSynergeticStaff != null) { rbl_HasSynergeticStaff.AutoPostBack = true; rbl_HasSynergeticStaff.SelectedIndexChanged += new EventHandler(rbl_HasSynergeticStaff_SelectedIndexChanged); } ddl_RelateActivity = (DropDownList)pl_detail.FindControl("JN_Journal_RelateActivity"); if (ddl_RelateActivity != null) { ddl_RelateActivity.DataTextField = "Topic"; ddl_RelateActivity.DataValueField = "ID"; ddl_RelateActivity.AutoPostBack = true; ddl_RelateActivity.SelectedIndexChanged += new EventHandler(ddl_RelateActivity_SelectedIndexChanged); } #endregion // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? Int32.Parse(Request.QueryString["ID"]) : 0; #endregion BindDropDown(); if ((int)ViewState["ID"] != 0) { if (rbl_HasSynergeticStaff != null) rbl_HasSynergeticStaff.SelectedValue = "2"; //默认非协同拜访 BindData(); } else { if (Request.QueryString["Day"] != null && Request.QueryString["Day"] != "0") tbx_begindate.Text = DateTime.Today.AddDays(int.Parse(Request.QueryString["Day"]) - DateTime.Today.DayOfYear).ToString("yyyy-MM-dd"); else tbx_begindate.Text = DateTime.Today.ToString("yyyy-MM-dd"); #region 获取日志填报人信息 Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"], true); select_Staff.SelectText = staff.Model.RealName; select_Staff.SelectValue = Session["UserID"].ToString(); Org_PositionBLL position = new Org_PositionBLL(staff.Model.Position); lbl_Position.Text = position.Model.Name; MCSTreeControl tr_OfficialCity = pl_detail.FindControl("JN_Journal_OfficialCity") != null ? (MCSTreeControl)pl_detail.FindControl("JN_Journal_OfficialCity") : null; if (tr_OfficialCity != null) tr_OfficialCity.SelectValue = staff.Model.OfficialCity.ToString(); #endregion #region 获取本机IP TextBox tbx_IPAddress = pl_detail.FindControl("JN_Journal_IPAddress") != null ? (TextBox)pl_detail.FindControl("JN_Journal_IPAddress") : null; if (tbx_IPAddress != null) { tbx_IPAddress.Text = Request.UserHostAddress; TextBox tbx_IPLocation = pl_detail.FindControl("JN_Journal_IPLocation") != null ? (TextBox)pl_detail.FindControl("JN_Journal_IPLocation") : null; userAddress = Const_IPLocationBLL.FindByIP(Request.UserHostAddress); if (tbx_IPLocation != null) tbx_IPLocation.Text = userAddress != null ? userAddress.Location : ""; } #endregion #region 新增日志时,联系人字段不可编辑 if (ddl_RelateLinkMan != null) { ddl_RelateLinkMan.Items.Clear(); ddl_RelateLinkMan.Enabled = false; } #endregion pl_detail.SetPanelVisible("Panel_OA_JournalDetail_02", false); pl_detail.SetPanelVisible("Panel_OA_JournalDetail_03", false); pl_detail.SetPanelVisible("Panel_OA_JournalDetail_04", false); #region 默认无领导协同拜访 if (rbl_HasSynergeticStaff != null) { rbl_HasSynergeticStaff.SelectedValue = "2"; //默认非协同拜访 rbl_HasSynergeticStaff_SelectedIndexChanged(null, null); } #endregion bt_AddNewClient.Visible = false; bt_Delete.Visible = false; tbl_comment.Visible = false; UploadFile1.Visible = false; bt_ToEvectionRoute.Visible = false; } } #region 注册脚本 string script = "function OpenClientInput(Journalid,OfferMan,Activityid){\r\n"; script += "window.open('../../CSO/CSO_SampleOfferDetail.aspx?JournalID='+Journalid+'&OfferMan='+OfferMan+'&ActivityID='+Activityid);}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OpenClientInput", script, true); #endregion }
private void BindData() { CM_ClientBLL _bll = new CM_ClientBLL((int)ViewState["ClientID"]); CM_Client m = _bll.Model; switch (m.ClientType) { case 1: Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString()); break; case 2: Response.Redirect("../DI/DistributorDetail.aspx?ClientID=" + m.ID.ToString()); break; case 3: break; default: MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery); break; } pl_detail.BindData(m); //lbl_preSales.Text = _bll.GetSalesVolume(AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString(); //lbl_AvageSales.Text = _bll.GetSalesVolumeAvg().ToString(); MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager"); if (select_ClientManager != null) { select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + m.OrganizeCity + "&IncludeSuperManager=Y"; } MCSSelectControl select_Supplier = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier"); if (select_Supplier != null) { select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\""; } MCSSelectControl select_Supplier2 = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier2"); if (select_Supplier2 != null) { select_Supplier2.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\""; } if (m.ApproveFlag == 1) { //已审核 TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime"); if (m.ActiveFlag == 1) { if (tbx_OpenTime != null && tbx_OpenTime.Text != "") { tbx_OpenTime.Enabled = false; } bt_AddApply.Visible = false; } else { TextBox tbx_CloseTime = (TextBox)pl_detail.FindControl("CM_Client_CloseTime"); if (tbx_CloseTime != null && tbx_CloseTime.Text != "") { tbx_CloseTime.Enabled = false; } bt_RevocationApply.Visible = false; } Header.Attributes["WebPageSubCode"] = "Modify"; bt_Approve.Visible = false; } else { bt_RevocationApply.Visible = false; } if (string.IsNullOrEmpty(m["TaskID"])) { bt_Record.Visible = false; } else { if (m["State"] == "2") { //审批中,不可修改数据 bt_AddApply.Visible = false; bt_RevocationApply.Visible = false; bt_OK.Visible = false; bt_RevocationApply.Visible = false; } } #region 绑定该客户的首要联系人 DropDownList ddl_ChiefLinkMan = pl_detail.FindControl("CM_Client_ChiefLinkMan") != null ? (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan") : null; try { ddl_ChiefLinkMan.DataTextField = "Name"; ddl_ChiefLinkMan.DataValueField = "ID"; ddl_ChiefLinkMan.DataSource = CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString()); ddl_ChiefLinkMan.DataBind(); ddl_ChiefLinkMan.Items.Insert(0, new ListItem("请选择", "0")); ddl_ChiefLinkMan.SelectedValue = m.ChiefLinkMan.ToString(); } catch { } #endregion BindGrid(); //MessageBox.Show(this, Session["UserID"].ToString()); bt_ReplaceClientManager.OnClientClick = "javascript:PopReplaceClientManager(" + m.ClientManager.ToString() + "," + m.ClientType.ToString() + ")"; //管理员登录状况下 雅慧电商的流通店 数据有误发出警报 if (Session["UserID"].ToString() == "1" && m["RTChannel"] != "20" && m["RTClassify"] == "1" && (m["IsRMSClient"] != "2" || m["RMSAccountEnabled"] != "2")) { MessageBox.Show(this, "非雅慧电商的流通店积分店状态(" + m["IsRMSClient"] + ")或积分账户启用否(" + m["RMSAccountEnabled"] + ")数据有误"); } }
private void BindData() { CM_ClientBLL clientbll = new CM_ClientBLL((int)ViewState["ClientID"]); CM_Client m = clientbll.Model; if (m == null) { Response.Redirect("RetailerList.aspx"); } switch (m.ClientType) { case 1: Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString()); break; case 2: Response.Redirect("../DI/DistributorDetail.aspx?ClientID=" + m.ID.ToString()); break; case 3: break; default: MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery); break; } CM_ClientSupplierInfo supplierinfo = clientbll.GetSupplierInfoByManufacturer((int)Session["Manufacturer"]); CM_ClientManufactInfo manufactinfo = clientbll.GetManufactInfo((int)Session["Manufacturer"]); pl_detail.BindData(m); if (supplierinfo != null) { pl_detail.BindData(supplierinfo); } if (manufactinfo != null) { BindGeoCode(m.OfficialCity); BindVisitRoute(manufactinfo.OrganizeCity); pl_detail.BindData(manufactinfo); } MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_ClientManufactInfo_ClientManager"); if (select_ClientManager != null) { select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + manufactinfo.OrganizeCity.ToString() + "&IncludeSuperManager=Y"; } if (manufactinfo != null) { if (manufactinfo.SyncState != 0 && manufactinfo.SyncState != 1 && manufactinfo.SyncState != 8) { bt_Submit.Visible = false; } if (manufactinfo.SyncState != 2) { bt_Approve.Visible = false; bt_UnApprove.Visible = false; } //有公司客户编号后,页面为编辑权限模式 if (!string.IsNullOrEmpty(manufactinfo.Code)) { Header.Attributes["WebPageSubCode"] = "Modify"; } } bt_Map.OnClientClick = "javascript:Pop_MapShow(" + m.ID.ToString() + ")"; }
protected void Page_Load(object sender, System.EventArgs e) { #region 获取举办医院控件 MCSSelectControl select_StageClient = (MCSSelectControl)pl_detail.FindControl("CAT_Activity_StageClient"); if (select_StageClient != null) { select_StageClient.SelectChange += new SelectChangeEventHandler(select_StageClient_SelectChange); } DropDownList ddl_classify = pl_detail.FindControl("CAT_Activity_Classify") != null ? (DropDownList)pl_detail.FindControl("CAT_Activity_Classify") : null; if (ddl_classify != null) { } #endregion // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null?int.Parse(Request.QueryString["ID"]) : 0; ViewState["Classify"] = Request.QueryString["Classify"] != null?int.Parse(Request.QueryString["Classify"]) : 0; #endregion BindDropDown(); ViewState["FeeListDetails"] = CAT_FeeApplyDetailBLL.GetModelList("Activity=" + ViewState["ID"].ToString()); ViewState["GiftListDetails"] = CAT_GiftApplyDetailBLL.GetModelList("Activity=" + ViewState["ID"].ToString()); ViewState["SalesListDetails"] = CAT_SalesVolumeDetailBLL.GetModelList("Activity=" + ViewState["ID"].ToString()); ViewState["EditAdjust"] = false; if ((int)ViewState["ID"] != 0) { //修改 BindData(); BindGrid(); } else { //新增 Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"], true); ((MCSTreeControl)pl_detail.FindControl("CAT_Activity_Officialcity")).SelectValue = staff.Model.OfficialCity.ToString(); ((MCSTreeControl)pl_detail.FindControl("CAT_Activity_OrganizeCity")).SelectValue = staff.Model.OrganizeCity.ToString(); string state = Request.QueryString["State"] != null ? Request.QueryString["State"] : "11"; //默认为排期中的活动 ((DropDownList)pl_detail.FindControl("CAT_Activity_State")).SelectedValue = state; bt_Stage.Visible = false; bt_Submit.Visible = false; bt_Approve.Visible = false; bt_Complete.Visible = false; bt_Cancel.Visible = false; UploadFile001.Visible = false; gv_FeeListDetail.Columns[gv_FeeListDetail.Columns.Count - 2].Visible = false; //调整按钮 gv_FeeListDetail.Columns[gv_FeeListDetail.Columns.Count - 3].Visible = false; //批复金额 gv_FeeListDetail.Columns[gv_FeeListDetail.Columns.Count - 4].Visible = false; //扣减额原因 gv_FeeListDetail.Columns[gv_FeeListDetail.Columns.Count - 5].Visible = false; //扣减额 gv_GiftListDetail.Columns[2].Visible = false; //调整数量 gv_GiftListDetail.Columns[3].Visible = false; //使用数量 gv_GiftListDetail.Columns[4].Visible = false; //剩余数量 pl_detail.SetPanelVisible("Panel_CAT_ActivityDetail_02", false); } } if (ViewState["ApproveFlag"] == null || (int)ViewState["ApproveFlag"] != 1) { MCSTabControl1.Items[2].Visible = false; } }
private void BindData() { int clientID = 0; if (ViewState["ClientID"] == null || !int.TryParse(ViewState["ClientID"].ToString(), out clientID)) { return; } CM_ClientBLL clientbll = new CM_ClientBLL(clientID); CM_Client m = clientbll.Model; if (m == null) { Response.Redirect("DistributorList.aspx"); } switch (m.ClientType) { case 1: Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString()); break; case 2: break; case 3: Response.Redirect("../RT/RetailerDetail.aspx?ClientID=" + m.ID.ToString()); break; default: MessageBox.ShowAndRedirect(this, "请先在‘经销商列表’中选择要查看的经销商!", "DistributorList.aspx?URL=" + Request.Url.PathAndQuery); break; } pl_detail.BindData(m); tr_OfficialCity_Selected(null, null); tr_OrganizeCity_Selected(null, null); CM_ClientSupplierInfo supplierinfo = clientbll.GetSupplierInfoByManufacturer((int)Session["Manufacturer"]); CM_ClientManufactInfo manufactinfo = clientbll.GetManufactInfo((int)Session["Manufacturer"]); if (supplierinfo != null) { pl_detail.BindData(supplierinfo); } if (manufactinfo != null) { pl_detail.BindData(manufactinfo); } MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_ClientManufactInfo_ClientManager"); if (select_ClientManager != null && manufactinfo != null) { select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + manufactinfo.OrganizeCity.ToString() + "&IncludeSuperManager=Y"; } if (manufactinfo != null && manufactinfo.ApproveFlag == 1) { //已审核 TextBox tbx_BeginDate = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_BeginDate"); if (tbx_BeginDate != null && tbx_BeginDate.Text != "") { tbx_BeginDate.Enabled = false; } TextBox tbx_Code = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_Code"); if (tbx_Code != null) { tbx_Code.Enabled = false; } bt_Approve.Visible = false; Header.Attributes["WebPageSubCode"] = "Modify"; } }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { Hashtable _htDataObjectdControlsInfo = new Hashtable(); HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow T_tr_title = new HtmlTableRow(); HtmlTableCell T_tc_title = new HtmlTableCell(); T_tr_title.Cells.Add(T_tc_title); T_Content.Rows.Add(T_tr_title); #region The title of the panel HtmlTable tb_title = new HtmlTable(); T_tc_title.Controls.Add(tb_title); tb_title.CellPadding = 0; tb_title.CellSpacing = 0; tb_title.Width = "100%"; tb_title.Height = "30px"; tb_title.Border = 0; tb_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_title = new HtmlTableRow(); HtmlTableCell tc_title = new HtmlTableCell(); tr_title.Cells.Add(tc_title); tb_title.Rows.Add(tr_title); tc_title.InnerHtml = "<h3>工作流提交的数据字段内容</h3>"; #endregion #region The content of the panel HtmlTableRow T_tr_panelcontent = new HtmlTableRow(); T_tr_panelcontent.ID = "T_tr_panelcontent"; HtmlTableCell T_tc_panelcontent = new HtmlTableCell(); T_tr_panelcontent.Cells.Add(T_tc_panelcontent); T_Content.Rows.Add(T_tr_panelcontent); HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = "tabForm"; T_tc_panelcontent.Controls.Add(tb_panel_content); IList<EWF_Flow_DataObject> _dataobjects = new EWF_Flow_AppBLL(App).GetDataObjectList(); int i = 0; foreach (EWF_Flow_DataObject _dataobject in _dataobjects) { if (_dataobject.Visible == "N") continue; #region 判断该控件是否已存在 if (_htDataObjectdControlsInfo.Contains(_dataobject.Name)) continue; #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = "dataLabel"; tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tc_displayname.InnerText = _dataobject.DisplayName; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = "dataField"; if (_dataobject.ColSpan > 0) { if (i + _dataobject.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _dataobject.ColSpan - 1; i = i + _dataobject.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _dataobject.RelationType; string RelationTableName = _dataobject.RelationTableName; string RelationValueField = _dataobject.RelationValueField; string RelationTextField = _dataobject.RelationTextField; #region 根据控件类型生成相应的控件 switch (_dataobject.ControlType) { case 1://Label control = new Label(); break; case 2://TextBox control = new TextBox(); if (_dataobject.DataType == 4) { control.Attributes["onfocus"] = "setday(this);"; } break; case 3://DropDownList control = new DropDownList(); if (RelationType == 1)//Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); break; case 4://RadioButtonList control = new RadioButtonList(); if (RelationType == 1)//Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) ((RadioButtonList)control).SelectedIndex = 0; break; case 5://MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_dataobject.ControlHeight > 0) ((TextBox)control).Height = new Unit(_dataobject.ControlHeight); break; case 6://TextBox supports search control = new MCSSelectControl(); control.ID = "C_" + _dataobject.Name.ToString(); if (RelationType == 2)//Relation to the model table { ((MCSSelectControl)control).PageUrl = _dataobject.SearchPageURL; } break; case 7://MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2)//Relation to the model table { control.ID = "C_" + _dataobject.Name.ToString(); //在设置控件DataSource之前,必须要有ID属性 Shen Gang 20090110 if (_dataobject.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = "C_" + _dataobject.Name.ToString(); control.Enabled = _dataobject.Enable.ToUpper() == "Y"; control.ToolTip = _dataobject.Description; if (_dataobject.ControlWidth > 0) control.Width = _dataobject.ControlWidth; tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_dataobject.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = "*"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } //add validate control for the textbox if (_dataobject.ControlType == 2 || _dataobject.ControlType == 5) { RequiredFieldValidator _requiredfieldvalidator = null; CompareValidator _comparevalidator = null; RegularExpressionValidator _regularexpressionvalidator = null; if (_dataobject.IsRequireField == "Y") { _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_dataobject.DataType == 1 || _dataobject.DataType == 2 || _dataobject.DataType == 4) //非varchar 字符串 { _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_dataobject.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_dataobject.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_dataobject.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (_dataobject.RegularExpression != "") { _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _dataobject.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion #region Record the info of the control created DataObjectControlInfo dataobjectcontrolinfo = new DataObjectControlInfo(); dataobjectcontrolinfo.ControlName = control.ID; dataobjectcontrolinfo.ControlType = _dataobject.ControlType; dataobjectcontrolinfo.DataObjectID = _dataobject.ID; dataobjectcontrolinfo.DataObjectName = _dataobject.Name; _htDataObjectdControlsInfo.Add(dataobjectcontrolinfo.DataObjectName, dataobjectcontrolinfo); #endregion } #endregion ViewState["HTDataObjectControlInfo"] = _htDataObjectdControlsInfo; if (new EWF_Flow_AppBLL(App).Model.RelateBusiness.ToUpper() == "Y") SetPanelEnable(false); }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { if (DataSet == Guid.Empty) { return; } IList <Rpt_DataSetParams> paramfields = new Rpt_DataSetBLL(DataSet, true).GetParams(); if (paramfields.Count == 0) { return; //无参数 } HtmlTable T_Content = new HtmlTable(); string[] tablestyles = new string[] { "tabForm", "dataLabel", "dataField" }; T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = "DataSetParamPanel"; HtmlTableCell tc_panel = new HtmlTableCell(); #region The title of the panel HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>请设置统计报表参数信息</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); #endregion #region The content of the panel int FieldCount = 3; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = tablestyles[0]; int i = 0; foreach (Rpt_DataSetParams param in paramfields) { string ControlID = "Param_" + param.ParamName.Replace("@", ""); //判断该控件是否已存在 if (ParamControlsInfo.ContainsKey(ControlID)) { continue; } ParamControlsInfo.Add(ControlID, param); if (param.Visible == "Y") { #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = tablestyles[1]; tc_displayname.InnerText = param.DisplayName; if (tc_displayname.InnerText.Length <= 6) { tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; } else { tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; } tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = tablestyles[2]; i++; WebControl control = null; int RelationType = param.RelationType; string RelationTableName = param.RelationTableName; string RelationValueField = param.RelationValueField; string RelationTextField = param.RelationTextField; #region 根据控件类型生成相应的控件 switch (param.ControlType) { case 1: //Label control = new Label(); ((Label)control).Text = GetDefaule(param.DefaultValue); break; case 2: //TextBox control = new TextBox(); if (param.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (param.DataType != 5) { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); } else { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } if (param.DefaultValue != "") { if (((DropDownList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((DropDownList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } if (param.DefaultValue != "") { if (((RadioButtonList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((RadioButtonList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 6: //TextBox supports search control = new MCSSelectControl(); control.ID = ControlID; if (param.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = param.SearchPageURL; } if (param.DefaultValue != "") { control.Init += new EventHandler(control_Init); } break; case 7: //MCSTreeControl control = new MCSTreeControl(); control.ID = ControlID; if (param.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } if (param.DefaultValue != "") { if (((MCSTreeControl)control).SelectValue == "0" || ((MCSTreeControl)control).SelectValue == "") { ((MCSTreeControl)control).SelectValue = GetDefaule(param.DefaultValue); } } break; } #endregion control.ID = ControlID; control.Enabled = param["Enable"] != "N"; int controlwidth = 0; if (int.TryParse(param["ControlWidth"], out controlwidth)) { control.Width = new Unit(controlwidth); } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (param["IsRequireField"] == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (param.ControlType == 2 || param.ControlType == 5) { if (param["IsRequireField"] == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(_requiredfieldvalidator); } if (param.DataType == 1 || param.DataType == 2 || param.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; if (param.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (param.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (param.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (param.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = param.RegularExpression; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion } } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); }
protected void Page_Load(object sender, System.EventArgs e) { select_RelateClient = (MCSSelectControl)pl_detail.FindControl("JN_Journal_RelateClient"); select_RelateClient.SelectChange += new SelectChangeEventHandler(select_RelateClient_SelectChange); // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 if (Request.QueryString["ID"] != null) ViewState["ID"] = Int32.Parse(Request.QueryString["ID"]); #endregion BindDropDown(); if (ViewState["ID"] != null) { BindData(); } else { ((TextBox)pl_detail.FindControl("JN_Journal_BeginTime")).Text = DateTime.Today.ToString("yyyy-MM-dd"); //Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"], true); //tr_OfficialCity.SelectValue = staff.Model.OfficialCity.ToString(); //tbx_IPAddress.Text = Request.UserHostAddress; bt_Delete.Visible = false; tr_comment.Visible = false; tr_uploadfile.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { #region 获取页面参数 ViewState["TargetID"] = Request.QueryString["TargetID"] == null ? 0 : int.Parse(Request.QueryString["TargetID"]); ViewState["ClientID"] = Request.QueryString["ClientID"] == null ? 0 : int.Parse(Request.QueryString["ClientID"]); #endregion BindDropDown(); if ((int)ViewState["TargetID"] != 0) { BindData(); btn_SalesTarget.Visible = false; } else { if ((int)ViewState["ClientID"] == 0) { Response.Redirect("SalesTarget.aspx"); } #region 新增销量目标 CM_Client c = new CM_ClientBLL((int)ViewState["ClientID"]).Model; MCSSelectControl select_Client = (MCSSelectControl)UC_DetailView1.FindControl("SVM_SalesTarget_Client"); if (select_Client != null) { select_Client.SelectValue = ViewState["ClientID"].ToString(); select_Client.SelectText = c.FullName; select_Client.Enabled = false; } MCSTreeControl tr_OrganizeCity = (MCSTreeControl)UC_DetailView1.FindControl("SVM_SalesTarget_OrganizeCity"); if (tr_OrganizeCity != null) { tr_OrganizeCity.SelectValue = c.OrganizeCity.ToString(); tr_OrganizeCity.Enabled = false; } DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_SalesTarget_AccountMonth"); if (ddl_Month != null) { ddl_Month.SelectedValue = AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-7).AddMonths(1)).ToString(); } bt_Del.Visible = false; bt_Save.Visible = false; bt_Approve.Visible = false; #endregion } #region 确定页面权限 if ((int)ViewState["ClientID"] != 0) { CM_Client _r = new CM_ClientBLL((int)ViewState["ClientID"]).Model; ViewState["ClientType"] = _r.ClientType; if (_r.ClientType == 3) { Header.Attributes["WebPageSubCode"] += "ClientType=3"; } else if (_r.ClientType == 2) { Header.Attributes["WebPageSubCode"] += "ClientType=2&DIClassify=" + _r["DIClassify"]; } } #endregion } }
private void BindData() { CM_Client m = new CM_ClientBLL((int)ViewState["ClientID"]).Model; switch (m.ClientType) { case 1: Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString()); break; case 2: break; case 3: Response.Redirect("../RT/RetailerDetail.aspx?ClientID=" + m.ID.ToString()); break; default: MessageBox.ShowAndRedirect(this, "请先在‘经销商列表’中选择要查看的经销商!", "DistributorList.aspx?URL=" + Request.Url.PathAndQuery); break; } pl_detail.BindData(m); MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager"); select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + m.OrganizeCity; if (m.ApproveFlag == 1) { //已审核 TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime"); if (tbx_OpenTime != null && tbx_OpenTime.Text != "") { tbx_OpenTime.Enabled = false; } if (m.ActiveFlag == 1) { bt_AddApply.Visible = false; bt_DIUP.Visible = false; } else { TextBox tbx_CloseTime = (TextBox)pl_detail.FindControl("CM_Client_CloseTime"); if (tbx_CloseTime != null && tbx_CloseTime.Text != "") { tbx_CloseTime.Enabled = false; } bt_RevocationApply.Visible = false; } bt_Approve.Visible = false; } if (m.ActiveFlag == 1) { Header.Attributes["WebPageSubCode"] = "Modify"; bt_AddApply.Visible = false; bt_Approve.Visible = false; } else { bt_RevocationApply.Visible = false; } if (string.IsNullOrEmpty(m["TaskID"])) { bt_Record.Visible = false; } else { if (m["State"] == "2") { //审批中,不可修改数据 bt_AddApply.Visible = false; bt_RevocationApply.Visible = false; bt_OK.Visible = false; bt_RevocationApply.Visible = false; bt_DIACUpgrade.Visible = false; bt_DIUP.Visible = false; } } #region 绑定该客户的首要联系人 DropDownList ddl_ChiefLinkMan = (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan"); try { ddl_ChiefLinkMan.DataTextField = "Name"; ddl_ChiefLinkMan.DataValueField = "ID"; ddl_ChiefLinkMan.DataSource = CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString()); ddl_ChiefLinkMan.DataBind(); } catch { } ddl_ChiefLinkMan.Items.Insert(0, new ListItem("请选择", "0")); ddl_ChiefLinkMan.SelectedValue = m.ChiefLinkMan.ToString(); #endregion BindGrid(); bt_Add.Enabled = true; if (m.ClientType != 2 || m["DIClassify"] != "3") { bt_DIACUpgrade.Visible = false; } if (m.ClientType != 2 || m["DIClassify"] == "2") { bt_DIUP.Visible = false; } bt_ReplaceSupplier.OnClientClick = "javascript:PopReplaceSupplier(" + m.ID.ToString() + ")"; bt_ReplaceSupplier2.OnClientClick = "javascript:PopReplaceSupplier2(" + m.ID.ToString() + ")"; bt_ReplaceClientManager.OnClientClick = "javascript:PopReplaceClientManager(" + m.ClientManager.ToString() + "," + m.ClientType.ToString() + ")"; }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { #region 获取页面参数 if (Request.QueryString["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]); Session["ClientID"] = ViewState["ClientID"]; } else if (Session["ClientID"] != null) { ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString()); } #endregion if (ViewState["ClientID"] != null) { BindData(); } else if (Request.QueryString["Mode"] == "New") { #region 新增客户时的初始值 Org_Staff staff = new Org_StaffBLL((int)Session["UserID"]).Model; if (staff == null) { Response.Redirect("~/SubModule/Desktop.aspx"); } #region 新增客户时,详细资料界面控件初始化 DropDownList ddl_ActiveFlag = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag"); if (ddl_ActiveFlag != null) { ddl_ActiveFlag.SelectedValue = "4"; } TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime"); if (tbx_OpenTime != null) { tbx_OpenTime.Text = DateTime.Today.ToString("yyyy-MM-dd"); } MCSTreeControl tr_OrganizeCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OrganizeCity"); if (tr_OrganizeCity != null) { tr_OrganizeCity.SelectValue = staff.OrganizeCity.ToString(); } MCSTreeControl tr_OfficalCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OfficalCity"); if (tr_OfficalCity != null) { tr_OfficalCity.SelectValue = staff.OfficialCity.ToString(); } MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager"); if (select_ClientManager != null) { select_ClientManager.SelectText = staff.RealName; select_ClientManager.SelectValue = staff.ID.ToString(); } DropDownList ddl_ChiefLinkMan = (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan"); if (ddl_ChiefLinkMan != null) { ddl_ChiefLinkMan.Items.Clear(); ddl_ChiefLinkMan.Enabled = false; } DropDownList ddl_DIClassify = pl_detail.FindControl("CM_Client_DIClassify") == null ? null : (DropDownList)pl_detail.FindControl("CM_Client_DIClassify"); if (ddl_DIClassify != null) { ddl_DIClassify.SelectedValue = "2"; ddl_DIClassify.Enabled = false; } #endregion bt_Add.Enabled = false; bt_Approve.Visible = false; tbl_LinkMan.Visible = false; bt_Analysis.Visible = false; bt_AddApply.Visible = false; bt_RevocationApply.Visible = false; bt_Record.Visible = false; bt_ReplaceClientManager.Visible = false; bt_ReplaceSupplier.Visible = false; bt_DIACUpgrade.Visible = false; bt_ViewSubClient.Visible = false; bt_DIUP.Visible = false; #endregion } else { MessageBox.ShowAndRedirect(this, "请先在‘经销商列表’中选择要查看的经销商!", "DistributorList.aspx?URL=" + Request.Url.PathAndQuery); } } #region 给活跃标志加事件 DropDownList ddl_ActiveFlag_1 = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag"); ddl_ActiveFlag_1.AutoPostBack = true; ddl_ActiveFlag_1.SelectedIndexChanged += new EventHandler(ddl_ActiveFlag_SelectedIndexChanged); #endregion #region 择经销商级别 一级则弹出仓库,二级则弹出经销商,并指定所属片区 MCSSelectControl select_Supplier = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier"); //select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ExtCondition=ClientType in (1,2)"; MCSTreeControl select_OrganizeCity = (MCSTreeControl)pl_detail.FindControl("CM_Client_OrganizeCity"); DropDownList select_DIClassify = (DropDownList)pl_detail.FindControl("CM_Client_DIClassify"); select_DIClassify.AutoPostBack = true; int type = 0; type = select_DIClassify.SelectedIndex; switch (select_DIClassify.SelectedValue) { case "1": select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=1&OrganizeCity=" + select_OrganizeCity.SelectValue; //只可以选择仓库 break; case "2": case "3": select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7)=1\"&OrganizeCity=" + select_OrganizeCity.SelectValue; break; default: select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType in (1,2)&OrganizeCity=" + select_OrganizeCity.SelectValue; //可以选择仓库及经销商 break; } #endregion #region 给判断重复编码加事件 TextBox tbx_Code = (TextBox)pl_detail.FindControl("CM_Client_Code"); tbx_Code.AutoPostBack = true; tbx_Code.TextChanged += new EventHandler(tbx_Code_TextChanged); #endregion #region 给账号/开户行文本框添加事件 TextBox tbx_BankName = (TextBox)pl_detail.FindControl("CM_Client_BankName"); tbx_BankName.AutoPostBack = true; tbx_BankName.TextChanged += new EventHandler(tbx_Bank_TextChanged); TextBox tbx_BankAccountNo = (TextBox)pl_detail.FindControl("CM_Client_BankAccountNo"); tbx_BankAccountNo.AutoPostBack = true; tbx_BankAccountNo.TextChanged += new EventHandler(tbx_Bank_TextChanged); #endregion #region 注册弹出窗口脚本 string script = "function PopReplaceSupplier(id){\r\n"; script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../ReplaceSupplier.aspx") + "?Supplier=' + id + '&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=260px;status:yes;resizable=yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopReplaceSupplier", script, true); script = "function PopReplaceSupplier2(id){\r\n"; script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../ReplaceSupplier.aspx") + "?Supplier2=' + id + '&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=260px;status:yes;resizable=yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopReplaceSupplier2", script, true); script = "function PopReplaceClientManager(id,clienttype){\r\n"; script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../ReplaceClientManager.aspx") + "?ClientManager=' + id + '&ClientType='+clienttype+'&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=260px;status:yes;resizable=yes');}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopReplaceClientManager", script, true); #endregion }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); UD_DetailViewBLL _DetailViewBll = new UD_DetailViewBLL(DetailViewCode, true); IList <UD_Panel> _panellist = _DetailViewBll.GetDetailPanels(); Hashtable _htFieldControlsInfo = new Hashtable(); foreach (UD_Panel _panelmodel in _panellist) { HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = _panelmodel.Code; if (_panelmodel.Enable.ToUpper() == "N") { tr_panel.Visible = false; } HtmlTableCell tc_panel = new HtmlTableCell(); string _tablestytle = _panelmodel.TableStyle; string[] _tablestyles = _panelmodel.TableStyle.Split(new char[] { ',' }); if (_tablestyles.Length < 3) { _tablestyles = ("tabForm,dataLabel,dataField").Split(new char[] { ',' }); } #region The title of the panel if (_panelmodel.Name != "") { HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>" + _panelmodel.Name + "</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); } #endregion #region The content of the panel IList <UD_Panel_ModelFields> fields = new UD_PanelBLL(_panelmodel.ID, true).GetModelFields(); int FieldCount = _panelmodel.FieldCount; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = _tablestyles[0]; int i = 0; foreach (UD_Panel_ModelFields _panel_modelfields in fields) { if (_panel_modelfields.Visible == "N") { continue; } UD_ModelFields _modelfieldsmodel = new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model; UD_TableList _tablemodel = new UD_TableListBLL(_modelfieldsmodel.TableID, true).Model; #region 判断该控件是否已存在 if (_htFieldControlsInfo.Contains(_tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName)) { continue; } #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = _tablestyles[1]; tc_displayname.InnerText = string.IsNullOrEmpty(_panel_modelfields.LabelText) ? _modelfieldsmodel.DisplayName : _panel_modelfields.LabelText; if (tc_displayname.InnerText.Length <= 6) { tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; } else { tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; } tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = _tablestyles[2]; if (_panel_modelfields.ColSpan > 0) { if (i + _panel_modelfields.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _panel_modelfields.ColSpan - 1; i = i + _panel_modelfields.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _modelfieldsmodel.RelationType; string RelationTableName = _modelfieldsmodel.RelationTableName; string RelationValueField = _modelfieldsmodel.RelationValueField; string RelationTextField = _modelfieldsmodel.RelationTextField; #region 根据控件类型生成相应的控件 switch (_panel_modelfields.ControlType) { case 1: //Label control = new Label(); break; case 2: //TextBox control = new TextBox(); if (_modelfieldsmodel.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (_modelfieldsmodel.DataType != 5) { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); } else { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_panel_modelfields.ControlHeight > 0) { ((TextBox)control).Height = new Unit(_panel_modelfields.ControlHeight); } break; case 6: //TextBox supports search control = new MCSSelectControl(); if (RelationType == 2) //Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_panel_modelfields.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = _panel_modelfields.SearchPageURL; } else if (_modelfieldsmodel.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = _modelfieldsmodel.SearchPageURL; } } break; case 7: //MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2) //Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取所能管辖的片区 if (System.Web.HttpContext.Current.Session["AccountType"] == null || (int)System.Web.HttpContext.Current.Session["AccountType"] == 1) { //员工 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } } else if ((int)System.Web.HttpContext.Current.Session["AccountType"] == 2 && System.Web.HttpContext.Current.Session["OrganizeCity"] != null) { //商业客户 int city = (int)System.Web.HttpContext.Current.Session["OrganizeCity"]; Addr_OrganizeCityBLL citybll = new Addr_OrganizeCityBLL(city); ((MCSTreeControl)control).DataSource = citybll.GetAllChildNodeIncludeSelf(); ((MCSTreeControl)control).RootValue = citybll.Model.SuperID.ToString(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = city.ToString(); } } #endregion } else if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") { ((MCSTreeControl)control).TableName = "MCS_SYS.dbo.Addr_OfficialCity"; ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; control.Enabled = _panel_modelfields.Enable.ToUpper() == "Y"; if (_panel_modelfields.ControlWidth > 0) { control.Width = _panel_modelfields.ControlWidth; } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_panel_modelfields.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (_panel_modelfields.ControlType == 2 || _panel_modelfields.ControlType == 5) { if (_panel_modelfields.IsRequireField == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_panel_modelfields.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _panel_modelfields.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } else { if (_modelfieldsmodel.DataType == 1 || _modelfieldsmodel.DataType == 2 || _modelfieldsmodel.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_modelfieldsmodel.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_modelfieldsmodel.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_modelfieldsmodel.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } } } #endregion if (!string.IsNullOrEmpty(_panel_modelfields.Description)) { Label lb = new Label(); lb.Text = " " + _panel_modelfields.Description; tc_control.Controls.Add(lb); } tr_panel_detail.Cells.Add(tc_control); #endregion #region 将控件记录到字段控件HashTable中 FieldControlInfo fieldcontrolinfo = new FieldControlInfo(); fieldcontrolinfo.FieldID = _modelfieldsmodel.ID; fieldcontrolinfo.FieldName = _modelfieldsmodel.FieldName; fieldcontrolinfo.ModelName = _tablemodel.ModelClassName; fieldcontrolinfo.ControlType = _panel_modelfields.ControlType; fieldcontrolinfo.ControlName = control.ID; fieldcontrolinfo.DisplayMode = _panel_modelfields.DisplayMode; fieldcontrolinfo.Panel_Field_ID = _panel_modelfields.ID; _htFieldControlsInfo.Add(fieldcontrolinfo.ControlName, fieldcontrolinfo); #endregion } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); } ViewState["FieldControlsInfo"] = _htFieldControlsInfo; }