Exemplo n.º 1
0
        public static Int64 CreateBlankDictID(string frmID, string userNo, Hashtable htParas)
        {
            FrmBill fb = new FrmBill(frmID);

            //创建rpt.
            BP.WF.Data.GERpt rpt = new BP.WF.Data.GERpt(frmID);

            //int i= rpt.Retrieve("Starter", WebUser.No, "BillState", 0);
            //if (i >= 1)
            //{
            //    rpt.SetValByKey("RDT", DataType.CurrentData);
            //    return rpt.OID;
            //}

            //更新基础的数据到表单表.
            rpt.SetValByKey("BillState", 0);
            rpt.SetValByKey("Starter", WebUser.No);
            rpt.SetValByKey("StarterName", WebUser.Name);
            rpt.SetValByKey("RDT", DataType.CurrentData);

            rpt.EnMap.CodeStruct = fb.EnMap.CodeStruct;

            //rpt.SetValByKey("Title", gb.Title);
            rpt.SetValByKey("BillNo", rpt.GenerNewNoByKey("BillNo"));
            rpt.OID = DBAccess.GenerOID(frmID);
            rpt.InsertAsOID(rpt.OID);
            return(rpt.OID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建工作ID
        /// </summary>
        /// <param name="frmID">表单ID</param>
        /// <param name="userNo">用户编号</param>
        /// <param name="htParas">参数</param>
        /// <returns>一个新的WorkID</returns>
        public static Int64 CreateBlankBillID(string frmID, string userNo, Hashtable htParas)
        {
            GenerBill gb = new GenerBill();
            int       i  = gb.Retrieve(GenerBillAttr.FrmID, frmID, GenerBillAttr.Starter, userNo, GenerBillAttr.BillState, 0);

            if (i == 1)
            {
                return(gb.WorkID);
            }

            FrmBill fb = new FrmBill(frmID);

            gb.WorkID      = BP.DA.DBAccess.GenerOID("WorkID");
            gb.BillState   = BillState.None; //初始化状态.
            gb.Starter     = BP.Web.WebUser.No;
            gb.StarterName = BP.Web.WebUser.Name;
            gb.FrmName     = fb.Name;       //单据名称.
            gb.FrmID       = fb.No;         //单据ID

            gb.FK_FrmTree = fb.FK_FormTree; //单据类别.
            gb.RDT        = BP.DA.DataType.CurrentDataTime;
            gb.NDStep     = 1;
            gb.NDStepName = "启动";

            //创建rpt.
            BP.WF.Data.GERpt rpt = new BP.WF.Data.GERpt(frmID);

            //设置标题.
            if (fb.EntityType == EntityType.FrmBill)
            {
                gb.Title  = Dev2Interface.GenerTitle(fb.TitleRole, rpt);
                gb.BillNo = BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, gb.WorkID, null, frmID);
            }

            if (fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict)
            {
                rpt.EnMap.CodeStruct = fb.EnMap.CodeStruct;
                gb.BillNo            = rpt.GenerNewNoByKey("BillNo");
                // BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, gb.WorkID, null, frmID);
                gb.Title = "";
            }

            gb.DirectInsert(); //执行插入.

            //更新基础的数据到表单表.
            // rpt = new BP.WF.Data.GERpt(frmID);
            rpt.SetValByKey("BillState", (int)gb.BillState);
            rpt.SetValByKey("Starter", gb.Starter);
            rpt.SetValByKey("StarterName", gb.StarterName);
            rpt.SetValByKey("RDT", gb.RDT);
            rpt.SetValByKey("Title", gb.Title);
            rpt.SetValByKey("BillNo", gb.BillNo);
            rpt.OID = gb.WorkID;
            rpt.InsertAsOID(gb.WorkID);

            return(gb.WorkID);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="frmID">表单ID</param>
        /// <param name="workID">工作ID</param>
        /// <returns>返回保存结果</returns>
        public static string SaveWork(string frmID, Int64 workID)
        {
            FrmBill fb = new FrmBill(frmID);

            GenerBill gb = new GenerBill();

            gb.WorkID = workID;
            int i = gb.RetrieveFromDBSources();

            if (i == 0)
            {
                return("");
            }
            gb.BillState = BillState.Editing;

            //创建rpt.
            BP.WF.Data.GERpt rpt = new BP.WF.Data.GERpt(gb.FrmID, workID);

            if (fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict)
            {
                gb.Title = rpt.Title;
                gb.Update();
                return("保存成功...");
            }

            //单据编号.
            if (DataType.IsNullOrEmpty(gb.BillNo) == true && !(fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict))
            {
                gb.BillNo = BP.Frm.Dev2Interface.GenerBillNo(fb.BillNoFormat, workID, null, fb.PTable);
                //更新单据里面的billNo字段.
                if (DBAccess.IsExitsTableCol(fb.PTable, "BillNo") == true)
                {
                    DBAccess.RunSQL("UPDATE " + fb.PTable + " SET BillNo='" + gb.BillNo + "' WHERE OID=" + workID);
                }
            }

            //标题.
            if (DataType.IsNullOrEmpty(gb.Title) == true && !(fb.EntityType == EntityType.EntityTree || fb.EntityType == EntityType.FrmDict))
            {
                gb.Title = Dev2Interface.GenerTitle(fb.TitleRole, rpt);
                //更新单据里面的 Title 字段.
                if (DBAccess.IsExitsTableCol(fb.PTable, "Title") == true)
                {
                    DBAccess.RunSQL("UPDATE " + fb.PTable + " SET Title='" + gb.Title + "' WHERE OID=" + workID);
                }
            }

            gb.Update();

            //把通用的字段更新到数据库.
            rpt.Title  = gb.Title;
            rpt.BillNo = gb.BillNo;
            rpt.Update();

            return("保存成功...");
        }
Exemplo n.º 4
0
        public string ImpData_Done()
        {
            HttpFileCollection files = context.Request.Files;

            if (files.Count == 0)
            {
                return("err@请选择要导入的数据信息。");
            }

            string errInfo = "";

            string ext      = ".xls";
            string fileName = System.IO.Path.GetFileName(files[0].FileName);

            if (fileName.Contains(".xlsx"))
            {
                ext = ".xlsx";
            }


            //设置文件名
            string fileNewName = DateTime.Now.ToString("yyyyMMddHHmmssff") + ext;

            //文件存放路径
            string filePath = BP.Sys.SystemConfig.PathOfTemp + "\\" + fileNewName;

            files[0].SaveAs(filePath);

            //从excel里面获得数据表.
            DataTable dt = BP.DA.DBLoad.ReadExcelFileToDataTable(filePath);

            //删除临时文件
            System.IO.File.Delete(filePath);

            if (dt.Rows.Count == 0)
            {
                return("err@无导入的数据");
            }

            //获得entity.
            FrmBill   bill = new FrmBill(this.FrmID);
            GEEntitys rpts = new GEEntitys(this.FrmID);
            GERpt     en   = new GERpt(this.FrmID);


            string noColName   = ""; //实体列的编号名称.
            string nameColName = ""; //实体列的名字名称.

            BP.En.Map map  = en.EnMap;
            Attr      attr = map.GetAttrByKey("BillNo");

            noColName = attr.Desc; //
            String codeStruct = bill.EnMap.CodeStruct;

            attr        = map.GetAttrByKey("Title");
            nameColName = attr.Desc; //

            //定义属性.
            Attrs attrs = map.Attrs;

            int impWay = this.GetRequestValInt("ImpWay");

            #region 清空方式导入.
            //清空方式导入.
            int    count       = 0; //导入的行数
            int    changeCount = 0; //更新的行数
            String successInfo = "";
            if (impWay == 0)
            {
                rpts.ClearTable();
                foreach (DataRow dr in dt.Rows)
                {
                    string no   = dr[noColName].ToString();
                    string name = dr[nameColName].ToString();

                    //判断是否是自增序列,序列的格式
                    if (!DataType.IsNullOrEmpty(codeStruct))
                    {
                        no = no.PadLeft(System.Int32.Parse(codeStruct), '0');
                    }

                    GERpt myen = new BP.WF.Data.GERpt(this.FrmID);

                    myen.SetValByKey("BillNo", no);

                    if (myen.Retrieve("BillNo", no) == 1)
                    {
                        errInfo += "err@编号[" + no + "][" + name + "]重复.";
                        continue;
                    }


                    //给实体赋值
                    errInfo += SetEntityAttrVal(no, dr, attrs, myen, dt, 0);
                    count++;
                    successInfo += "&nbsp;&nbsp;<span>" + noColName + "为" + no + "," + nameColName + "为" + name + "的导入成功</span><br/>";
                }
            }

            #endregion 清空方式导入.

            #region 更新方式导入
            if (impWay == 1 || impWay == 2)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string no   = dr[noColName].ToString();
                    string name = dr[nameColName].ToString();
                    //判断是否是自增序列,序列的格式
                    if (!DataType.IsNullOrEmpty(codeStruct))
                    {
                        no = no.PadLeft(System.Int32.Parse(codeStruct), '0');
                    }
                    GERpt myen = rpts.GetNewEntity as GERpt;
                    myen.SetValByKey("BillNo", no);
                    if (myen.Retrieve("BillNo", no) == 1)
                    {
                        //给实体赋值
                        errInfo += SetEntityAttrVal(no, dr, attrs, myen, dt, 1);
                        changeCount++;
                        successInfo += "&nbsp;&nbsp;<span>" + noColName + "为" + no + "," + nameColName + "为" + name + "的更新成功</span><br/>";
                        continue;
                    }


                    //给实体赋值
                    errInfo += SetEntityAttrVal(no, dr, attrs, myen, dt, 0);
                    count++;
                    successInfo += "&nbsp;&nbsp;<span>" + noColName + "为" + no + "," + nameColName + "为" + name + "的导入成功</span><br/>";
                }
            }
            #endregion

            return("errInfo=" + errInfo + "@Split" + "count=" + count + "@Split" + "successInfo=" + successInfo + "@Split" + "changeCount=" + changeCount);
        }