Esempio n. 1
0
    /// <summary>
    /// 显示字段文本数据
    /// </summary>
    /// <param name="type"></param>
    /// <param name="obj"></param>
    /// <returns></returns>
    public string ShowFiled(int type, object obj)
    {
        string result = "";

        if (type == 0)
        {
            //乘客类型
            if (obj != null && obj != DBNull.Value && obj.ToString() != "")
            {
                if (obj.ToString() == "1")
                {
                    result = "成人";
                }
                else if (obj.ToString() == "2")
                {
                    result = "儿童";
                }
                else if (obj.ToString() == "3")
                {
                    result = "婴儿";
                }
            }
        }
        else if (type == 1)
        {
            //证件类型
            if (obj != null && obj != DBNull.Value && obj.ToString() != "")
            {
                if (CardTypeList == null)
                {
                    string sqlWhere = " parentid=7 order by ChildID";
                    CardTypeList = this.baseDataManage.CallMethod("Bd_Base_Dictionary", "GetList", null, new object[] { sqlWhere }) as List <Bd_Base_Dictionary>;
                }
                if (CardTypeList != null)
                {
                    Bd_Base_Dictionary dic = CardTypeList.Find(delegate(Bd_Base_Dictionary _dic)
                    {
                        return(_dic.ChildID.ToString().Trim() == obj.ToString().Trim());
                    });
                    if (dic != null)
                    {
                        result = dic.ChildName;
                    }
                }
            }
        }
        else if (type == 2)
        {
            //卡号
            if (obj != null && obj != DBNull.Value && obj.ToString() != "")
            {
                result = obj.ToString().Replace("|", "<br />");
            }
        }
        return(result);
    }
    /// <summary>
    /// 添加父级
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddParentName_Click(object sender, EventArgs e)
    {
        string msg = "";

        try
        {
            #region 添加父级

            Bd_Base_Dictionary model = new Bd_Base_Dictionary();
            int parentID             = new Bd_Base_DictionaryBLL().GetBaseDictionaryMaxParentID();//获取父级最大id
            parentID++;

            //model.id = Guid.NewGuid();
            model.ParentID         = parentID;
            model.ParentName       = txtParentName.Text.Trim();
            model.ChildID          = 1;
            model.ChildName        = "";
            model.ChildDescription = "";
            model.Remark           = "";

            bool result = (bool)baseDataManage.CallMethod("Bd_Base_Dictionary", "Insert", null, new Object[] { model });

            if (result)
            {
                msg = "添加成功!";

                DataBlsList();
            }
            else
            {
                msg = "添加失败!";
            }

            #endregion
        }
        catch (Exception)
        {
            msg = "操作失败!";
        }
        finally
        {
            ScriptManager.RegisterStartupScript(this, GetType(), DateTime.Now.Ticks.ToString(), "showdialog('" + msg + "');", true);
        }
    }
    //页面显示数据
    public string ShowText(int opType, object objData)
    {
        string strReData = "";

        if (opType == 0)
        {
            //创建时间
            if (objData != null)
            {
                strReData = objData.ToString().Trim().Replace(" ", "<br />");
            }
        }
        else if (opType == 1)
        {
            //显示乘机人
            if (objData != null)
            {
                strReData = objData.ToString().Replace("|", "<br />");
            }
        }
        else if (opType == 2)
        {
            //起飞日期
            if (objData != null)
            {
                strReData = objData.ToString().Trim().Replace("/", "<br />");
            }
        }
        else if (opType == 3)
        {
            //行程
            if (objData != null)
            {
                if (objData.ToString().Trim() == "1")
                {
                    strReData = "单程";
                }
                else if (objData.ToString().Trim() == "2")
                {
                    strReData = "往返";
                }
                else if (objData.ToString().Trim() == "3")
                {
                    strReData = "联程";
                }
                else if (objData.ToString().Trim() == "4")
                {
                    strReData = "多程";
                }
            }
        }
        else if (opType == 4)
        {
            //订单状态
            if (objData != null)
            {
                if (diclist == null)
                {
                    diclist = this.baseDataManage.CallMethod("Bd_Base_Dictionary", "GetList", null, new object[] { "parentid=1" }) as List <Bd_Base_Dictionary>;
                }
                Bd_Base_Dictionary d = diclist.Find(delegate(Bd_Base_Dictionary _dic)
                {
                    return(_dic.ChildID.ToString() == objData.ToString().Trim());
                });
                if (d != null)
                {
                    strReData = d.ChildName.Replace(",", ",").Replace(",", "<br />");
                }
            }
        }
        else if (opType == 5)
        {
            //航程
            if (objData != null)
            {
                strReData = objData.ToString().Trim().Replace("/", "<br />");
            }
        }
        else if (opType == 6)
        {
            //订单状态
            if (objData != null)
            {
                strReData = objData.ToString().Trim() == "27" ? "show" : "hide";
            }
        }
        return(strReData);
    }
    /// <summary>
    /// 添加子级
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddChildName_Click(object sender, EventArgs e)
    {
        string msg = "";

        try
        {
            List <Bd_Base_Dictionary> bPaseList = null;

            if (txtChildName.Text.Trim() == "" || txtChildName.Text.Trim() == "")
            {
                msg = "请输入子级名称!";
            }
            else
            {
                //判断名称是否重复
                bPaseList = ViewState["ChildPaseList"] as List <Bd_Base_Dictionary>;
                foreach (var item in bPaseList)
                {
                    if (item.ChildName == txtChildName.Text.Trim())
                    {
                        msg = "子级名称不能重复!";
                        break;
                    }
                }
            }



            if (msg == "" && bPaseList != null)
            {
                #region 添加子级

                int parentId = int.Parse(ViewState["parentID"].ToString());

                Bd_Base_Dictionary model = new Bd_Base_Dictionary();
                int childID = bPaseList.Max((p) => p.ChildID);// new Bd_Base_DictionaryBLL().GetBaseDictionaryMaxChildIDByParentID(parentId);//获取父级最大id
                childID++;

                model.id               = Guid.NewGuid();
                model.ParentID         = parentId;
                model.ParentName       = ViewState["parentName"].ToString();
                model.ChildID          = childID;
                model.ChildName        = txtChildName.Text.Trim();
                model.ChildDescription = txtChildDescription.Text.Trim();
                model.Remark           = txtRemark.Text.Trim();
                int A1 = 0;
                model.A1 = int.TryParse(txtA1.Text.Trim(), out A1) ? A1 : 0;

                bool result = (bool)baseDataManage.CallMethod("Bd_Base_Dictionary", "Insert", null, new Object[] { model });

                if (result)
                {
                    msg = "添加成功!";

                    DataBlsList();
                }
                else
                {
                    msg = "添加失败!";
                }
                #endregion
            }
        }
        catch (Exception)
        {
            msg = "操作失败!";
        }
        finally
        {
            ScriptManager.RegisterStartupScript(this, GetType(), DateTime.Now.Ticks.ToString(), "showdialog('" + msg + "');", true);
        }
    }