Exemplo n.º 1
0
 private PSSMETable GetPSSMEInfoFromIDataReader(IDataReader dr)
 {
     PSSMETable dt = new PSSMETable();
     if (dr.Read())
     {
         dt.MenuDescription = dr["PSSMEMD"].ToString();
         dt.MenuImageUrl = dr["PSSMEUIP"].ToString();
         dt.MenuIsValid = dr["PSSMEUS"].ToString();
         dt.MenuLink = dr["PSSMEMP"].ToString();
         dt.MenuLinkTarget = dr["PSSMEOWT"].ToString();
         dt.MenuMouseDownCss = dr["PSSMEMSS"].ToString();
         dt.MenuMouseLeaveCss = dr["PSSMEMOS"].ToString();
         dt.MenuMouseOverCss = dr["PSSMEMVS"].ToString();
         dt.MenuName = dr["PSSMEMN"].ToString();
         dt.ModleCode = dr["PSSMEMC"].ToString();
         dt.ModleCodeList = dr["PSSMEMLST"].ToString();
         dt.ModleID = Int32.Parse(dr["PSSMEID"].ToString());
         dt.ModleParentCode = dr["PSSMEPMC"].ToString();
         dt.MouldIDList = dr["PSSMEILST"].ToString();
         dt.OrderBy = Int32.Parse(dr["PSSMEOR"].ToString());
         dt.MouldNameEn = dr["PSSMEMNEN"].ToString();
         dt.MouldNameTW = dr["PSSMEMNTW"].ToString();
         dt.IsProcess = dr["PSSMEPRO"].ToString();
         if (dr["PSSMESOID"].ToString() != "") dt.AllOrderBy = Int32.Parse(dr["PSSMESOID"].ToString());
         dt.AllOrderByList = dr["PSSMEOLST"].ToString();
         dr.Close();
         return dt;
     }
     dr.Close();
     return null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 增加节点菜单
        /// </summary>
        /// <param name="_PSSMETable"></param>
        /// <returns>-1;//该节点代码已经存在;</returns>
        public int CreatePSSME(PSSMETable _PSSMETable)
        {
            //判断是否存在该节点代码
            DbParameter[] prams = {
                                   MakeInParam("@PSSMEPMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleCode),
                                   };
            string sql = "";

            sql = "select * from [PSSME] where  PSSMEPMC = @PSSMEPMC ";

            if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0)
            {
                return -1;//该节点代码已经存在
            }
            else
            {
                DbParameter[] prams2 = {
                                   MakeInParam("@PSSMEMD",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuDescription),
                                   MakeInParam("@PSSMEUIP",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuImageUrl),
                                   MakeInParam("@PSSMEUS",(DbType)SqlDbType.Char,1,_PSSMETable.MenuIsValid),
                                   MakeInParam("@PSSMEMP",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuLink),
                                   MakeInParam("@PSSMEOWT",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuLinkTarget),
                                   MakeInParam("@PSSMEMSS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseDownCss),
                                   MakeInParam("@PSSMEMOS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseLeaveCss),
                                   MakeInParam("@PSSMEMVS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseOverCss),
                                   MakeInParam("@PSSMEMN",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuName),
                                   MakeInParam("@PSSMEMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleCode),
                                   MakeInParam("@PSSMEMLST",(DbType)SqlDbType.VarChar,200,_PSSMETable.ModleCodeList),
                                   MakeInParam("@PSSMEID",(DbType)SqlDbType.Int,4,_PSSMETable.ModleID),
                                   MakeInParam("@PSSMEPMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleParentCode),
                                   MakeInParam("@PSSMEILST",(DbType)SqlDbType.VarChar,100,_PSSMETable.MouldIDList),
                                   MakeInParam("@PSSMEOR",(DbType)SqlDbType.Int,4,_PSSMETable.OrderBy),
                                   MakeInParam("@PSSMEMNEN",(DbType)SqlDbType.VarChar,100,_PSSMETable.MouldNameEn),
                                   MakeInParam("@PSSMEMNTW",(DbType)SqlDbType.VarChar,50,_PSSMETable.MouldNameTW),
                                   MakeInParam("@PSSMEPRO",(DbType)SqlDbType.Char,1,_PSSMETable.IsProcess),
                                       };
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].[PSSME]");
                sb.Append("([PSSMEMC]");
                sb.Append(",[PSSMEMN]");
                sb.Append(",[PSSMEMD]");
                sb.Append(",[PSSMEMP]");
                sb.Append(",[PSSMEPMC]");
                sb.Append(",[PSSMEUS]");
                sb.Append(",[PSSMEMVS]");
                sb.Append(",[PSSMEMOS]");
                sb.Append(",[PSSMEMSS]");
                sb.Append(",[PSSMEOWT]");
                sb.Append(",[PSSMEUIP]");
                sb.Append(",[PSSMEILST]");
                sb.Append(",[PSSMEOR]");
                sb.Append(",[PSSMEMNEN]");
                sb.Append(",[PSSMEMNTW]");
                sb.Append(",[PSSMEPRO]");
                sb.Append(",[PSSMEMLST])");
                sb.Append("VALUES");
                sb.Append("(@PSSMEMC,");
                sb.Append("@PSSMEMN,");
                sb.Append("@PSSMEMD, ");
                sb.Append("@PSSMEMP,");
                sb.Append("@PSSMEPMC,");
                sb.Append("@PSSMEUS, ");
                sb.Append("@PSSMEMVS,");
                sb.Append("@PSSMEMOS,");
                sb.Append("@PSSMEMSS,");
                sb.Append("@PSSMEOWT,");
                sb.Append("@PSSMEUIP,");
                sb.Append("@PSSMEILST, ");
                sb.Append("@PSSMEOR, ");
                sb.Append("@PSSMEMNEN,");
                sb.Append("@PSSMEMNTW, ");
                sb.Append("@PSSMEPRO, ");
                sb.Append("@PSSMEMLST);");
                sb.Append("select @@identity;");

                int MoudleID = Utils.StrToInt(ExecuteScalar(CommandType.Text, sb.ToString(), prams2), -1);
                //插入成功后,要把该节点code追加到其上级菜单的记录数组当中去

                if (_PSSMETable.ModleParentCode != "")//非第一级菜单,,
                {
                    DbParameter[] prams3 = {
                                      MakeInParam("@PSSMEILST",(DbType)SqlDbType.VarChar,10,MoudleID.ToString()),
                                      MakeInParam("@PSSMEMLST",(DbType)SqlDbType.VarChar,10,_PSSMETable.ModleCode.ToString()),
                                      MakeInParam("@PSSMEMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleParentCode),
                        };
                    sql = "update [dbo].[PSSME] set PSSMEILST=isnull(PSSMEILST,'')+RTRIM(@PSSMEILST)+',',PSSMEMLST=isnull(PSSMEMLST,'')+RTRIM(@PSSMEMLST)+',' where PSSMEMC=@PSSMEMC";

                    ExecuteNonQuery(CommandType.Text, sql, prams3);
                    string LENPSSMEPMC = "";
                    //获取同级数据且按先代码排序/然后顺序排序.  然后把所有同级记录进行更新一次,也就是为了配合界面上的CSS显示问题
                    for (int i = 0; i < _PSSMETable.ModleCode.ToString().Trim().Length; i++)
                    {
                        LENPSSMEPMC = LENPSSMEPMC + "_";
                    }
                    sql = "select * from [PSSME] where  PSSMEMC like '" + LENPSSMEPMC + "'";

                    IDataReader dr = ExecuteReader(CommandType.Text, sql);
                    int j = 1;
                    while (dr.Read())
                    {
                        sql = "update [PSSME] set PSSMESOID=" + j + " where PSSMEMC = '" + dr["PSSMEMC"].ToString() + "'";
                        ExecuteNonQuery(CommandType.Text, sql);
                        j++;
                    }
                    //然后还要把该更新后的顺序号告诉给其上级,获取上级数据,
                    LENPSSMEPMC = "";
                    for (int i = 0; i < _PSSMETable.ModleParentCode.ToString().Trim().Length; i++)
                    {
                        LENPSSMEPMC = LENPSSMEPMC + "_";
                    }
                    sql = "select * from [PSSME] where  PSSMEMC like '" + LENPSSMEPMC + "'";
                    dr = ExecuteReader(CommandType.Text, sql);
                    while (dr.Read())
                    {
                        //获取到的上级,然后又去得到它的所有下级目录。
                        sql = "select * from [PSSME] where  PSSMEPMC like '" + dr["PSSMEMC"].ToString() + "' order by PSSMESOID";
                        IDataReader dr2 = ExecuteReader(CommandType.Text, sql);
                        string strPSSMEILST = "";
                        while (dr2.Read())
                        {
                            strPSSMEILST = strPSSMEILST + dr2["PSSMESOID"].ToString().Trim() + ",";
                        }
                        dr2.Close();
                        //再循环地把他们的CSS使用的ID给自己的ID集合
                        if (strPSSMEILST.Length > 0)
                        {
                            sql = "update [PSSME] set PSSMEOLST='" + strPSSMEILST.Substring(0, strPSSMEILST.Length - 1) + "' where PSSMEMC = '" + dr["PSSMEMC"].ToString() + "'";
                            ExecuteNonQuery(CommandType.Text, sql);
                        }
                    }
                    dr.Close();
                }
                return MoudleID;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 修改节点菜单
 /// </summary>
 /// <param name="_PSSMETable"></param>
 /// <returns>-1;//该节点代码已经存在;</returns>
 public int UpdatePSSME(PSSMETable _PSSMETable)
 {
     DbParameter[] prams2 = {
                        MakeInParam("@PSSMEMD",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuDescription),
                        MakeInParam("@PSSMEUIP",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuImageUrl),
                        MakeInParam("@PSSMEUS",(DbType)SqlDbType.Char,1,_PSSMETable.MenuIsValid),
                        MakeInParam("@PSSMEMP",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuLink),
                        MakeInParam("@PSSMEOWT",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuLinkTarget),
                        MakeInParam("@PSSMEMSS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseDownCss),
                        MakeInParam("@PSSMEMOS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseLeaveCss),
                        MakeInParam("@PSSMEMVS",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuMouseOverCss),
                        MakeInParam("@PSSMEMN",(DbType)SqlDbType.VarChar,50,_PSSMETable.MenuName),
                        MakeInParam("@PSSMEMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleCode),
                        MakeInParam("@PSSMEMLST",(DbType)SqlDbType.VarChar,200,_PSSMETable.ModleCodeList),
                        MakeInParam("@PSSMEID",(DbType)SqlDbType.Int,4,_PSSMETable.ModleID),
                        MakeInParam("@PSSMEPMC",(DbType)SqlDbType.VarChar,50,_PSSMETable.ModleParentCode),
                        MakeInParam("@PSSMEILST",(DbType)SqlDbType.VarChar,100,_PSSMETable.MouldIDList),
                        MakeInParam("@PSSMEOR",(DbType)SqlDbType.Int,4,_PSSMETable.OrderBy),
                        MakeInParam("@PSSMEMNEN",(DbType)SqlDbType.VarChar,100,_PSSMETable.MouldNameEn),
                        MakeInParam("@PSSMEMNTW",(DbType)SqlDbType.VarChar,50,_PSSMETable.MouldNameTW),
                        MakeInParam("@PSSMEPRO",(DbType)SqlDbType.Char,1,_PSSMETable.IsProcess),
                                };
     string sql = "UpdatePSSME";
     int MoudleID = Utils.StrToInt(ExecuteScalar(CommandType.StoredProcedure, sql, prams2), -1);
     return MoudleID;
 }
Exemplo n.º 4
0
 private int SaveData()
 {
     PSSMETable dt = new PSSMETable();
     dt.ModleID = mMoudleID;
     dt.MenuIsValid = chkValiad.SelectedValue;
     dt.MenuLink = txtLink.Text;
     dt.MenuLinkTarget = txtiFrame.Text;
     dt.MenuName = txtTitleOne.Text;
     dt.ModleCode = txtCodeOne.Text;
     if (lblParentCode.Text.ToString() != "0")
         dt.ModleParentCode = lblParentCode.Text;
     else
         dt.ModleParentCode = "";
     dt.IsProcess = chkIsProcess.SelectedValue;
     dt.MouldNameEn = txtTitleEn.Text;
     if (txtTitleTW.Text == "")
         dt.MouldNameTW = Utils.ToTChinese(txtTitleOne.Text);
     else
         dt.MouldNameTW = txtTitleTW.Text;
     dt.OrderBy = Convert.ToInt16(txtOrderby.Text);
     if (dt.ModleID == 0)
         return DbHelper.GetInstance().CreatePSSME(dt);
     else
         return DbHelper.GetInstance().UpdatePSSME(dt);
 }