Exemple #1
0
        public IList <TempletTypeInfo> TempletTypeByParentIDGetList(int ParentID)
        {
            IList <TempletTypeInfo> ilist = new List <TempletTypeInfo>();
            DataTable dt = new DataTable();

            OleDbParameter[] param = new OleDbParameter[1];
            param[0]       = new OleDbParameter("@ParentID", OleDbType.Integer);
            param[0].Value = ParentID;

            string sql = "select * from Cm_TempletType where ParentID=@ParentID order by ParentID,ID";

            dt = DbHelper.ExecuteTable(constring, CommandType.Text, sql, param);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                TempletTypeInfo info = new TempletTypeInfo();
                info.ID         = Convert.ToInt32(dt.Rows[i]["ID"].ToString());
                info.ParentID   = int.Parse(dt.Rows[i]["ParentID"].ToString());
                info.Code       = dt.Rows[i]["Code"].ToString();
                info.Title      = dt.Rows[i]["Title"].ToString();
                info.FileTypeID = int.Parse(dt.Rows[i]["FileTypeID"].ToString());
                info.Alias      = dt.Rows[i]["Alias"].ToString();
                info.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"].ToString());
                info.EditTime   = Convert.ToDateTime(dt.Rows[i]["EditTime"].ToString());
                info.Remark     = dt.Rows[i]["Remark"].ToString();
                ilist.Add(info);
            }
            return(ilist);
        }
Exemple #2
0
        public int TempletType_Edit(TempletTypeInfo info)
        {
            int rst = 0;

            try
            {
                OleDbParameter[] param = new OleDbParameter[5];
                //param[0] = new OleDbParameter("@Code", OleDbType.VarWChar, 50);
                //param[0].Value = info.Code;
                param[0]       = new OleDbParameter("@Title", OleDbType.VarWChar, 50);
                param[0].Value = info.Title;
                param[1]       = new OleDbParameter("@Alias", OleDbType.VarWChar, 50);
                param[1].Value = info.Alias;
                param[2]       = new OleDbParameter("@Remark", OleDbType.VarWChar, 100);
                param[2].Value = info.Remark;
                param[3]       = new OleDbParameter("@ID", OleDbType.Integer);
                param[3].Value = info.ID;
                string sql = "update Cm_TempletType set Title=@Title,Alias=@Alias,EditTime=now(),Remark=@Remark where ID=@ID";
                rst = DbHelper.ExecuteNonQuery(constring, CommandType.Text, sql, param);
            }
            catch
            {
                rst = -1;
            }

            return(rst);
        }
Exemple #3
0
        public int TempletType_Add(TempletTypeInfo info)
        {
            int rst = 0;

            try
            {
                OleDbParameter[] param = new OleDbParameter[5];
                param[0]       = new OleDbParameter("@ParentID", OleDbType.Integer);
                param[0].Value = info.ParentID;
                param[1]       = new OleDbParameter("@Code", OleDbType.VarWChar, 50);
                param[1].Value = info.Code;
                param[2]       = new OleDbParameter("@Title", OleDbType.VarWChar, 50);
                param[2].Value = info.Title;
                param[3]       = new OleDbParameter("@Alias", OleDbType.VarWChar, 50);
                param[3].Value = info.Alias;
                param[4]       = new OleDbParameter("@Remark", OleDbType.VarWChar, 100);
                param[4].Value = info.Remark;
                string sql = "insert into Cm_TempletType (ParentID,Code,Title,Alias,CreateTime,EditTime,Remark) values (@ParentID,@Code,@Title,@Alias,now(),now(),@Remark)";
                rst = DbHelper.ExecuteNonQuery(constring, CommandType.Text, sql, param);
            }
            catch
            {
                rst = -1;
            }

            return(rst);
        }
Exemple #4
0
        public IList <TempletTypeInfo> TempletTypeGetList()
        {
            IList <TempletTypeInfo> ilist = new List <TempletTypeInfo>();
            DataTable dt = new DataTable();

            string sql = "select * from Cm_TempletType order by ParentID,ID";

            dt = DbHelper.ExecuteTable(constring, CommandType.Text, sql, null);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                TempletTypeInfo info = new TempletTypeInfo();
                info.ID         = Convert.ToInt32(dt.Rows[i]["ID"].ToString());
                info.ParentID   = int.Parse(dt.Rows[i]["ParentID"].ToString());
                info.Code       = dt.Rows[i]["Code"].ToString();
                info.Title      = dt.Rows[i]["Title"].ToString();
                info.FileTypeID = int.Parse(dt.Rows[i]["FileTypeID"].ToString());
                info.Alias      = dt.Rows[i]["Alias"].ToString();
                info.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"].ToString());
                info.EditTime   = Convert.ToDateTime(dt.Rows[i]["EditTime"].ToString());
                info.Remark     = dt.Rows[i]["Remark"].ToString();
                ilist.Add(info);
            }
            return(ilist);
        }
Exemple #5
0
 private void tv_left_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     tv_left.SelectedNode = e.Node;
     if (tv_left.SelectedNode != null)
     {
         ClearInput();
         if (tv_left.SelectedNode.Text == "根目录")
         {
             ParentInfo          = null;
             lb_ParentTitle.Text = "根目录";
         }
         else
         {
             TempletTypeInfo info = tv_left.SelectedNode.Tag as TempletTypeInfo;
             if (info != null)
             {
                 ParentInfo          = info;
                 lb_ParentTitle.Text = info.Title;
                 tb_Code.Text        = info.Code;
                 if (info.FileTypeID != 0)
                 {
                     cb_FileType.SelectedValue = info.FileTypeID;
                 }
                 else
                 {
                     cb_FileType.SelectedValue = 0;
                 }
             }
         }
         QueryData();
     }
 }
Exemple #6
0
        public TempletTypeInfo TempletTypeByCodeGetList(string Code)
        {
            TempletTypeInfo info = new TempletTypeInfo();
            DataTable       dt   = new DataTable();

            OleDbParameter[] param = new OleDbParameter[1];
            param[0]       = new OleDbParameter("@Code", OleDbType.VarWChar, 50);
            param[0].Value = Code;

            string sql = "select * from Cm_TempletType where Code=@Code order by ParentID,ID";

            dt = DbHelper.ExecuteTable(constring, CommandType.Text, sql, param);
            if (dt.Rows.Count > 0)
            {
                info.ID         = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
                info.ParentID   = int.Parse(dt.Rows[0]["ParentID"].ToString());
                info.Code       = dt.Rows[0]["Code"].ToString();
                info.Title      = dt.Rows[0]["Title"].ToString();
                info.FileTypeID = int.Parse(dt.Rows[0]["FileTypeID"].ToString());
                info.Alias      = dt.Rows[0]["Alias"].ToString();
                info.CreateTime = Convert.ToDateTime(dt.Rows[0]["CreateTime"].ToString());
                info.EditTime   = Convert.ToDateTime(dt.Rows[0]["EditTime"].ToString());
                info.Remark     = dt.Rows[0]["Remark"].ToString();
            }
            return(info);
        }
        /// <summary>
        /// 递归获取实体
        /// </summary>
        /// <param name="ilist">节点</param>
        /// <param name="ninfo">实体</param>
        private void GetMenuInfo(IList <TempletTypeInfo> ilist, TempletTypeInfo ninfo)
        {
            ilist.Add(ninfo);
            var list = from tl in menuList
                       where tl.ParentID == ninfo.ID
                       select tl;

            foreach (TempletTypeInfo info in list)
            {
                GetMenuInfo(ilist, info);
            }
        }
Exemple #8
0
        /// <summary>
        /// 递归获取目录节点
        /// </summary>
        /// <param name="tn">节点</param>
        /// <param name="tinfo">实体</param>
        private void GetNode(TreeNode tn, TempletTypeInfo tinfo)
        {
            var list = from tl in menuList
                       where tl.ParentID == tinfo.ID
                       select tl;

            foreach (TempletTypeInfo info in list)
            {
                TreeNode tnode = new TreeNode(info.Title);
                GetNode(tnode, info);
                tnode.Tag = info;
                tn.Nodes.Add(tnode);
            }
        }
Exemple #9
0
        public static string GetFilePath(int ID)
        {
            string          filepath = "";
            IFileType       ftdal    = new AccessDal.CodeMaker.FileType();
            ITempletType    tdal     = new AccessDal.CodeMaker.TempletType();
            ITemplet        dal      = new AccessDal.CodeMaker.Templet();
            TempletInfo     tinfo    = dal.TempletGetInfo(ID);
            TempletTypeInfo info     = tdal.TempletTypeGetInfo(tinfo.ParentID);

            string          code   = info.Code.Substring(0, 3);
            TempletTypeInfo tyinfo = tdal.TempletTypeByCodeGetList(code);

            string path = ftdal.FileType_GetPath(tyinfo.FileTypeID);

            filepath = rootFolder + "\\" + path + "\\" + info.Code;
            return(filepath);
        }
Exemple #10
0
        /// <summary>
        /// 显示菜单Treeview
        /// </summary>
        private void QueryMenu()
        {
            nodeid   = 0;
            menuList = menuDal.TempletTypeGetList();
            TreeNode        tn   = new TreeNode("根目录");
            TempletTypeInfo info = new TempletTypeInfo();

            info.ID = 0;
            GetNode(tn, info);
            tn.ExpandAll();
            tv_left.Nodes.Clear();
            tv_left.Nodes.Add(tn);

            nodeMax1 = 0;
            TreeNodeCollection tnc = tv_left.Nodes;

            GetNodeNameMax(tnc);
        }
Exemple #11
0
        public static string GetFilePath(TempletTypeInfo info)
        {
            string       filepath = "";
            IFileType    ftdal    = new AccessDal.CodeMaker.FileType();
            ITempletType tdal     = new AccessDal.CodeMaker.TempletType();

            string          code   = info.Code.Substring(0, 3);
            TempletTypeInfo tyinfo = tdal.TempletTypeByCodeGetList(code);

            string path = ftdal.FileType_GetPath(tyinfo.FileTypeID);

            filepath = rootFolder + "\\" + path + "\\" + info.Code;
            string fpath = AppDomain.CurrentDomain.BaseDirectory + filepath;

            if (!Directory.Exists(fpath))
            {
                Directory.CreateDirectory(fpath);
            }

            return(filepath);
        }
        /// <summary>
        /// 递归获取目录节点
        /// </summary>
        /// <param name="tn">节点</param>
        /// <param name="tinfo">实体</param>
        private void GetNode(TreeNode tn, TempletTypeInfo tinfo)
        {
            var list = from tl in menuList
                       where tl.ParentID == tinfo.ID
                       select tl;

            foreach (TempletTypeInfo info in list)
            {
                TreeNode tnode = new TreeNode(info.Title);
                GetNode(tnode, info);
                var tplist = from tp in templetList
                             where tp.ParentID == info.ID
                             select tp;
                foreach (TempletInfo tpinfo in tplist)
                {
                    TreeNode tpnode = new TreeNode(tpinfo.Title);
                    tpnode.Tag  = tpinfo;
                    tpnode.Name = "Templet";
                    tnode.Nodes.Add(tpnode);
                }
                tnode.Tag = info;
                tn.Nodes.Add(tnode);
            }
        }
Exemple #13
0
        /// <summary>
        /// 递归获取数据实体
        /// </summary>
        /// <param name="datalist">数据列表</param>
        /// <param name="ilist">返回数据列表</param>
        /// <param name="ninfo">实体</param>
        private void GetDataInfo(IList <TempletInfo> datalist, IList <TempletInfo> ilist, TempletTypeInfo ninfo)
        {
            var dlist = from dl in datalist
                        where dl.ParentID == ninfo.ID
                        select dl;

            foreach (TempletInfo dinfo in dlist)
            {
                ilist.Add(dinfo);
            }
            var list = from tl in menuList
                       where tl.ParentID == ninfo.ID
                       select tl;

            foreach (TempletTypeInfo info in list)
            {
                GetDataInfo(datalist, ilist, info);
            }
        }
Exemple #14
0
        /// <summary>
        /// 保存数据
        /// </summary>
        private void SaveData()
        {
            TempletInfo info = new TempletInfo();

            info.Code    = tb_Code.Text.Trim();
            info.Title   = tb_Title.Text.Trim();
            info.Content = "";
            info.Remark  = tb_Remark.Text.Trim();
            info.Postfix = cb_Postfix.Text;
            info.Path    = "";
            string Content = textEditorControl.Text;

            if (ParentInfo == null && lb_ID.Text == "")
            {
                MessageBox.Show("请选择目录。");
                return;
            }
            if (info.Title == "")
            {
                MessageBox.Show("请输入名称。");
                return;
            }
            if (Content == "")
            {
                MessageBox.Show("请输入内容。");
                return;
            }
            if (info.Postfix == "")
            {
                MessageBox.Show("请选择后缀名称。");
                return;
            }

            int rst       = -1;
            int TempletID = 0;

            if (lb_ID.Text == "")
            {
                info.ParentID = ParentInfo.ID;
                rst           = dal.Templet_Add(info, out TempletID);
            }
            else
            {
                info.ID   = int.Parse(lb_ID.Text);
                TempletID = info.ID;
                rst       = dal.Templet_Edit(info);
            }

            if (rst == 1)
            {
                IUpLoadFile    ufDal   = new AccessDal.CodeMaker.UpLoadFile();
                UpLoadFileInfo upfInfo = new UpLoadFileInfo();

                upfInfo = ufDal.UpLoadFileGetInfo("Cm_Templet", TempletID);
                if (upfInfo != null && upfInfo.FileID != 0)
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + upfInfo.FilePath + "\\" + upfInfo.UniqueName;
                    Common.FileHandle.DeleteFile(path);
                    if (ufDal.UpLoadFile_Del(upfInfo.FileID) != 1)
                    {
                        MessageBox.Show("操作失败。");
                        return;
                    }
                }

                TempletInfo     tinfo    = dal.TempletGetInfo(TempletID);
                TempletTypeInfo tltinfo  = menuDal.TempletTypeGetInfo(tinfo.ParentID);
                string          fpath    = CodeFile.GetFilePath(tltinfo);
                string          filepath = AppDomain.CurrentDomain.BaseDirectory + fpath;

                rst = Common.FileHandle.WirteCreateFile(Content, filepath + "\\" + info.Title + "." + info.Postfix);
                if (rst == 1)
                {
                    upfInfo.TableName    = "Cm_Templet";
                    upfInfo.RootField    = "";
                    upfInfo.RootId       = "";
                    upfInfo.ParentField  = "";
                    upfInfo.ParentId     = TempletID.ToString();
                    upfInfo.FilePath     = fpath;
                    upfInfo.Remark       = "";
                    upfInfo.FileSize     = 0;
                    upfInfo.FileName     = info.Title;
                    upfInfo.ExpandName   = info.Postfix;
                    upfInfo.UniqueName   = info.Title + "." + info.Postfix;
                    upfInfo.FileTypeId   = tltinfo.ID;
                    upfInfo.AttachmentId = tltinfo.Code;
                    rst = ufDal.UpLoadFile_Add(upfInfo);
                }
            }

            QueryData();

            if (rst == 1)
            {
                MessageBox.Show("保存成功。");
            }
            else
            {
                MessageBox.Show("保存失败。");
            }
        }
Exemple #15
0
        /// <summary>
        /// 保存数据
        /// </summary>
        private void SaveData()
        {
            try
            {
                TempletTypeInfo info = new TempletTypeInfo();
                info.Code   = tb_Code.Text.Trim();
                info.Title  = tb_Title.Text.Trim();
                info.Remark = tb_Remark.Text.Trim();
                info.Alias  = "";


                //if (info.Code == "")
                //{
                //    MessageBox.Show("请输入编码。");
                //    return;
                //}
                if (info.Title == "")
                {
                    MessageBox.Show("请输入名称。");
                    return;
                }

                int rst = -1;
                if (lb_ID.Text == "")
                {
                    if (ParentInfo == null)
                    {
                        //if (info.Code.Length != 3)
                        //{
                        //    MessageBox.Show("请输入3位长度编码。");
                        //    return;
                        //}

                        info.ParentID = 0;
                    }
                    else
                    {
                        //if (info.Code.Length - ParentInfo.Code.Length != 3)
                        //{
                        //    MessageBox.Show("请再输入3位长度编码。");
                        //    return;
                        //}
                        info.ParentID = ParentInfo.ID;
                    }
                    info.Code = GetMaxCode(info.ParentID);
                    rst       = menuDal.TempletType_Add(info);
                }
                else
                {
                    info.ID = int.Parse(lb_ID.Text);
                    rst     = menuDal.TempletType_Edit(info);
                }

                QueryData();

                if (rst == 1)
                {
                    MessageBox.Show("保存成功。");
                }
                else
                {
                    MessageBox.Show("保存失败。");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }