Example #1
0
        private static void Insert(Model.Yjgl.Yj_xmzm zm)
        {
            // 修改文件名
            ChangeFile(zm);

            Insert <Model.Yjgl.Yj_xmzm>(zm);
        }
Example #2
0
        private static void Delete(Model.Yjgl.Yj_xmzm zm)
        {
            Delete <Model.Yjgl.Yj_xmzm>(zm.Pkid);

            // 删除原文件
            string path = TU.WebHelper.MapPath("~" + zm.OldCflj);

            File.Delete(path);
        }
Example #3
0
        private static void Update(Model.Yjgl.Yj_xmzm zm)
        {
            // 删除原文件
            if (zm.OldCflj != zm.Cflj)
            {
                string path = TU.WebHelper.MapPath("~" + zm.OldCflj);
                File.Delete(path);
            }

            // 修改文件名
            ChangeFile(zm);

            Update <Model.Yjgl.Yj_xmzm>(zm);
        }
Example #4
0
        private static void ChangeFile(Model.Yjgl.Yj_xmzm zm)
        {
            int    idx         = zm.Cflj.LastIndexOf("/");
            string dir         = zm.Cflj.Substring(0, idx); // 不带/
            string ext         = zm.Cflj.Substring(zm.Cflj.LastIndexOf('.'));
            string oldfilename = zm.Cflj.Substring(idx);    // 以/开头
            int    no          = int.Parse(oldfilename[5].ToString());
            string newfilename = "/" + no + "_" + zm.Clbt + ext;
            string path        = TU.WebHelper.MapPath("~" + dir);

            File.Move(path + oldfilename, path + newfilename);

            zm.Cflj = dir + newfilename;
        }
Example #5
0
        /// <summary>
        /// 保存证明材料(删除时Pkid以Del@开头)
        /// </summary>
        public static int Save(Model.Yjgl.Yj_xmzm zm)
        {
            int    k    = 0;
            string pkid = zm.Pkid;

            if (String.IsNullOrEmpty(pkid))
            {
                Insert(zm);
            }
            else if (zm.Cflj.StartsWith("Del@"))
            {
                Delete(zm);
            }
            else
            {
                Update(zm);
            }
            return(k);
        }
Example #6
0
        private void SaveXmzm(string xmbh)
        {
            string        errMsg   = "";
            List <string> lstFiles = new List <string>();

            // 检查附件信息
            for (int i = 0; i < this.tbs.Length; i++)
            {
                errMsg += CheckInfo(i);
            }
            if (errMsg.Length > 0)
            {
                Alert.Show(errMsg, "上传提示", MessageBoxIcon.Warning);
                return;
            }

            // 保存附件信息
            for (int no = 0, i = 0; i < this.lstXhs.Count; i++)
            {
                try
                {
                    no = this.lstXhs[i];
                    string   zy      = hfds[no].Text; // 原始附件信息
                    string   clbt    = tbs[no].Text;
                    string   cflj    = hhfs[no].Value;
                    string[] zys     = zy.Split('|');
                    bool     isDel   = cflj.StartsWith("Del@") && !String.IsNullOrEmpty(zy);
                    bool     hasFile = !String.IsNullOrEmpty(cflj) && !cflj.StartsWith("Del@");
                    bool     isAdd   = String.IsNullOrEmpty(zy) && hasFile;
                    bool     isMod   = !isAdd && !isDel && (clbt != zys[1] || cflj != zys[2]);

                    if (isAdd || isDel || isMod)
                    {
                        // 保存附件
                        Model.Yjgl.Yj_xmzm zm = new Model.Yjgl.Yj_xmzm();
                        zm.Pkid = zys[0];
                        zm.Xmbh = Xmbh;
                        zm.Clbt = clbt;
                        zm.Cflj = hhfs[no].Value;
                        if (!isAdd)
                        {
                            zm.OldCflj = zys[2];
                        }
                        BLL.Xmgl.Yj_xmzm.Save(zm);
                    }
                }
                catch (Exception err)
                {
                    Alert.Show(err.Message, string.Format("保存附件{0}失败", szs[no]), MessageBoxIcon.Error);
                    return;
                }
            }

            // 清理临时文件
            string bmbh  = TStar.Web.Globals.Account.DeptPkid;
            string dzbbh = TStar.Web.Globals.Account.UserInfo.Dzbbh;
            string xsbh  = TStar.Web.Globals.Account.Pkid;

            ClearTmpFiles(bmbh, dzbbh, xsbh, Xmbh);

            PageContext.RegisterStartupScript(Alert.GetShowInParentReference("项目证明材料保存成功 !", "操作完成", MessageBoxIcon.Information) + ActiveWindow.GetHidePostBackReference());
        }