Ejemplo n.º 1
0
        /// <summary>
        /// 将实体类转为json格式List
        /// </summary>
        /// <param name="ens"></param>
        /// <param name="hidenKeys">隐藏字段</param>
        /// <returns></returns>
        public string TranslateEntitiesToListJson(BP.En.Entities ens, string hidenKeys)
        {
            Attrs         attrs  = ens.GetNewEntity.EnMap.Attrs;
            StringBuilder append = new StringBuilder();

            append.Append("[");

            foreach (Entity en in ens)
            {
                append.Append("{");
                foreach (Attr attr in attrs)
                {
                    if (!string.IsNullOrEmpty(hidenKeys) && hidenKeys.Contains("@" + attr.Key))
                    {
                        continue;
                    }

                    string strValue = en.GetValStrByKey(attr.Key);
                    if (!string.IsNullOrEmpty(strValue) && strValue.LastIndexOf("\\") > -1)
                    {
                        strValue = strValue.Substring(0, strValue.LastIndexOf("\\"));
                    }
                    append.Append(attr.Key + ":'" + strValue + "',");
                }
                append = append.Remove(append.Length - 1, 1);
                append.Append("},");
            }
            if (append.Length > 1)
            {
                append = append.Remove(append.Length - 1, 1);
            }
            append.Append("]");
            return(ReplaceIllgalChart(append.ToString()));
        }
Ejemplo n.º 2
0
    void ToolBar1_ButtonClick(object sender, EventArgs e)
    {
        var btn = sender as LinkBtn;

        switch (btn.ID)
        {
        case NamesOfBtn.New:
        case NamesOfBtn.Save:
        case NamesOfBtn.SaveAndNew:
            this.Save();
            break;

        case NamesOfBtn.SaveAndClose:
            this.Save();
            this.WinClose();
            break;

        case NamesOfBtn.Delete:
            BP.En.Entities dtls = this.HisEns;
            QueryObject    qo   = new QueryObject(dtls);
            qo.DoQuery(dtls.GetNewEntity.PK, BP.Sys.SystemConfig.PageSize, this.PageIdx, false);
            string msg1 = "";
            foreach (BP.En.Entity dtl in dtls)
            {
                CheckBox cb = this.ucsys1.GetCBByID("IDX_" + dtl.PKVal);
                if (cb == null)
                {
                    continue;
                }
                try
                {
                    if (cb.Checked)
                    {
                        dtl.Delete();
                    }
                }
                catch (Exception ex)
                {
                    msg1 += "@删除期间错误:" + ex.Message;
                }
            }

            if (msg1 != "")
            {
                this.Alert(msg1);
            }

            this.ucsys1.Clear();
            this.Bind();
            break;

        case NamesOfBtn.Excel:
            this.ExpExcel();
            break;

        default:
            BP.Sys.PubClass.Alert("当前版本不支持此功能。");
            break;
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 为部分数据做的缓冲处理
 /// </summary>
 /// <param name="clName"></param>
 /// <param name="obj"></param>
 public static void SetEnsDataExt(string clName, BP.En.Entities obj)
 {
     if (clName == null || obj == null)
     {
         throw new Exception("clName.  obj 参数有一个为空。");
     }
     EnsData_Cash_Ext[clName] = obj;
 }
        /// <summary>
        /// 将实体类转为json格式 包含列名和数据
        /// </summary>
        /// <param name="ens"></param>
        /// <returns></returns>
        public string TranslateEntitiesToGridJsonColAndData(BP.En.Entities ens)
        {
            Attrs         attrs  = ens.GetNewEntity.EnMap.Attrs;
            StringBuilder append = new StringBuilder();

            append.Append("{");
            //整理列名
            append.Append("columns:[");
            foreach (Attr attr in attrs)
            {
                if (attr.IsRefAttr || attr.UIVisible == false)
                {
                    continue;
                }

                if (attr.Key == this.RefPK)
                {
                    continue;
                }

                append.Append("{");
                append.Append(string.Format("field:'{0}',title:'{1}',width:{2},sortable:true", attr.Key, attr.Desc, attr.UIWidth * 2));
                append.Append("},");
            }
            if (append.Length > 10)
            {
                append = append.Remove(append.Length - 1, 1);
            }
            append.Append("]");

            //整理数据
            bool bHaveData = false;

            append.Append(",data:[");
            foreach (Entity en in ens)
            {
                bHaveData = true;
                append.Append("{");
                foreach (Attr attr in attrs)
                {
                    if (attr.IsRefAttr || attr.UIVisible == false)
                    {
                        continue;
                    }
                    append.Append(attr.Key + ":\"" + en.GetValStrByKey(attr.Key) + "\",");
                }
                append = append.Remove(append.Length - 1, 1);
                append.Append("},");
            }
            if (append.Length > 11 && bHaveData)
            {
                append = append.Remove(append.Length - 1, 1);
            }
            append.Append("]");
            append.Append("}");
            return(append.ToString());
        }
Ejemplo n.º 5
0
        public static void EnsDataSet(string clName, BP.En.Entities obj)
        {
            if (obj.Count == 0)
            {
                ///obj.RetrieveAll();
#warning 设置个数为

                //  throw new Exception(clName + "设置个数为0 , 请确定这个缓存实体,是否有数据?sq=select * from " + obj.GetNewEntity.EnMap.PhysicsTable);
            }

            EnsData_Cash[clName] = obj;
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            string ensName = context.Request.QueryString["EnsName"];
            string PKVal   = context.Request.QueryString["PKVal"];

            BP.En.Entities ens = BP.En.ClassFactory.GetEns(ensName);
            BP.En.Entity   en  = ens.GetNewEntity;
            if (PKVal != null)
            {
                en.PKVal = PKVal;
                en.RetrieveFromDBSources();
            }
            en = BP.Sys.PubClass.CopyFromRequest(en, context.Request);
            en.Save();



            #region 保存 属性 附件
            try
            {
                //AttrFiles fils = en.EnMap.HisAttrFiles;
                //SysFileManagers sfs = new SysFileManagers(en.ToString(), en.PKVal.ToString());
                //foreach (AttrFile fl in fils)
                //{
                //    HtmlInputFile file = (HtmlInputFile)this.UCEn1.FindControl("F" + fl.FileNo);
                //    if (file.Value.Contains(".") == false)
                //        continue;

                //    SysFileManager enFile = sfs.GetEntityByKey(SysFileManagerAttr.AttrFileNo, fl.FileNo) as SysFileManager;
                //    SysFileManager enN = null;
                //    if (enFile == null)
                //    {
                //        enN = this.FileSave(null, file, en);
                //    }
                //    else
                //    {
                //        enFile.Delete();
                //        enN = this.FileSave(null, file, en);
                //    }

                //    enN.AttrFileNo = fl.FileNo;
                //    enN.AttrFileName = fl.FileName;
                //    enN.EnName = en.ToString();
                //    enN.Update();
                //}
            }
            catch
            {
                //     this.Alert("保存附件出现错误:" + ex.Message);
            }
            #endregion
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 将实体类转为json格式
        /// </summary>
        /// <param name="ens"></param>
        /// <param name="hidenKeys"></param>
        /// <returns></returns>
        public string TranslateEntitiesToGridJsonOnlyData(BP.En.Entities ens, int totalRows, string hidenKeys)
        {
            Attrs         attrs  = ens.GetNewEntity.EnMap.Attrs;
            StringBuilder append = new StringBuilder();

            append.Append("{rows:[");

            foreach (Entity en in ens)
            {
                append.Append("{");
                foreach (Attr attr in attrs)
                {
                    if (!string.IsNullOrEmpty(hidenKeys) && hidenKeys.Contains("@" + attr.Key))
                    {
                        continue;
                    }

                    string strValue = en.GetValStrByKey(attr.Key);
                    if (!string.IsNullOrEmpty(strValue) && strValue.LastIndexOf("\\") > -1)
                    {
                        strValue = strValue.Substring(0, strValue.LastIndexOf("\\"));
                    }
                    append.Append(attr.Key + ":'" + strValue + "',");
                }
                append = append.Remove(append.Length - 1, 1);
                append.Append("},");
            }
            //长度超过{rows:[才进行截取
            if (append.Length > 7)
            {
                append = append.Remove(append.Length - 1, 1);
            }


            if (totalRows == 0)
            {
                append.Append("],total:");
                append.Append(ens != null ? ens.Count : 0);
            }
            else
            {
                append.Append("],total:" + totalRows);
            }
            append.Append("}");
            return(ReplaceIllgalChart(append.ToString()));
        }
Ejemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            string ensName = context.Request.QueryString["EnsName"];
            string PKVal   = context.Request.QueryString["PKVal"];

            BP.En.Entities ens = BP.En.ClassFactory.GetEns(ensName);
            BP.En.Entity   en  = ens.GetNewEntity;
            if (PKVal != null)
            {
                en.PKVal = PKVal;
                en.RetrieveFromDBSources();
            }
            en = BP.Sys.PubClass.CopyFromRequest(en, context.Request);
            en.Save();

            #region 保存 实体附件
            try
            {
                if (en.EnMap.Attrs.Contains("MyFileName"))
                {
                    //HtmlInputFile file = this.UCEn1.FindControl("file") as HtmlInputFile;
                    //if (file != null && file.Value.IndexOf(".") != -1)
                    //{
                    //    BP.Sys.EnCfg cfg = new EnCfg(en.ToString());
                    //    if (System.IO.Directory.Exists(cfg.FJSavePath) == false)
                    //        System.IO.Directory.CreateDirectory(cfg.FJSavePath);

                    //    /* 如果包含这二个字段。*/
                    //    string fileName = file.PostedFile.FileName;
                    //    fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1);

                    //    string filePath = cfg.FJSavePath;
                    //    en.SetValByKey("MyFilePath", filePath);

                    //    string ext = "";
                    //    if (fileName.IndexOf(".") != -1)
                    //        ext = fileName.Substring(fileName.LastIndexOf(".") + 1);

                    //    en.SetValByKey("MyFileExt", ext);
                    //    en.SetValByKey("MyFileName", fileName);
                    //    en.SetValByKey("WebPath", cfg.FJWebPath + en.PKVal + "." + ext);

                    //    string fullFile = filePath + "/" + en.PKVal + "." + ext;

                    //    file.PostedFile.SaveAs(fullFile);
                    //    file.PostedFile.InputStream.Close();
                    //    file.PostedFile.InputStream.Dispose();
                    //    file.Dispose();

                    //    System.IO.FileInfo info = new System.IO.FileInfo(fullFile);
                    //    en.SetValByKey("MyFileSize", BP.DA.DataType.PraseToMB(info.Length));
                    //    if (DataType.IsImgExt(ext))
                    //    {
                    //        System.Drawing.Image img = System.Drawing.Image.FromFile(fullFile);
                    //        en.SetValByKey("MyFileH", img.Height);
                    //        en.SetValByKey("MyFileW", img.Width);
                    //        img.Dispose();
                    //    }
                    //    en.Update();
                    //}
                }
            }
            catch (Exception ex)
            {
                //  this.Alert("保存附件出现错误:" + ex.Message);
            }
            #endregion

            #region 保存 属性 附件
            try
            {
                //AttrFiles fils = en.EnMap.HisAttrFiles;
                //SysFileManagers sfs = new SysFileManagers(en.ToString(), en.PKVal.ToString());
                //foreach (AttrFile fl in fils)
                //{
                //    HtmlInputFile file = (HtmlInputFile)this.UCEn1.FindControl("F" + fl.FileNo);
                //    if (file.Value.Contains(".") == false)
                //        continue;

                //    SysFileManager enFile = sfs.GetEntityByKey(SysFileManagerAttr.AttrFileNo, fl.FileNo) as SysFileManager;
                //    SysFileManager enN = null;
                //    if (enFile == null)
                //    {
                //        enN = this.FileSave(null, file, en);
                //    }
                //    else
                //    {
                //        enFile.Delete();
                //        enN = this.FileSave(null, file, en);
                //    }

                //    enN.AttrFileNo = fl.FileNo;
                //    enN.AttrFileName = fl.FileName;
                //    enN.EnName = en.ToString();
                //    enN.Update();
                //}
            }
            catch
            {
                //     this.Alert("保存附件出现错误:" + ex.Message);
            }
            #endregion
        }