Esempio n. 1
0
 public static void crearConexion(String pConexion)
 {
     if (accesoDatos == null)
     {
         accesoDatos = new DBAccess(pConexion);
     }
 }
		protected void Page_Load(object sender, EventArgs e)
		{
			// initialize database helper
			objDB = new DBAccess();
			objDB.ErrorLabel = lblError;
			
			btnOk.OnClientClick = string.Format("javascript: {0}.style.visibility = 'hidden'; return false; ", pnlMessage.ClientID);

			pnlMessage.Visible = false;
			
			if (!Page.IsPostBack)
			{
				// do the initial retrieval of the list of CADs
				DataTable objCADTable = objDB.GetCADs();
				ddlCADId.DataSource = objCADTable;
				ddlCADId.DataTextField = "CAD";
				ddlCADId.DataValueField = "CAD";
				ddlCADId.DataBind();
			}
			else
			{
				// retrieve table to be edited from the Session
				objDT = (DataTable)Session[ CACHED_TABLE ];
				if (objDT != null)
					fvEditor.DataSource = objDT;

				// retrieve the item template containing the tabs and the columns to use in the formview
				DynamicItemTemplate objTemplate = (DynamicItemTemplate)Session[ CACHED_TEMPLATE ];
				if (objTemplate != null)
				{
					fvEditor.EditItemTemplate = objTemplate;
					try
					{
						fvEditor.DataBind();
					}
					catch (Exception)
					{
					}
				}

				// retrieve the table that stores the changed columns and reasons
				if (objChangedColumns == null)
				{
					objChangedColumns = (DataTable)Session[ CACHED_CHANGEDCOLS ];

					// if it is not Sessiond, create and Session it
					if (objChangedColumns == null)
					{
						// if table does not exist, create it and Session the structure
						objChangedColumns = new DataTable("ChangedColumns");
						...
						
						Session[ CACHED_CHANGEDCOLS ] = objChangedColumns;					
					}
				}

				// retrieve the index of the currently selected change in the list box of changes
				iPreviousIndex = Convert.ToInt32( Session[PREVIOUS_INDEX] );
			}
		}
        public DBArtistTest()
        {
            db = new DBAccess();
            db.Open();
            db.ClearDatabase();

        }
Esempio n. 4
0
        public DataLoader( string strPath
            , System.Web.UI.WebControls.TextBox tbStatusParam
            , System.Web.UI.WebControls.Label lblErrorParam
            , System.Web.UI.HtmlControls.HtmlGenericControl OpenCSVListParam)
        {
            strAppPath = strPath;	//Request.PhysicalApplicationPath
            tbStatus = tbStatusParam;
            lblError = lblErrorParam;

            objDB = new DBAccess();
            objDB.ErrorLabel = lblErrorParam;

            Company2SFUtils.OpenCSVList = OpenCSVListParam;
        }
Esempio n. 5
0
 private void SaveToken(OAuthToken token)
 {
     TextBox1.Text += "token:" + token.Token + '\n';
     TextBox1.Text += "token:" + token.Secret + '\n';
     DBAccess dba = new DBAccess();
     dba.AddTable(DBConst.C3010A00);
     dba.AddParam(DBConst.C3010A01, 0);
     dba.AddParam(DBConst.C3010A02, HashUtil.UtcTimeInHex(false));
     dba.AddParam(DBConst.C3010A03, UserModel.Current(Session).Code);
     dba.AddParam(DBConst.C3010A04, KuaipanServer.TYPE);
     dba.AddParam(DBConst.C3010A05, KuaipanServer.CONSUMER_KEY);
     dba.AddParam(DBConst.C3010A06, KuaipanServer.CONSUMER_SECRET);
     dba.AddParam(DBConst.C3010A07, CharUtil.Text2DB(token.Token));
     dba.AddParam(DBConst.C3010A08, CharUtil.Text2DB(token.Secret));
     dba.AddParam(DBConst.C3010A09, 1);
     dba.AddParam(DBConst.C3010A0A, DBConst.SQL_NOW, false);
     dba.AddParam(DBConst.C3010A0B, DBConst.SQL_NOW, false);
     dba.ExecuteInsert();
 }
Esempio n. 6
0
        /// <summary>
        /// 获取数据库访问对象的静态方法
        /// </summary>
        /// <returns>返回数据库访问对象(dbAccess)</returns>
        public static IDBAccess GetDBAccess(string connectionString)
        {
            IDBAccess dbAccess = null;
            DBAccessType type = dbType();
            switch (type)
            {
                case DBAccessType.SQL:
                    dbAccess = new DBAccess<SqlConnection, SqlCommand, SqlDataAdapter>(connectionString);
                    break;
                case DBAccessType.ODBC:
                    dbAccess = new DBAccess<OdbcConnection, OdbcCommand, OdbcDataAdapter>(connectionString);
                    break;
                case DBAccessType.OLEDB:
                    dbAccess = new DBAccess<OleDbConnection, OleDbCommand, OleDbDataAdapter>(connectionString);
                    break;
                case DBAccessType.ORACLE:
                    dbAccess = new DBAccess<OracleConnection, OracleCommand, OracleDataAdapter>(connectionString);
                    break;
            }

            return dbAccess;
        }
Esempio n. 7
0
        public void LoadById(string id)
        {
            toolStripTextBox1.Text = id;
            til = DBAccess.GetTextureInformationsById(id);
            List <DBAccess.BundleInformation> tbil = new List <DBAccess.BundleInformation>();

            foreach (DBAccess.TextureInformation ti in til)
            {
                bool found = false;
                for (int i = 0; i < tbil.Count; i++)
                {
                    if (tbil[i].index == ti.bundleIndex)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    tbil.Add(DBAccess.GetBundleInformationByIndex(ti.bundleIndex));
                }
            }
            bil = tbil.ToArray();
            List <DBAccess.TOCInformation> ttocil = new List <DBAccess.TOCInformation>();

            foreach (DBAccess.BundleInformation bi in bil)
            {
                bool found = false;
                for (int i = 0; i < ttocil.Count; i++)
                {
                    if (ttocil[i].index == bi.tocIndex)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    ttocil.Add(DBAccess.GetTocInformationByIndex(bi.tocIndex));
                }
            }
            tocil    = ttocil.ToArray();
            hasBase  = hasPatch = hasDLC = false;
            allInCas = true;
            foreach (DBAccess.TOCInformation toci in tocil)
            {
                if (!toci.incas)
                {
                    allInCas = false;
                }
                if (!toci.path.ToLower().Contains("update"))
                {
                    hasBase = true;
                }
                else
                {
                    if (toci.path.ToLower().Contains("patch"))
                    {
                        hasPatch = true;
                    }
                    else
                    {
                        hasDLC = true;
                    }
                }
            }
            listBox1.Items.Clear();
            int count = 0;

            foreach (DBAccess.BundleInformation bi in bil)
            {
                DBAccess.TOCInformation ti = new DBAccess.TOCInformation();
                ti.path = "";
                foreach (DBAccess.TOCInformation t in tocil)
                {
                    if (t.index == bi.tocIndex)
                    {
                        ti = t;
                    }
                }
                listBox1.Items.Add((count++) + " : " + ti.path + " -> " + bi.bundlepath);
            }
            rtb1.Text = "";
            rtb1.AppendText("Name                : " + id + "\n");
            rtb1.AppendText("Bundle occurenes    : " + bil.Length + "\n");
            rtb1.AppendText("TOC occurenes       : " + tocil.Length + "\n");
            rtb1.AppendText("All in CAS          : " + allInCas + "\n");
            rtb1.AppendText("Occurs in base game : " + hasBase + "\n");
            rtb1.AppendText("Occurs in DLC       : " + hasDLC + "\n");
            rtb1.AppendText("Occurs in Patch     : " + hasPatch + "\n");
            if (bil.Length != 0)
            {
                listBox1.SelectedIndex = 0;
            }
        }
Esempio n. 8
0
 private void RefreshPreview()
 {
     try
     {
         int n = listBox1.SelectedIndex;
         if (n == -1)
         {
             return;
         }
         status.Text = "Getting header infos from db...";
         Application.DoEvents();
         DBAccess.RESInformation    ti   = ttprevlist[n];
         DBAccess.BundleInformation buni = DBAccess.GetBundleInformationById(ti.bundlepath)[0];
         DBAccess.TOCInformation    toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
         BinaryBundle b       = new BinaryBundle();
         byte[]       resdata = new byte[0];
         if (toci.incas)
         {
             status.Text = "Getting header data from sha1...";
             Application.DoEvents();
             resdata = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ti.sha1));
         }
         else
         {
             status.Text = "Getting header data from binary bundle...";
             Application.DoEvents();
             TOCFile toc        = new TOCFile(toci.path);
             byte[]  bundledata = toc.ExportBundleDataByPath(buni.bundlepath);
             b = new BinaryBundle(new MemoryStream(bundledata));
             foreach (BinaryBundle.ResEntry res in b.ResList)
             {
                 if (res._name == ti.resname)
                 {
                     resdata = res._data;
                     break;
                 }
             }
         }
         hb1.ByteProvider = new DynamicByteProvider(resdata);
         mesh             = new Mesh(new MemoryStream(resdata));
         rtb1.Text        = mesh.HeaderToStr();
         rtb2.Text        = mesh.LODsToString();
         foreach (Mesh.MeshLOD lod in mesh.header.LODs)
         {
             byte[] id   = lod.ChunkID;
             byte[] data = new byte[0];
             if (toci.incas)
             {
                 DBAccess.ChunkInformation ci = GetChunkById(id);
                 if (ci.sha1 == null)
                 {
                     continue;
                 }
                 data = SHA1Access.GetDataBySha1(ci.sha1);
             }
             else
             {
                 byte t = id[0];
                 id[0] = id[3];
                 id[3] = t;
                 t     = id[1];
                 id[1] = id[2];
                 id[2] = t;
                 t     = id[6];
                 id[6] = id[7];
                 id[7] = t;
                 t     = id[4];
                 id[4] = id[5];
                 id[5] = t;
                 foreach (BinaryBundle.ChunkEntry c in b.ChunkList)
                 {
                     if (Helpers.ByteArrayCompare(id, c.id))
                     {
                         data = c._data;
                     }
                 }
                 if (data.Length == 0)
                 {
                     DBAccess.ChunkInformation ci = GetChunkById(id);
                     if (ci.sha1 == null)
                     {
                         continue;
                     }
                     data = SHA1Access.GetDataBySha1(ci.sha1);
                 }
             }
             mesh.LoadChunkData(lod, new MemoryStream(data));
         }
         MeshRenderObject mro = new MeshRenderObject(mesh);
         renderer.list.Clear();
         renderer.list.Add(mro);
         renderer.worldoffset = -mro.center;
         renderer.CamDistance = mro.min.Length() + mro.max.Length();
         listBox2.Items.Clear();
         int count = 0;
         foreach (Mesh.MeshLOD l in mesh.header.LODs)
         {
             listBox2.Items.Add("LOD " + (count++) + " - Chunk-" + Helpers.ByteArrayToHexString(l.ChunkID));
         }
         status.Text = "Ready";
     }
     catch (Exception ex)
     {
         status.Text = "General error, after state '" + status.Text + "' : " + ex.Message;
     }
 }
Esempio n. 9
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            try
            {
                statustext.Text = "Getting header infos from db...";
                Application.DoEvents();
                hb1.ByteProvider = new DynamicByteProvider(new byte[0]);
                if (File.Exists("tmp\\tmp.dds"))
                {
                    File.Delete("tmp\\tmp.dds");
                }

                DBAccess.BundleInformation  buni = bil[n];
                DBAccess.TextureInformation ti   = new DBAccess.TextureInformation();
                foreach (DBAccess.TextureInformation t in til)
                {
                    if (t.bundleIndex == buni.index)
                    {
                        ti = t;
                    }
                }
                DBAccess.TOCInformation toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
                byte[] resdata = new byte[0];
                if (toci.incas)
                {
                    statustext.Text = "Getting header data from sha1...";
                    Application.DoEvents();
                    resdata = SHA1Access.GetDataBySha1(ti.sha1);
                }
                else
                {
                    statustext.Text = "Getting header data from binary bundle...";
                    Application.DoEvents();
                    TOCFile      toc        = new TOCFile(toci.path);
                    byte[]       bundledata = toc.ExportBundleDataByPath(buni.bundlepath);
                    BinaryBundle b          = new BinaryBundle(new MemoryStream(bundledata));
                    foreach (BinaryBundle.ResEntry res in b.ResList)
                    {
                        if (res._name == ti.name)
                        {
                            resdata = res._data;
                            break;
                        }
                    }
                }
                hb1.ByteProvider = new DynamicByteProvider(resdata);
                statustext.Text  = "Getting texture infos from db...";
                Application.DoEvents();
                TextureMetaResource       tmr = new TextureMetaResource(resdata);
                DBAccess.ChunkInformation ci  = DBAccess.GetChunkInformationById(tmr.chunkid);
                if (ci.bundleIndex == -1)
                {
                    throw new Exception("no chunk info found in db");
                }
                DBAccess.BundleInformation buni2 = DBAccess.GetBundleInformationByIndex(ci.bundleIndex);
                DBAccess.TOCInformation    toci2 = DBAccess.GetTocInformationByIndex(buni2.tocIndex);
                byte[] texdata = new byte[0];
                if (toci2.incas)
                {
                    statustext.Text = "Getting texture data from sha1...";
                    Application.DoEvents();
                    texdata = SHA1Access.GetDataBySha1(ci.sha1);
                }
                else
                {
                    statustext.Text = "Getting texture data from binary bundle...";
                    Application.DoEvents();
                    TOCFile      toc        = new TOCFile(toci2.path);
                    byte[]       bundledata = toc.ExportBundleDataByPath(buni2.bundlepath);
                    BinaryBundle b          = new BinaryBundle(new MemoryStream(bundledata));
                    foreach (BinaryBundle.ChunkEntry chunk in b.ChunkList)
                    {
                        if (Helpers.MatchByteArray(chunk.id, ci.id))
                        {
                            texdata = chunk._data;
                            break;
                        }
                    }
                }
                hb2.ByteProvider = new DynamicByteProvider(texdata);
                statustext.Text  = "Making Preview...";
                Application.DoEvents();
                MemoryStream m = new MemoryStream();
                tmr.WriteTextureHeader(m);
                m.Write(texdata, 0, texdata.Length);
                if (!Directory.Exists("tmp"))
                {
                    Directory.CreateDirectory("tmp");
                }
                File.WriteAllBytes("tmp\\tmp.dds", m.ToArray());
                try
                {
                    pb1.Image = DevIL.DevIL.LoadBitmap("tmp\\tmp.dds");
                    pb1.BringToFront();
                }
                catch (Exception)
                {
                    statustext.Text = "Error loading dds, after state '" + statustext.Text + "'";
                }
                statustext.Text = "Ready";
            }
            catch (Exception)
            {
                statustext.Text = "General error, after state '" + statustext.Text + "'";
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 得到菜单列表
        /// </summary>
        /// <returns></returns>
        public static DataTable GetGroupsForUser()
        {
            string sql = @"select GroupCode, GroupName, '0'GroupSelected  from KPI_Group  order by GroupCode";

            return(DBAccess.GetRelation().ExecuteDataset(sql).Tables[0]);
        }
Esempio n. 11
0
 private void frm_LPI_per_orgtype_main_Load(object sender, EventArgs e)
 {
     cmbOrgtype.DataSource = DBAccess.populatecmb("`sp_populate_cmb_host`", "host_org_type");
 }
Esempio n. 12
0
        /// <summary>
        /// 获得记录个数
        /// </summary>
        /// <returns></returns>
        public static int CurveIDCounts()
        {
            string sql = "select CurveID from KPI_CurveTag";

            return(DBAccess.GetRelation().ExecuteDataset(sql).Tables[0].Rows.Count);
        }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserModel userModel = UserModel.Current(Session);
        if (userModel.Rank < IUser.LEVEL_02)
        {
            Response.Redirect("~/Index.aspx");
            return;
        }

        if (IsPostBack)
        {
            return;
        }

        DBAccess dba = new DBAccess();
        dba.AddTable(DBConst.APWD0000);
        dba.AddColumn(DBConst.APWD0002);
        dba.AddColumn(DBConst.APWD0003);
        dba.AddWhere(DBConst.APWD0001, userModel.Code);
        dba.AddSort(DBConst.APWD0002, true);
        DataTable dt = dba.ExecuteSelect();
        if (dt.Rows.Count != 4)
        {
            TrRegInfo.Visible = false;
            return;
        }

        TrRegData1.Visible = false;
        TrRegData2.Visible = false;

        StringBuilder buffer = new StringBuilder();
        XmlWriter writer = XmlWriter.Create(buffer);
        writer.WriteStartElement("Amon");
        writer.WriteStartElement("User");
        writer.WriteElementString("Code", userModel.Code);
        foreach (DataRow row in dt.Rows)
        {
            if ("Data" == row[DBConst.APWD0002] as string)
            {
                writer.WriteElementString("Data", row[DBConst.APWD0003] as string);
                continue;
            }
            if ("Info" == row[DBConst.APWD0002] as string)
            {
                writer.WriteElementString("Info", row[DBConst.APWD0003] as string);
                continue;
            }
            if ("Main" == row[DBConst.APWD0002] as string)
            {
                writer.WriteElementString("Main", row[DBConst.APWD0003] as string);
                continue;
            }
            if ("Safe" == row[DBConst.APWD0002] as string)
            {
                writer.WriteElementString("Safe", row[DBConst.APWD0003] as string);
                continue;
            }
        }
        writer.WriteEndElement();
        writer.WriteEndElement();
        writer.Flush();
        writer.Close();

        TBData.Text = buffer.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"").ToString();
    }
Esempio n. 14
0
        /// <summary>
        /// 得到区间值,实体形式
        /// </summary>
        /// <returns></returns>
        public static List <KPI_XLineEntity> GetAllXLineEntity(string ecid, string eccode, string curvegroup, int numbers)
        {
            //
            //numbers 在查询时为0, 在校验时 为 系数数量。
            List <KPI_XLineEntity> ltxls = new List <KPI_XLineEntity>();

            string sql       = @"select CurveID, CurveCode, CurveMonth, CurveType, CurveGetType, CurveXRealTag, CurveYRealTag, CurveZRealTag, CurveXYZ
                            from KPI_CurveTag
                            where CurveIsValid=1 {0}";
            string condition = " and CurveGroup='" + curvegroup + "'";

            sql = string.Format(sql, condition);

            DataTable dt = DBAccess.GetRelation().ExecuteDataset(sql).Tables[0];

            foreach (DataRow dr in dt.Rows)
            {
                int    xlinetype    = int.Parse(dr["CurveType"].ToString());
                int    xlinegettype = int.Parse(dr["CurveGetType"].ToString());
                string xlinemonth   = dr["CurveMonth"].ToString();

                string xlinexyz = dr["CurveXYZ"].ToString();

                DataTable dtXLine = new DataTable();
                double    dout    = 0.0;

                bool bResult = GetXLineXYZ(xlinetype, xlinexyz, out dtXLine, out dout);

                if (xlinetype == 0)
                {
                    KPI_XLineEntity entity = new KPI_XLineEntity();
                    entity.XLineID = Guid.NewGuid().ToString();
                    ////////////////////////////////////////////////////////////////
                    //notice
                    entity.ECID         = ecid;
                    entity.ECCode       = eccode;
                    entity.ECCurveGroup = curvegroup;
                    entity.XLineMonth   = "," + xlinemonth + ",";
                    entity.XLineCoef    = "a1";
                    entity.XLineGet     = xlinegettype;
                    entity.XLineXBase   = "";
                    entity.XLineYBase   = "";

                    entity.XLineX     = 0;
                    entity.XLineY     = 0;
                    entity.XLineValue = dout;

                    if (numbers > 1)
                    {
                        return(null);
                    }

                    ltxls.Add(entity);
                }
                else if (xlinetype == 1)
                {
                    string xrealtag = dr["CurveXRealTag"].ToString();
                    //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag);
                    //xrealtag = "'" + xrealtag + "'";

                    for (int i = 1; i < dtXLine.Rows.Count; i++)
                    {
                        for (int j = 1; j < dtXLine.Columns.Count; j++)
                        {
                            KPI_XLineEntity entity = new KPI_XLineEntity();
                            entity.XLineID = Guid.NewGuid().ToString();
                            ////////////////////////////////////////////////////////////////
                            //notice
                            entity.ECID         = ecid;
                            entity.ECCode       = eccode;
                            entity.ECCurveGroup = curvegroup;
                            entity.XLineMonth   = "," + xlinemonth + ",";
                            entity.XLineCoef    = "a" + i.ToString();
                            entity.XLineGet     = xlinegettype;
                            entity.XLineXBase   = xrealtag;
                            entity.XLineYBase   = "";
                            entity.XLineX       = double.Parse(dtXLine.Rows[0][j].ToString());
                            entity.XLineY       = 0;
                            entity.XLineValue   = double.Parse(dtXLine.Rows[i][j].ToString());

                            ltxls.Add(entity);
                        }
                    }

                    if (numbers > (dtXLine.Rows.Count - 1))
                    {
                        return(null);
                    }
                }
                else if (xlinetype == 2)
                {
                    string xrealtag = dr["CurveXRealTag"].ToString();
                    //xrealtag = KPI_RealTagDal.GetRealCode(xrealtag);
                    //xrealtag = "'" + xrealtag + "'";

                    string yrealtag = dr["CurveYRealTag"].ToString();
                    //yrealtag = KPI_RealTagDal.GetRealCode(yrealtag);
                    //yrealtag = "'" + yrealtag + "'";

                    for (int i = 1; i < dtXLine.Rows.Count; i++)
                    {
                        for (int j = 1; j < dtXLine.Columns.Count; j++)
                        {
                            KPI_XLineEntity entity = new KPI_XLineEntity();
                            entity.XLineID = Guid.NewGuid().ToString();
                            ////////////////////////////////////////////////////////////////
                            //notice
                            entity.ECID         = ecid;
                            entity.ECCode       = eccode;
                            entity.ECCurveGroup = curvegroup;
                            entity.XLineMonth   = "," + xlinemonth + ",";
                            entity.XLineCoef    = "a1";
                            entity.XLineGet     = xlinegettype;
                            entity.XLineXBase   = xrealtag;
                            entity.XLineYBase   = yrealtag;
                            entity.XLineX       = double.Parse(dtXLine.Rows[0][j].ToString());
                            entity.XLineY       = double.Parse(dtXLine.Rows[i][0].ToString());
                            entity.XLineValue   = double.Parse(dtXLine.Rows[i][j].ToString());

                            ltxls.Add(entity);
                        }
                    }

                    if (numbers > 1)
                    {
                        return(null);
                    }
                }
                break;
            }
            return(ltxls);
        }
Esempio n. 15
0
        /// <summary>
        /// 获得所有经济指标的ID, Name集, 供下拉列表用
        /// </summary>
        /// <returns></returns>
        public static DataTable GetCurvesByCode()
        {
            string sql = @"select CurveCode[Code], CurveCode+CurveName[Name] from KPI_CurveTag order by CurveIndex";

            return(DBAccess.GetRelation().ExecuteDataset(sql).Tables[0]);
        }
Esempio n. 16
0
        public static bool GenerateHOSAFiles(int ALedgerNumber,
                                             int APeriodNumber,
                                             int AIchNumber,
                                             string ACostCentre,
                                             String ACurrencySelect,
                                             string AFileName,
                                             out TVerificationResultCollection AVerificationResult,
                                             TDataBase ADataBase)
        {
            bool Successful = false;

            GLBatchTDS MainDS = new GLBatchTDS();

            TVerificationResultCollection VerificationResult = new TVerificationResultCollection();

            AVerificationResult = VerificationResult;

            TDataBase      db            = DBAccess.Connect("GenerateHOSAFiles", ADataBase);
            TDBTransaction DBTransaction = new TDBTransaction();

            db.ReadTransaction(
                ref DBTransaction,
                delegate
            {
                //Load tables needed: AccountingPeriod, Ledger, Account, Cost Centre, Transaction, Gift Batch, ICHStewardship
                ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, DBTransaction);

                /* Retrieve info on the ledger. */
                ALedgerRow LedgerRow = (ALedgerRow)MainDS.ALedger.Rows[0];
                String Currency      = (ACurrencySelect == MFinanceConstants.CURRENCY_BASE) ? LedgerRow.BaseCurrency : LedgerRow.IntlCurrency;

                /*              String StoreNumericFormat = "#" + CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator + "##0";
                 *
                 *              if (CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits > 0)
                 *              {
                 *                  string DecPls = new String('0', CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits);
                 *                  StoreNumericFormat += CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + DecPls;
                 *              }
                 */
                AAccountingPeriodTable AccountingPeriodTable =
                    AAccountingPeriodAccess.LoadByPrimaryKey(ALedgerNumber, APeriodNumber, DBTransaction);
                AAccountingPeriodRow AccountingPeriodRow = (AAccountingPeriodRow)AccountingPeriodTable.Rows[0];
                String MonthName = AccountingPeriodRow.AccountingPeriodDesc;

                //Create table definitions
                DataTable TableForExport = new DataTable();
                TableForExport.Columns.Add("CostCentre", typeof(string));
                TableForExport.Columns.Add("Account", typeof(string));
                TableForExport.Columns.Add("LedgerMonth", typeof(string));
                TableForExport.Columns.Add("ICHPeriod", typeof(string));
                TableForExport.Columns.Add("Date", typeof(DateTime));
                TableForExport.Columns.Add("IndividualDebitTotal", typeof(decimal));
                TableForExport.Columns.Add("IndividualCreditTotal", typeof(decimal));

                TLedgerInfo info = new TLedgerInfo(ALedgerNumber, db);

                string TableForExportHeader = "/** Header **" + "," +
                                              APeriodNumber.ToString() + "," +
                                              info.GetStandardCostCentre() + "," +
                                              ACostCentre + "," +
                                              DateTime.Today.ToShortDateString() + "," +
                                              Currency;

                //See gi3200.p ln: 170
                //Select any gift transactions to export
                string strSql = TDataBase.ReadSqlFile("ICH.HOSAExportGifts.sql");

                OdbcParameter parameter;

                List <OdbcParameter> parameters = new List <OdbcParameter>();
                parameter       = new OdbcParameter("LedgerNumber", OdbcType.Int);
                parameter.Value = ALedgerNumber;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("Year", OdbcType.Int);
                parameter.Value = LedgerRow.CurrentFinancialYear;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("CostCentre", OdbcType.VarChar);
                parameter.Value = ACostCentre;
                parameters.Add(parameter);

                DataTable TmpTable = db.SelectDT(strSql, "table", DBTransaction, parameters.ToArray());

                foreach (DataRow untypedTransRow in TmpTable.Rows)
                {
                    string gLMAcctCode  = untypedTransRow[3].ToString();
                    string gLMCostCCode = untypedTransRow[4].ToString();
                    string gLMAcctType  = untypedTransRow[5].ToString();

                    if (gLMAcctType == MFinanceConstants.ACCOUNT_TYPE_INCOME)         //a_account.a_account_type_c
                    {
                        DateTime PeriodStartDate = AccountingPeriodRow.PeriodStartDate;
                        DateTime PeriodEndDate   = AccountingPeriodRow.PeriodEndDate;

                        /*RUN Export_gifts(INPUT pv_ledger_number_i...*/

                        //gi3200-1.i
                        ExportGifts(ALedgerNumber,
                                    ACostCentre,
                                    gLMAcctCode,
                                    MonthName,
                                    APeriodNumber,
                                    PeriodStartDate,
                                    PeriodEndDate,
                                    ACurrencySelect,
                                    AIchNumber,
                                    TableForExport,
                                    VerificationResult,
                                    db);
                    }

                    /* Then see if there are any GL transactions to export */
                    //gi3200.i ln:33

                    /*
                     * This scheme with ODBC parameters consistently causes an "input string is the wrong type" eror:
                     *
                     * strSql = TDataBase.ReadSqlFile("ICH.HOSAExportGLTrans.sql");
                     * OdbcParameter[] SqlParams = new OdbcParameter[] {
                     *      new OdbcParameter("LedgerNumber", (Int32)ALedgerNumber),
                     *      new OdbcParameter("Account", (String)gLMAcctCode),
                     *      new OdbcParameter("CostCentre", (String)gLMCostCCode),
                     *      new OdbcParameter("Narrative", (String)MFinanceConstants.NARRATIVE_YEAR_END_REALLOCATION),
                     *      new OdbcParameter("ICHNumber", (Int32)AIchNumber),
                     *      new OdbcParameter("ICHNumber2", (Int32)AIchNumber),
                     *      new OdbcParameter("PeriodNumber", (Int32)APeriodNumber)
                     *  };
                     * DataTable TmpTransTable = db.SelectDT(strSql, "Transactions", DBTransaction, SqlParams);
                     */

                    strSql = "SELECT Trans.a_ledger_number_i, Trans.a_batch_number_i, Trans.a_journal_number_i, Trans.a_transaction_number_i, " +
                             "Trans.a_account_code_c, Trans.a_cost_centre_code_c, Trans.a_transaction_date_d, Trans.a_transaction_amount_n, " +
                             "Trans.a_amount_in_base_currency_n, Trans.a_amount_in_intl_currency_n, Trans.a_ich_number_i, Trans.a_system_generated_l, "
                             +
                             "Trans.a_narrative_c, Trans.a_debit_credit_indicator_l  FROM public.a_transaction AS Trans, public.a_journal AS Journal "
                             +
                             "WHERE Trans.a_ledger_number_i = Journal.a_ledger_number_i AND Trans.a_batch_number_i = Journal.a_batch_number_i " +
                             "AND Trans.a_journal_number_i = Journal.a_journal_number_i " +
                             String.Format(
                        "AND Trans.a_ledger_number_i = {0} AND Trans.a_account_code_c = '{1}' AND Trans.a_cost_centre_code_c = '{2}' " +
                        "AND Trans.a_transaction_status_l = true AND NOT (Trans.a_narrative_c LIKE '{3}%' AND Trans.a_system_generated_l = true) "
                        +
                        "AND ((Trans.a_ich_number_i + {4}) = Trans.a_ich_number_i OR Trans.a_ich_number_i = {4}) " +
                        "AND Journal.a_journal_period_i = {5};",
                        ALedgerNumber,
                        gLMAcctCode,
                        gLMCostCCode,
                        MFinanceConstants.NARRATIVE_YEAR_END_REALLOCATION,
                        AIchNumber,
                        APeriodNumber
                        );

                    DataTable TmpTransTable = db.SelectDT(strSql, "Transactions", DBTransaction);

                    foreach (DataRow untypedTransactRow in TmpTransTable.Rows)
                    {
                        Decimal DebitTotal  = 0;
                        Decimal CreditTotal = 0;

                        bool Debit           = Convert.ToBoolean(untypedTransactRow[13]);       //a_transaction.a_debit_credit_indicator_l
                        bool SystemGenerated = Convert.ToBoolean(untypedTransactRow[11]);       //a_transaction.a_system_generated_l
                        //TODO: Calendar vs Financial Date Handling - Check if number of ledger periods needs to be used here and not 12 assumed
                        string Narrative         = untypedTransactRow[12].ToString();           //a_transaction.a_narrative_c
                        DateTime TransactionDate = Convert.ToDateTime(untypedTransactRow[6]);   //a_transaction.a_transaction_date_d

                        if (ACurrencySelect == MFinanceConstants.CURRENCY_BASE)
                        {
                            decimal AmountInBaseCurrency = Convert.ToDecimal(untypedTransactRow[8]);      //a_transaction.a_amount_in_base_currency_n

                            /* find transaction amount and store as debit or credit */
                            if (Debit)
                            {
                                DebitTotal += AmountInBaseCurrency;
                            }
                            else
                            {
                                CreditTotal += AmountInBaseCurrency;
                            }
                        }
                        else
                        {
                            decimal AmountInIntlCurrency = Convert.ToDecimal(untypedTransactRow[9]);       //a_transaction.a_amount_in_intl_currency_n

                            if (Debit)
                            {
                                DebitTotal += AmountInIntlCurrency;
                            }
                            else
                            {
                                CreditTotal += AmountInIntlCurrency;
                            }
                        }

                        TLogging.LogAtLevel(4, "HOSA-Narrative: " + Narrative);

                        //Check for specific narrative strings
                        bool IsNarrativeGBGiftBatch            = false;
                        int LenNarrativeGBGiftBatch            = MFinanceConstants.NARRATIVE_GB_GIFT_BATCH.Length;
                        bool IsNarrativeGiftsReceivedGiftBatch = false;
                        int LenNarrativeGiftsReceivedGiftBatch = MFinanceConstants.NARRATIVE_GIFTS_RECEIVED_GIFT_BATCH.Length;

                        if (Narrative.Length >= LenNarrativeGiftsReceivedGiftBatch)
                        {
                            IsNarrativeGiftsReceivedGiftBatch =
                                (Narrative.Substring(0,
                                                     LenNarrativeGiftsReceivedGiftBatch) == MFinanceConstants.NARRATIVE_GIFTS_RECEIVED_GIFT_BATCH);
                        }

                        if (Narrative.Length >= LenNarrativeGBGiftBatch)
                        {
                            IsNarrativeGBGiftBatch =
                                (Narrative.Substring(0, LenNarrativeGBGiftBatch) == MFinanceConstants.NARRATIVE_GB_GIFT_BATCH);
                        }

                        if ((gLMAcctType.ToUpper() != MFinanceConstants.ACCOUNT_TYPE_INCOME.ToUpper()) ||
                            !(SystemGenerated && (IsNarrativeGBGiftBatch || IsNarrativeGiftsReceivedGiftBatch)))
                        {
                            // Put transaction information
                            DataRow DR = (DataRow)TableForExport.NewRow();

                            DR[0] = gLMCostCCode;
                            DR[1] = ConvertAccount(gLMAcctCode);
                            DR[2] = ALedgerNumber.ToString() + MonthName + ":" + Narrative;
                            DR[3] = "ICH-" + APeriodNumber.ToString("00");
                            DR[4] = TransactionDate;
                            DR[5] = DebitTotal;
                            DR[6] = CreditTotal;

                            TableForExport.Rows.Add(DR);
                        }
                    }
                }

                TableForExport.AcceptChanges();

                TLogging.LogAtLevel(4, "HOSA-TableForExport: " + TableForExport.Rows.Count.ToString());

                //DataTables to XML to CSV
                XmlDocument doc = TDataBase.DataTableToXml(TableForExport);

                TCsv2Xml.Xml2Csv(doc, AFileName);

                //Replace the default CSV header row with OM specific
                ReplaceHeaderInFile(AFileName, TableForExportHeader, ref VerificationResult);
                Successful = true;
            });     // Get NewOrExisting AutoReadTransaction

            return(Successful);
        } // Generate HOSA Files
Esempio n. 17
0
        public static void ExportGifts(int ALedgerNumber,
                                       string ACostCentre,
                                       string AAcctCode,
                                       string AMonthName,
                                       int APeriodNumber,
                                       DateTime APeriodStartDate,
                                       DateTime APeriodEndDate,
                                       string ACurrencySelect,
                                       int AIchNumber,
                                       DataTable AExportDataTable,
                                       TVerificationResultCollection AVerificationResult,
                                       TDataBase ADataBase)
        {
            /* Define local variables */
            bool    FirstLoopFlag         = true;
            Int32   LastRecipKey          = 0;
            string  LastGroup             = string.Empty;
            string  LastDetail            = string.Empty;
            string  LastDetailDesc        = string.Empty;
            decimal IndividualDebitTotal  = 0;
            decimal IndividualCreditTotal = 0;

            string ExportDescription = string.Empty;
            Int32  tmpLastRecipKey   = 0;
            string tmpLastGroup      = string.Empty;
            string tmpLastDetail     = string.Empty;

            //Find and total each gift transaction

            TDBTransaction DBTransaction = new TDBTransaction();
            TDataBase      db            = DBAccess.Connect("ExportGifts", ADataBase);

            db.ReadTransaction(ref DBTransaction,
                               delegate
            {
                String IchNumberFilter = "";

                if (AIchNumber > 0)
                {
                    IchNumberFilter = " AND GiftDetail.a_ich_number_i = " + AIchNumber;
                }

                String Query = "SELECT " +
                               " GiftDetail.a_ledger_number_i, " +
                               " GiftDetail.a_batch_number_i, " +
                               " GiftDetail.a_gift_transaction_number_i, " +
                               " GiftDetail.a_detail_number_i, " +
                               " GiftDetail.a_gift_amount_n, " +
                               " GiftDetail.a_gift_amount_intl_n, " +
                               " GiftDetail.a_motivation_group_code_c, " +
                               " GiftDetail.a_motivation_detail_code_c, " +
                               " GiftDetail.p_recipient_key_n, " +
                               " Gift.a_gift_status_c, " +
                               " MotiviationDetail.a_motivation_detail_desc_c, " +
                               " GiftBatch.a_batch_description_c " +
                               " FROM " +
                               " public.a_gift_detail AS GiftDetail, " +
                               " public.a_gift_batch AS GiftBatch, " +
                               " public.a_motivation_detail AS MotiviationDetail, " +
                               " public.a_gift AS Gift " +
                               " WHERE " +
                               " GiftDetail.a_ledger_number_i = GiftBatch.a_ledger_number_i  " +
                               " AND GiftDetail.a_batch_number_i = GiftBatch.a_batch_number_i  " +
                               " AND GiftDetail.a_ledger_number_i = MotiviationDetail.a_ledger_number_i  " +
                               " AND GiftDetail.a_motivation_group_code_c = MotiviationDetail.a_motivation_group_code_c  " +
                               " AND GiftDetail.a_motivation_detail_code_c = MotiviationDetail.a_motivation_detail_code_c  " +
                               " AND GiftDetail.a_ledger_number_i = Gift.a_ledger_number_i  " +
                               " AND GiftDetail.a_batch_number_i = Gift.a_batch_number_i  " +
                               " AND GiftDetail.a_gift_transaction_number_i = Gift.a_gift_transaction_number_i  " +
                               " AND GiftDetail.a_ledger_number_i = " + ALedgerNumber +
                               " AND GiftDetail.a_cost_centre_code_c = '" + ACostCentre + "'" +
                               IchNumberFilter +
                               " AND GiftBatch.a_batch_status_c = '" + MFinanceConstants.BATCH_POSTED + "'" +
                               " AND GiftBatch.a_gl_effective_date_d >= " + APeriodStartDate.ToString("#yyyy-MM-dd#") +
                               " AND GiftBatch.a_gl_effective_date_d <= " + APeriodEndDate.ToString("#yyyy-MM-dd#") +
                               " AND MotiviationDetail.a_account_code_c = '" + AAcctCode + "'" +
                               " ORDER BY " +
                               " GiftDetail.p_recipient_key_n ASC, " +
                               " GiftDetail.a_motivation_group_code_c ASC, " +
                               " GiftDetail.a_motivation_detail_code_c ASC;";


                DataTable TmpTable = db.SelectDT(Query, "table", DBTransaction);

                foreach (DataRow Row in TmpTable.Rows)
                {
                    /* Print totals etc. found for last recipient */
                    /* Only do after first loop due to last recipient key check */

                    tmpLastRecipKey = Convert.ToInt32(Row["p_recipient_key_n"]);
                    tmpLastGroup    = Row["a_motivation_group_code_c"].ToString();
                    tmpLastDetail   = Row["a_motivation_detail_code_c"].ToString();

                    if (!FirstLoopFlag &&
                        ((tmpLastRecipKey != LastRecipKey) ||
                         (tmpLastGroup != LastGroup) ||
                         (tmpLastDetail != LastDetail)
                        )
                        )
                    {
                        if ((IndividualCreditTotal != 0) ||
                            (IndividualDebitTotal != 0))
                        {
                            if (LastRecipKey != 0)
                            {
                                /* Find partner short name details */
                                PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction);
                                PPartnerRow PartnerRow     = (PPartnerRow)PartnerTable.Rows[0];

                                LastDetailDesc += " : " + PartnerRow.PartnerShortName;

                                ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc;
                            }
                            else
                            {
                                AMotivationGroupTable MotivationGroupTable = AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber,
                                                                                                                     LastGroup,
                                                                                                                     DBTransaction);
                                AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0];

                                ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" +
                                                    MotivationGroupRow.MotivationGroupDescription.TrimEnd(
                                    new Char[] { (' ') }) + "," + LastDetailDesc;
                            }

                            //Add data to export table
                            DataRow DR = (DataRow)AExportDataTable.NewRow();

                            DR[0] = ACostCentre;
                            DR[1] = ConvertAccount(AAcctCode);
                            DR[2] = ExportDescription;
                            DR[3] = "ICH-" + APeriodNumber.ToString("00");
                            DR[4] = APeriodEndDate;
                            DR[5] = IndividualDebitTotal;
                            DR[6] = IndividualCreditTotal;

                            AExportDataTable.Rows.Add(DR);

                            /* Reset total */
                            IndividualDebitTotal  = 0;
                            IndividualCreditTotal = 0;
                        }
                    }

                    if (ACurrencySelect == MFinanceConstants.CURRENCY_BASE)
                    {
                        Decimal GiftAmount = Convert.ToDecimal(Row["a_gift_amount_n"]);

                        if (GiftAmount < 0)
                        {
                            IndividualDebitTotal -= GiftAmount;
                        }
                        else
                        {
                            IndividualCreditTotal += GiftAmount;
                        }
                    }
                    else
                    {
                        Decimal IntlGiftAmount = Convert.ToDecimal(Row["a_gift_amount_intl_n"]);

                        if (IntlGiftAmount < 0)
                        {
                            IndividualDebitTotal -= IntlGiftAmount;
                        }
                        else
                        {
                            IndividualCreditTotal += IntlGiftAmount;
                        }
                    }

                    /* Set loop variables */
                    LastRecipKey   = tmpLastRecipKey;
                    LastGroup      = tmpLastGroup;
                    LastDetail     = tmpLastDetail;
                    LastDetailDesc = Convert.ToString(Row["a_motivation_detail_desc_c"]);
                    FirstLoopFlag  = false;
                }     // foreach

                /* Print totals etc. found for last recipient */
                /* Only do after first loop due to last recipient key check */
                if (!FirstLoopFlag && ((IndividualCreditTotal != 0) || (IndividualDebitTotal != 0)))
                {
                    if (LastRecipKey != 0)
                    {
                        /* Find partner short name details */
                        PPartnerTable PartnerTable = PPartnerAccess.LoadByPrimaryKey(LastRecipKey, DBTransaction);
                        PPartnerRow PartnerRow     = (PPartnerRow)PartnerTable.Rows[0];

                        LastDetailDesc += ":" + PartnerRow.PartnerShortName;

                        ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" + LastDetailDesc;
                    }
                    else
                    {
                        AMotivationGroupTable MotivationGroupTable =
                            AMotivationGroupAccess.LoadByPrimaryKey(ALedgerNumber, LastGroup, DBTransaction);
                        AMotivationGroupRow MotivationGroupRow = (AMotivationGroupRow)MotivationGroupTable.Rows[0];


                        ExportDescription = ALedgerNumber.ToString() + AMonthName + ":" +
                                            MotivationGroupRow.MotivationGroupDescription.TrimEnd() + "," + LastDetailDesc;
                    }

                    //Add rows to export table
                    DataRow DR = (DataRow)AExportDataTable.NewRow();

                    DR[0] = ACostCentre;
                    DR[1] = ConvertAccount(AAcctCode);
                    DR[2] = ExportDescription;
                    DR[3] = "ICH-" + APeriodNumber.ToString("00");
                    DR[4] = APeriodEndDate;;
                    DR[5] = IndividualDebitTotal;
                    DR[6] = IndividualCreditTotal;

                    AExportDataTable.Rows.Add(DR);
                }
            });     // Get NewOrExisting AutoReadTransaction
        } // Export Gifts
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    strsql = @"select * from WF_GenerWorkFlow where WorkID not in (
select distinct WorkID from WF_GenerWorkerlist) and WFState<> 3 and WFState<>7 and RDT > '2014-10-01 00:00' order by RDT desc ";
            DataTable dt     = DBAccess.RunSQLReturnTable(strsql);

            foreach (DataRow row in dt.Rows)
            {
                string empwors = row["TodoEmps"].ToString();
                if (!string.IsNullOrEmpty(empwors))
                {
                    string[] emps = empwors.Split(';');
                    if (emps != null && emps.Length > 0)
                    {
                        foreach (string str in emps)
                        {
                            if (!string.IsNullOrEmpty(str))
                            {
                                string[] emp = str.Split(',');
                                BP.WF.GenerWorkerList list = new GenerWorkerList();
                                list.WorkID      = Convert.ToInt64(row["WorkID"].ToString());
                                list.FK_Emp      = emp[0];
                                list.FK_EmpText  = emp[1];
                                list.FK_Node     = Convert.ToInt32(row["FK_Node"].ToString());
                                list.FK_NodeText = row["NodeName"].ToString();
                                list.FID         = Convert.ToInt64(row["FID"].ToString());
                                list.FK_Flow     = row["FK_Flow"].ToString();
                                list.FK_Dept     = row["FK_Dept"].ToString();
                                list.SDT         = row["SDTOfNode"].ToString();
                                list.DTOfWarning = row["SDTOfFlow"].ToString();
                                list.WarningHour = 0;
                                list.RDT         = row["RDT"].ToString();
                                list.IsEnable    = true;
                                list.IsPass      = false;
                                list.WhoExeIt    = 0;
                                list.Sender      = row["Starter"].ToString();
                                list.PRI         = 1;
                                list.IsRead      = false;
                                list.PressTimes  = 0;
                                list.HungUpTimes = 0;
                                list.CDT         = row["RDT"].ToString();
                                list.Insert();
                            }
                        }
                    }
                }
            }

            try
            {
                string url = "../WF/WFRpt.aspx?DoType=View&WorkID={0}&FK_Flow={1}&FK_Node={2}";
                string sql = "SELECT top 1 OID FROM RMS.dbo.V_FlowData WHERE ProjNo in (SELECT ProjNo FROM ND137Rpt WHERE OID='{0}') AND FK_Flow='{1}' ORDER BY OID DESC";
                //列表展示
                if (this.FrmView == "1")
                {
                    sql = "SELECT ProjNo FROM ND137Rpt WHERE OID='{0}'";
                    sql = string.Format(sql, this.WorkID);
                    string projNo = DBAccess.RunSQLReturnStringIsNull(sql, "0");
                    url = "ProjectInfoView.aspx?FK_Flow=" + this.FK_Flow + "&id=" + projNo;
                    Response.Redirect(url);
                }
                else
                {
                    //如果传入项目编号,直接使用
                    if (string.IsNullOrEmpty(this.ProjNo))
                    {
                        sql = string.Format(sql, this.WorkID, this.FK_Flow);
                    }
                    else
                    {
                        sql = "SELECT top 1 OID FROM RMS.dbo.V_FlowData WHERE ProjNo ='" + this.ProjNo + "' AND FK_Flow='" + this.FK_Flow + "' ORDER BY OID DESC";
                    }
                    //查到信息进行跳转,查不到进行提示
                    string OID = BP.DA.DBAccess.RunSQLReturnString(sql);
                    if (!string.IsNullOrEmpty(OID))
                    {
                        url = string.Format(url, OID, this.FK_Flow, this.FK_Node);
                        Response.Redirect(url);
                    }
                }
            }
            catch (Exception ex)
            {
                BP.DA.Log.DefaultLogWriteLineError(ex);
            }
            Response.Write("所选信息不存在!");
        }
Esempio n. 19
0
 public UserTest() {
     db = new DBAccess();
     db.Open();
 }
Esempio n. 20
0
        /// <summary>
        /// export all posted invoices of other suppliers in this year
        /// </summary>
        public static void Export(string AOutputPath,
                                  char ACSVSeparator,
                                  string ANewLine,
                                  Int32 ALedgerNumber,
                                  Int32 AFinancialYear,
                                  string ACostCentres)
        {
            string filename = Path.GetFullPath(Path.Combine(AOutputPath, "accountspayable.csv"));

            Console.WriteLine("Writing file: " + filename);

            StringBuilder sb = new StringBuilder();

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                TDataBase db = Transaction.DataBaseObj;

                // get all posted or paid ap_documents by their date issued
                string sql =
                    String.Format(
                        "SELECT * FROM PUB_{0} " +
                        "WHERE {1} = {2} AND " +
                        "({3} = '{4}' OR {3} = '{5}' OR {3} = '{6}') AND " +
                        "{7} >= ? AND {7} <= ?",
                        AApDocumentTable.GetTableDBName(),
                        AApDocumentTable.GetLedgerNumberDBName(),
                        ALedgerNumber,
                        AApDocumentTable.GetDocumentStatusDBName(),
                        MFinanceConstants.AP_DOCUMENT_POSTED,
                        MFinanceConstants.AP_DOCUMENT_PARTIALLY_PAID,
                        MFinanceConstants.AP_DOCUMENT_PAID,
                        AApDocumentTable.GetDateIssuedDBName());

                List <OdbcParameter> Parameters = new List <OdbcParameter>();
                OdbcParameter param             = new OdbcParameter("startdate", OdbcType.DateTime);
                param.Value = TAccountingPeriodsWebConnector.GetPeriodStartDate(ALedgerNumber, AFinancialYear, 0, 1);
                Parameters.Add(param);
                param = new OdbcParameter("enddate", OdbcType.DateTime);
                //TODO: Calendar vs Financial Date Handling - Check if this should use financial year start/end and not assume calendar
                param.Value = TAccountingPeriodsWebConnector.GetPeriodEndDate(ALedgerNumber, AFinancialYear, 0, 12);
                Parameters.Add(param);

                AApDocumentTable apDocuments = new AApDocumentTable();
                db.SelectDT(apDocuments, sql, Transaction, Parameters.ToArray(), 0, 0);

                // get all ap details
                sql =
                    String.Format(
                        "SELECT Detail.* FROM PUB_{0} AS Doc, PUB_{8} AS Detail " +
                        "WHERE Doc.{1} = {2} AND " +
                        "({3} = '{4}' OR {3} = '{5}' OR {3} = '{6}') AND " +
                        "{7} >= ? AND {7} <= ? AND " +
                        "Detail.{1} = Doc.{1} AND Detail.{9} = Doc.{9} AND " +
                        "Detail.{10} IN ({11})",
                        AApDocumentTable.GetTableDBName(),
                        AApDocumentTable.GetLedgerNumberDBName(),
                        ALedgerNumber,
                        AApDocumentTable.GetDocumentStatusDBName(),
                        MFinanceConstants.AP_DOCUMENT_POSTED,
                        MFinanceConstants.AP_DOCUMENT_PARTIALLY_PAID,
                        MFinanceConstants.AP_DOCUMENT_PAID,
                        AApDocumentTable.GetDateIssuedDBName(),
                        AApDocumentDetailTable.GetTableDBName(),
                        AApDocumentTable.GetApDocumentIdDBName(),
                        AApDocumentDetailTable.GetCostCentreCodeDBName(),
                        "'" + ACostCentres.Replace(",", "','") + "'");

                AApDocumentDetailTable apDetails = new AApDocumentDetailTable();
                db.SelectDT(apDetails, sql, Transaction, Parameters.ToArray(), 0, 0);

                apDetails.DefaultView.Sort = AApDocumentDetailTable.GetApDocumentIdDBName();

                // get all ap payments
                sql =
                    String.Format(
                        "SELECT DP.{0}, DP.{1}, P.{2} AS {3}, DP.{7}, DP.{15} FROM PUB_{4} AS Doc, PUB_{5} AS DP, PUB_{6} AS P " +
                        "WHERE Doc.{7} = {8} AND " +
                        "({9} = '{10}' OR {9} = '{11}' OR {9} = '{12}') AND " +
                        "{13} >= ? AND {13} <= ? AND " +
                        "DP.{7} = Doc.{7} AND DP.{14} = Doc.{14} AND " +
                        "P.{7} = Doc.{7} AND P.{15} = DP.{15}",

                        AApDocumentPaymentTable.GetApDocumentIdDBName(),
                        AApDocumentPaymentTable.GetAmountDBName(),
                        AApPaymentTable.GetPaymentDateDBName(),
                        AApDocumentPaymentTable.GetDateCreatedDBName(),
                        AApDocumentTable.GetTableDBName(),
                        AApDocumentPaymentTable.GetTableDBName(),
                        AApPaymentTable.GetTableDBName(),

                        AApDocumentTable.GetLedgerNumberDBName(),
                        ALedgerNumber,
                        AApDocumentTable.GetDocumentStatusDBName(),
                        MFinanceConstants.AP_DOCUMENT_POSTED,
                        MFinanceConstants.AP_DOCUMENT_PARTIALLY_PAID,
                        MFinanceConstants.AP_DOCUMENT_PAID,
                        AApDocumentTable.GetDateIssuedDBName(),

                        AApDocumentTable.GetApDocumentIdDBName(),
                        AApPaymentTable.GetPaymentNumberDBName());

                AApDocumentPaymentTable apPayments = new AApDocumentPaymentTable();
                db.SelectDT(apPayments, sql, Transaction, Parameters.ToArray(), 0, 0);

                apPayments.DefaultView.Sort = AApDocumentPaymentTable.GetApDocumentIdDBName();

                // get the analysis attributes for the taxes
                sql =
                    String.Format(
                        "SELECT Attrib.* FROM PUB_{0} AS Doc, PUB_{8} AS Attrib " +
                        "WHERE Doc.{1} = {2} AND " +
                        "({3} = '{4}' OR {3} = '{5}' OR {3} = '{6}') AND " +
                        "{7} >= ? AND {7} <= ? AND " +
                        "Attrib.{1} = Doc.{1} AND Attrib.{9} = Doc.{9}",
                        AApDocumentTable.GetTableDBName(),
                        AApDocumentTable.GetLedgerNumberDBName(),
                        ALedgerNumber,
                        AApDocumentTable.GetDocumentStatusDBName(),
                        MFinanceConstants.AP_DOCUMENT_POSTED,
                        MFinanceConstants.AP_DOCUMENT_PARTIALLY_PAID,
                        MFinanceConstants.AP_DOCUMENT_PAID,
                        AApDocumentTable.GetDateIssuedDBName(),
                        AApAnalAttribTable.GetTableDBName(),
                        AApDocumentTable.GetApDocumentIdDBName());

                AApAnalAttribTable apAttrib = new AApAnalAttribTable();
                db.SelectDT(apAttrib, sql, Transaction, Parameters.ToArray(), 0, 0);

                apAttrib.DefaultView.Sort = AApAnalAttribTable.GetApDocumentIdDBName() + "," + AApAnalAttribTable.GetDetailNumberDBName();

                // get the supplier name
                sql =
                    String.Format(
                        "SELECT DISTINCT p.* FROM PUB_{0} AS Doc, PUB_{8} AS p " +
                        "WHERE Doc.{1} = {2} AND " +
                        "({3} = '{4}' OR {3} = '{5}' OR {3} = '{6}') AND " +
                        "{7} >= ? AND {7} <= ? AND " +
                        "p.{9} = Doc.{10}",
                        AApDocumentTable.GetTableDBName(),
                        AApDocumentTable.GetLedgerNumberDBName(),
                        ALedgerNumber,
                        AApDocumentTable.GetDocumentStatusDBName(),
                        MFinanceConstants.AP_DOCUMENT_POSTED,
                        MFinanceConstants.AP_DOCUMENT_PARTIALLY_PAID,
                        MFinanceConstants.AP_DOCUMENT_PAID,
                        AApDocumentTable.GetDateIssuedDBName(),
                        PPartnerTable.GetTableDBName(),
                        PPartnerTable.GetPartnerKeyDBName(),
                        AApDocumentTable.GetPartnerKeyDBName());

                PPartnerTable suppliers = new PPartnerTable();
                db.SelectDT(suppliers, sql, Transaction, Parameters.ToArray(), 0, 0);

                foreach (AApDocumentRow doc in apDocuments.Rows)
                {
                    PPartnerRow supplier = (PPartnerRow)suppliers.Rows.Find(doc.PartnerKey);

                    DataRowView[] detailsRV = apDetails.DefaultView.FindRows(doc.ApDocumentId);

                    foreach (DataRowView rv in detailsRV)
                    {
                        AApDocumentDetailRow detail = (AApDocumentDetailRow)rv.Row;

                        if (doc.CreditNoteFlag)
                        {
                            detail.Amount *= -1.0m;
                        }

                        DataRowView[] payments = apPayments.DefaultView.FindRows(doc.ApDocumentId);

                        string DatePaid = string.Empty;

                        if (payments.Length > 1)
                        {
                            DatePaid = "Several Payments: ";

                            foreach (DataRowView rvPayment in payments)
                            {
                                AApDocumentPaymentRow payment = ((AApDocumentPaymentRow)rvPayment.Row);
                                DatePaid += payment.DateCreated.Value.ToString("yyyyMMdd") + " ";
                                DatePaid += payment.PaymentNumber.ToString() + "; ";
                            }

                            // for gdpdu, only write dates to this column
                            DatePaid = string.Empty;
                        }
                        else if (payments.Length == 1)
                        {
                            AApDocumentPaymentRow payment = ((AApDocumentPaymentRow)payments[0].Row);
                            DatePaid = payment.DateCreated.Value.ToString("yyyyMMdd");
                        }

                        sb.Append(StringHelper.StrMerge(
                                      new string[] {
                            doc.ApNumber.ToString(),
                            detail.DetailNumber.ToString(),
                            doc.DateIssued.ToString("yyyyMMdd"),
                            DatePaid,
                            doc.PartnerKey.ToString(),
                            supplier.PartnerShortName,
                            detail.CostCentreCode,
                            detail.AccountCode,
                            String.Format("{0:N}", detail.Amount),
                            detail.Narrative
                        }, ACSVSeparator));
                        sb.Append(ANewLine);
                    }
                }
            });

            StreamWriter sw = new StreamWriter(filename, false, Encoding.GetEncoding(1252));

            sw.Write(sb.ToString());
            sw.Close();
        }
Esempio n. 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["OrderList"] != null)
            {
                //public JavaScriptSerializer javaSerial = new JavaScriptSerializer();
                //HttpContext.Current.Session["OrderList"] = orders;
                orderlst = ((OrderList)HttpContext.Current.Session["OrderList"]).orders.ToArray();

                //foreach (var itm in orderlst)
                //{
                //    itm.Order.OrderDate = itm.Order.OrderDate.Value.Date;
                //}
                if (orderlst.Length > 0)
                {
                    txtPinCode.Value    = orderlst[0].Order.pincode.ToString();
                    txtPinCode.Disabled = true;
                }
            }


            //if (Session["USER"] != null)
            //{
            loggiedIn    = CommanAction.GetSession().UserId;
            minDateAdmin = (CommanAction.GetSession().UserType == "N") ? 3 : 3;    //4 : 0;

            //If requst order from tomorrow start
            if (Session["ORDERFROMTOMORROW"] != null)
            {
                DateTime serverTime = DateTime.Now;
                DateTime utcTime    = serverTime.ToUniversalTime();
                // convert it to Utc using timezone setting of server computer
                TimeZoneInfo tzi       = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                DateTime     localTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, tzi);

                string date = Session["ORDERFROMTOMORROW"].ToString().Trim();
                int    dd   = Convert.ToInt32(date.ToString().Substring(0, 2)) / 2;
                int    mm   = Convert.ToInt32(date.ToString().Substring(2, 2)) / 2;
                int    yy   = Convert.ToInt32(date.ToString().Substring(4, 2)) / 2;

                if ((dd.ToString().PadLeft(2, '0') + mm.ToString().PadLeft(2, '0') + yy.ToString().PadLeft(2, '0')) == localTime.ToString("ddMMyy"))
                {
                    minDateAdmin = 3;
                }
            }
            else
            {
                var zone                = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                var timeInIndia         = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, zone);
                var timeInIndiaAsString = timeInIndia.ToString("hh:mm tt", CultureInfo.InvariantCulture);

                //start from 1 PM
                if (timeInIndia.Hour > 12 && timeInIndiaAsString.Contains("PM"))
                {
                    minDateAdmin = 2;
                }
                else
                {
                    minDateAdmin = 3;
                }
            }
            //If requst order from tomorrow end


            //}

            var item = Page.RouteData.Values["itm"] as string;
            var il   = Page.RouteData.Values["il"] as string;

            if (!string.IsNullOrEmpty(Request.QueryString["OrderRqst"]))
            {
                RenewRequest = DBAccess.GetOrderedItemNonCust(Convert.ToInt32(Request.QueryString["OrderRqst"])).ToString();
            }

            if (!string.IsNullOrEmpty(il))
            {
                IsLunch = (il.ToUpper() == "LUNCH");
            }


            if (!IsPostBack)
            {
                SetHoidays();
                BindLocation();
                SetItems();

                SetConfig();
            }
        }
Esempio n. 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PushMsgs msgs = new PushMsgs(this.FK_Flow);
            var      msg  = msgs.GetEntityByKey(PushMsgAttr.FK_Event, this.Event, PushMsgAttr.FK_Node, int.Parse(this.NodeID)) as PushMsg;

            if (msg == null)
            {
                msg          = new PushMsg();
                msg.FK_Event = this.Event;
                msg.FK_Node  = int.Parse(this.NodeID);
            }

            if (!string.IsNullOrWhiteSpace(this.ThePushWay))
            {
                if (this.ThePushWay != msg.PushWay.ToString())
                {
                    msg.PushDoc = string.Empty;
                    msg.Tag     = string.Empty;
                }

                msg.PushWay = int.Parse(this.ThePushWay);
            }

            this.Pub1.AddTable("class='Table' cellspacing='1' cellpadding='1' border='1' style='width:100%'");

            this.Pub1.AddTR();
            this.Pub1.AddTD("style='width:100px'", "推送设置方式:");
            var ddl = new DDL();

            ddl.BindSysEnum(PushMsgAttr.PushWay);
            ddl.ID = "DDL_" + PushMsgAttr.PushWay;
            ddl.SetSelectItem((int)msg.PushWay);
            ddl.AutoPostBack          = true;
            ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
            this.Pub1.AddTD(ddl);
            this.Pub1.AddTREnd();

            switch ((PushWay)msg.PushWay)
            {
            case PushWay.ByParas:

                #region  照系统指定参数

                Pub1.AddTR();
                Pub1.AddTD("输入参数名:");
                Pub1.AddTDBegin();

                var rad = new RadioBtn();
                rad.GroupName = "Para";
                rad.ID        = "RB_0";
                rad.Text      = "系统参数";
                rad.Checked   = msg.PushDoc == "0";

                Pub1.Add(rad);

                var tb = new TB();
                tb.ID = "TB_" + PushMsgAttr.Tag;

                if (msg.PushDoc == "0")
                {
                    tb.Text = msg.Tag;
                }
                else
                {
                    tb.Text = "NoticeTo";
                }

                Pub1.Add(tb);

                Pub1.Add("&nbsp;默认为NoticeTo");
                Pub1.AddBR();

                rad           = new RadioBtn();
                rad.GroupName = "Para";
                rad.ID        = "RB_1";
                rad.Text      = "表单字段参数";
                rad.Checked   = msg.PushDoc == "1";

                Pub1.Add(rad);

                MapAttrs attrs = new MapAttrs();
                attrs.Retrieve(MapAttrAttr.FK_MapData, "ND" + this.NodeID);

                MapAttrs attrNs = new MapAttrs();

                foreach (MapAttr attr in attrs)
                {
                    if (attr.IsBigDoc)
                    {
                        continue;
                    }

                    switch (attr.KeyOfEn)
                    {
                    case "Title":
                    case "FK_Emp":
                    case "MyNum":
                    case "FK_NY":
                    case WorkAttr.Emps:
                    case WorkAttr.OID:
                    case StartWorkAttr.Rec:
                    case StartWorkAttr.FID:
                        continue;

                    default:
                        break;
                    }

                    attrNs.AddEntity(attr);
                }

                ddl    = new DDL();
                ddl.ID = "DDL_" + PushMsgAttr.Tag;
                ddl.BindEntities(attrNs, MapAttrAttr.MyPK, MapAttrAttr.Name);
                ddl.AutoPostBack = false;

                if (msg.PushDoc == "1")
                {
                    ddl.SetSelectItem(msg.Tag);
                }

                Pub1.Add(ddl);
                Pub1.AddTREnd();
                #endregion

                break;

            case PushWay.NodeWorker:

                #region  照指定结点的工作人员

                Pub1.AddTR();
                Pub1.AddTDBegin("colspan='2'");

                Pub1.Add("请选择要推送到的节点工作人员:<br />");
                Nodes    nds = new Nodes(this.FK_Flow);
                CheckBox cb  = null;

                foreach (BP.WF.Node nd in nds)
                {
                    if (nd.NodeID == int.Parse(this.NodeID))
                    {
                        continue;
                    }

                    cb         = new CheckBox();
                    cb.ID      = "CB_" + nd.NodeID;
                    cb.Text    = nd.NodeID + " &nbsp;" + nd.Name;
                    cb.Checked = msg.PushDoc.Contains("@" + nd.NodeID + "@");
                    Pub1.Add(cb);
                    Pub1.AddBR();
                }

                Pub1.AddTDEnd();
                Pub1.AddTREnd();
                #endregion

                break;

            case PushWay.SpecDepts:

                #region  照指定的部门

                Pub1.AddTR();
                Pub1.AddTDBegin("colspan='2'");

                this.Pub1.AddTable("class='Table' cellSpacing='1' cellPadding='1'  border='1' style='width:100%'");
                this.Pub1.AddTR();
                this.Pub1.AddTD("colspan='3' class='GroupTitle'", "部门选择");
                this.Pub1.AddTREnd();

                //NodeDepts ndepts = new NodeDepts(int.Parse(this.NodeID));
                Depts depts = new Depts();
                depts.RetrieveAll();
                int i = 0;

                //foreach (NodeDept dept in ndepts)
                foreach (Dept dept in depts)
                {
                    i++;

                    if (i == 4)
                    {
                        i = 1;
                    }

                    if (i == 1)
                    {
                        Pub1.AddTR();
                    }

                    cb = new CheckBox();
                    //cb.ID = "CB_" + dept.FK_Dept;
                    //cb.Text = (depts.GetEntityByKey(dept.FK_Dept) as Dept).Name;
                    cb.ID   = "CB_" + dept.No;
                    cb.Text = dept.Name;

                    //if (msg.PushDoc.Contains("@" + dept.FK_Dept + "@"))
                    if (msg.PushDoc.Contains("@" + dept.No + "@"))
                    {
                        cb.Checked = true;
                    }

                    this.Pub1.AddTD(cb);

                    if (i == 3)
                    {
                        Pub1.AddTREnd();
                    }
                }

                switch (i)
                {
                case 1:
                    Pub1.AddTD();
                    Pub1.AddTD();
                    Pub1.AddTREnd();
                    break;

                case 2:
                    Pub1.AddTD();
                    Pub1.AddTREnd();
                    break;

                default:
                    break;
                }

                this.Pub1.AddTableEnd();
                Pub1.AddTDEnd();
                Pub1.AddTREnd();
                #endregion

                break;

            case PushWay.SpecEmps:

                #region  照指定的人员

                Pub1.AddTR();
                //Pub1.AddTDBegin("colspan='2'");

                Pub1.AddTD("选择人员:");
                Pub1.AddTDBegin();

                tb          = new TB();
                tb.ID       = "TB_Users";
                tb.TextMode = TextBoxMode.MultiLine;
                tb.Style.Add("width", "99%");
                tb.Rows     = 4;
                tb.ReadOnly = true;

                var hf = new HiddenField();
                hf.ID = "HID_Users";

                //加载已经选择的人员
                if (!string.IsNullOrWhiteSpace(msg.PushDoc))
                {
                    hf.Value = msg.PushDoc.Replace("@@", ",").Trim('@');

                    var emps = new Emps();
                    emps.RetrieveAll();

                    tb.Text =
                        hf.Value.Split(',').Select(o => (emps.GetEntityByKey(o) as Emp).Name).Aggregate(
                            string.Empty, (curr, next) => curr + next + ",").TrimEnd(',');
                }

                Pub1.Add(tb);
                Pub1.Add(hf);
                Pub1.AddBR();
                Pub1.AddBR();

                Pub1.Add(
                    "<a class='easyui-linkbutton' data-options=\"iconCls:'icon-user'\" href='javascript:void(0)' onclick=\"showWin('../Comm/Port/SelectUser_Jq.aspx','" +
                    tb.ClientID + "','" + hf.ClientID + "');\">选择人员...</a>");
                Pub1.AddTDEnd();
                //Pub1.AddTable("class='Table' cellSpacing='1' cellPadding='1'  border='1' style='width:100%'");
                //depts = new Depts();
                //depts.RetrieveAll();
                //var emps = new Emps();
                //emps.RetrieveAll();
                //var empDepts = new EmpDepts();
                //empDepts.RetrieveAll();
                //var nemps = new NodeEmps(int.Parse(this.NodeID));

                //Emp emp = null;

                //foreach (Dept dept in depts)
                //{
                //    this.Pub1.AddTR();
                //    var mycb = new CheckBox();
                //    mycb.Text = dept.Name;
                //    mycb.ID = "CB_D_" + dept.No;
                //    this.Pub1.AddTD("colspan='3' class='GroupTitle'", mycb);
                //    this.Pub1.AddTREnd();

                //    i = 0;
                //    string ctlIDs = "";

                //    foreach (EmpDept ed in empDepts)
                //    {
                //        if (ed.FK_Dept != dept.No)
                //            continue;

                //        //排除非当前结点绑定的人员
                //        if (nemps.GetEntityByKey(NodeEmpAttr.FK_Emp, ed.FK_Emp) == null)
                //            continue;

                //        i++;

                //        if (i == 4)
                //            i = 1;

                //        if (i == 1)
                //            Pub1.AddTR();

                //        emp = emps.GetEntityByKey(ed.FK_Emp) as Emp;

                //        cb = new CheckBox();
                //        cb.ID = "CB_E_" + emp.No;
                //        ctlIDs += cb.ID + ",";
                //        cb.Text = emp.Name;
                //        if (msg.PushDoc.Contains("@" + emp.No + "@"))
                //            cb.Checked = true;

                //        Pub1.AddTD(cb);

                //        if (i == 3)
                //            Pub1.AddTREnd();
                //    }

                //    mycb.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";

                //    switch (i)
                //    {
                //        case 1:
                //            Pub1.AddTD();
                //            Pub1.AddTD();
                //            Pub1.AddTREnd();
                //            break;
                //        case 2:
                //            Pub1.AddTD();
                //            Pub1.AddTREnd();
                //            break;
                //        default:
                //            break;
                //    }
                //}

                //Pub1.AddTableEnd();

                //Pub1.AddTDEnd();
                Pub1.AddTREnd();
                #endregion

                break;

            case PushWay.SpecSQL:

                #region  照指定的SQL查询语句

                Pub1.AddTR();

                this.Pub1.AddTDBegin("colspan='2'");
                this.Pub1.Add("SQL查询语句:<br />");
                tb         = new TB();
                tb.ID      = "TB_" + PushMsgAttr.PushDoc;
                tb.Columns = 50;
                tb.Style.Add("width", "99%");
                tb.TextMode = TextBoxMode.MultiLine;
                tb.Rows     = 4;
                tb.Text     = msg.PushDoc;
                this.Pub1.Add(tb);
                this.Pub1.AddTDEnd();
                Pub1.AddTREnd();
                #endregion

                break;

            case PushWay.SpecStations:

                #region  照指定的岗位

                Pub1.AddTR();
                Pub1.AddTDBegin("colspan='2'");

                /*BPM 模式*/
                BP.GPM.StationTypes tps = new BP.GPM.StationTypes();
                tps.RetrieveAll();

                BP.GPM.Stations sts = new BP.GPM.Stations();
                sts.RetrieveAll();

                string    sql = "SELECT No,Name FROM Port_Station WHERE FK_StationType NOT IN (SELECT No FROM Port_StationType)";
                DataTable dt  = DBAccess.RunSQLReturnTable(sql);
                if (dt.Rows.Count != 0)
                {
                    if (tps.Count == 0)
                    {
                        var stp = new BP.GPM.StationType {
                            No = "01", Name = "普通岗"
                        };
                        stp.Save();

                        tps.AddEntity(stp);
                    }

                    //更新所有对不上岗位类型的岗位,岗位类型为01或第一个
                    foreach (BP.GPM.Station st in sts)
                    {
                        st.FK_StationType = tps[0].No;
                        st.Update();
                    }
                }

                this.Pub1.AddTable("class='Table' cellSpacing='0' cellPadding='0'  border='0' style='width:100%'");

                foreach (BP.GPM.StationType tp in tps)
                {
                    this.Pub1.AddTR();
                    CheckBox mycb = new CheckBox();
                    mycb.Text = tp.Name;
                    mycb.ID   = "CB_ST_" + tp.No;
                    this.Pub1.AddTD("colspan='3' class='GroupTitle'", mycb);
                    this.Pub1.AddTREnd();

                    i = 0;
                    string ctlIDs = "";

                    foreach (BP.GPM.Station st in sts)
                    {
                        if (st.FK_StationType != tp.No)
                        {
                            continue;
                        }

                        i++;

                        if (i == 4)
                        {
                            i = 1;
                        }

                        if (i == 1)
                        {
                            Pub1.AddTR();
                        }

                        cb      = new CheckBox();
                        cb.ID   = "CB_S_" + st.No;
                        ctlIDs += cb.ID + ",";
                        cb.Text = st.Name;

                        if (msg.PushDoc.Contains("@" + st.No + "@"))
                        {
                            cb.Checked = true;
                        }

                        this.Pub1.AddTD(cb);

                        if (i == 3)
                        {
                            Pub1.AddTREnd();
                        }
                    }

                    mycb.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";

                    switch (i)
                    {
                    case 1:
                        Pub1.AddTD();
                        Pub1.AddTD();
                        Pub1.AddTREnd();
                        break;

                    case 2:
                        Pub1.AddTD();
                        Pub1.AddTREnd();
                        break;

                    default:
                        break;
                    }
                }

                this.Pub1.AddTableEnd();



                #region 原逻辑,只考虑了一种模式,停用
                //Pub1.AddTable("class='Table' cellSpacing='1' cellPadding='1'  border='1' style='width:100%'");
                //SysEnums ses = new SysEnums("StaGrade");
                //Stations sts = new Stations();
                //NodeStations nsts = new NodeStations(int.Parse(this.NodeID));
                //sts.RetrieveAll();

                //foreach (SysEnum se in ses)
                //{
                //    this.Pub1.AddTR();
                //    var mycb = new CheckBox();
                //    mycb.Text = se.Lab;
                //    mycb.ID = "CB_SG_" + se.IntKey;
                //    this.Pub1.AddTD("colspan=3 class='GroupTitle'", mycb);
                //    this.Pub1.AddTREnd();

                //    i = 0;
                //    string ctlIDs = "";

                //    foreach (Station st in sts)
                //    {
                //        if (st.StaGrade != se.IntKey)
                //            continue;

                //        //排除非当前结点的岗位
                //        if (nsts.GetEntityByKey(NodeStationAttr.FK_Station, st.No) == null)
                //            continue;

                //        i++;

                //        if (i == 4)
                //            i = 1;

                //        if (i == 1)
                //            Pub1.AddTR();

                //        cb = new CheckBox();
                //        cb.ID = "CB_S_" + st.No;
                //        ctlIDs += cb.ID + ",";
                //        cb.Text = st.Name;
                //        if (msg.PushDoc.Contains("@" + st.No + "@"))
                //            cb.Checked = true;

                //        Pub1.AddTD(cb);

                //        if (i == 3)
                //            Pub1.AddTREnd();
                //    }

                //    mycb.Attributes["onclick"] = "SetSelected(this,'" + ctlIDs + "')";

                //    switch (i)
                //    {
                //        case 1:
                //            Pub1.AddTD();
                //            Pub1.AddTD();
                //            Pub1.AddTREnd();
                //            break;
                //        case 2:
                //            Pub1.AddTD();
                //            Pub1.AddTREnd();
                //            break;
                //        default:
                //            break;
                //    }
                //}
                //Pub1.AddTableEnd();
                #endregion

                Pub1.AddTDEnd();
                Pub1.AddTREnd();
                #endregion

                break;
            }

            Pub1.AddTableEnd();

            Pub1.AddBR();
            Pub1.AddSpace(1);

            var btn = new LinkBtn(false, NamesOfBtn.Save, "保存");
            btn.Click += new EventHandler(btn_Click);
            Pub1.Add(btn);

            if (!string.IsNullOrWhiteSpace(msg.MyPK))
            {
                Pub1.AddSpace(1);
                btn        = new LinkBtn(false, NamesOfBtn.Delete, "删除");
                btn.Click += new EventHandler(btn_Delete_Click);
                btn.Attributes["onclick"] = "return confirm('你确定要删除此消息推送设置吗?');";
                Pub1.Add(btn);
            }
        }
Esempio n. 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="GroupName"></param>
 /// <returns></returns>
 public static bool DeleteGroupID(string GroupID)
 {
     return(DBAccess.GetRelation().ExecuteNonQuery("delete from KPI_Group where GroupID='" + GroupID + "'") > 0);
 }
Esempio n. 24
0
        /// <summary>
        /// 部门编号为GUID模式下的发送
        /// </summary>
        public override void Do()
        {
            //重新装载演示环境.
            ReLoadDept();

            #region 把数据换成guid模式.
            BP.Port.Depts depts = new Port.Depts();
            depts.RetrieveAll();

            string guid1 = "";
            foreach (BP.Port.Dept item in depts)
            {
                string deptNo = item.No;
                string guid   = DBAccess.GenerGUID();
                if (item.No == "1")
                {
                    guid1 = guid;
                }

                sql = "UPDATE Port_Dept SET No='" + guid + "' WHERE No='" + deptNo + "'";
                DBAccess.RunSQL(sql);

                sql = "UPDATE Port_Emp SET FK_Dept='" + guid + "' WHERE FK_Dept='" + deptNo + "'";
                DBAccess.RunSQL(sql);

                sql = "UPDATE Port_EmpDept SET FK_Dept='" + guid + "' WHERE FK_Dept='" + deptNo + "'";
                DBAccess.RunSQL(sql);
            }

            sql = "UPDATE Port_Dept SET ParentNo='" + guid1 + "' WHERE ParentNo='1'";
            DBAccess.RunSQL(sql);
            #endregion

            string err = "";
            Flow   fl  = new Flow("023");
            fl.CheckRpt();
            fl.DoDelData();

            BP.SystemConfig.DoClearCash_del();

            err = "@第Send023 错误.";
            Send023 se = new Send023();
            se.Do();

            fl = new Flow("024");
            fl.CheckRpt();
            err = "@第Send024 错误.";
            Send024 s2e = new Send024();
            s2e.Do();


            fl = new Flow("005");
            fl.CheckRpt();
            err = "@第Send005 错误.";
            Send005 s5 = new Send005();
            s5.Do();


            //重新装载演示环境.
            ReLoadDept();
        }
Esempio n. 25
0
        /// <summary>
        /// 执行事件,事件标记是 EventList.
        /// </summary>
        /// <param name="dotype">执行类型</param>
        /// <param name="en">数据实体</param>
        /// <param name="atPara">特殊的参数格式@key=value 方式.</param>
        /// <returns></returns>
        private string _DoEventNode(string dotype, Entity en, string atPara)
        {
            if (this.Count == 0)
            {
                return(null);
            }

            FrmEvent nev = this.GetEntityByKey(FrmEventAttr.FK_Event, dotype) as FrmEvent;

            if (nev == null || nev.HisDoType == EventDoType.Disable)
            {
                return(null);
            }

            string doc = nev.DoDoc.Trim();

            if (doc == null || doc == "")
            {
                return(null);
            }

            #region 处理执行内容
            Attrs  attrs  = en.EnMap.Attrs;
            string MsgOK  = "";
            string MsgErr = "";
            foreach (Attr attr in attrs)
            {
                if (doc.Contains("@" + attr.Key) == false)
                {
                    continue;
                }
                if (attr.MyDataType == DataType.AppString ||
                    attr.MyDataType == DataType.AppDateTime ||
                    attr.MyDataType == DataType.AppDate)
                {
                    doc = doc.Replace("@" + attr.Key, "'" + en.GetValStrByKey(attr.Key) + "'");
                }
                else
                {
                    doc = doc.Replace("@" + attr.Key, en.GetValStrByKey(attr.Key));
                }
            }

            doc = doc.Replace("~", "'");
            doc = doc.Replace("@WebUser.No", BP.Web.WebUser.No);
            doc = doc.Replace("@WebUser.Name", BP.Web.WebUser.Name);
            doc = doc.Replace("@WebUser.FK_Dept", BP.Web.WebUser.FK_Dept);
            doc = doc.Replace("@FK_Node", nev.FK_MapData.Replace("ND", ""));
            doc = doc.Replace("@FK_MapData", nev.FK_MapData);
            doc = doc.Replace("@WorkID", en.GetValStrByKey("OID", "@WorkID"));

            //SDK表单上服务器地址,应用到使用ccflow的时候使用的是sdk表单,该表单会存储在其他的服务器上.
            doc = doc.Replace("@SDKFromServHost", SystemConfig.AppSettings["SDKFromServHost"]);



            if (System.Web.HttpContext.Current != null)
            {
                /*如果是 bs 系统, 有可能参数来自于url ,就用url的参数替换它们 .*/
                string url = BP.Sys.Glo.Request.RawUrl;
                if (url.IndexOf('?') != -1)
                {
                    url = url.Substring(url.IndexOf('?'));
                }

                string[] paras = url.Split('&');
                foreach (string s in paras)
                {
                    if (doc.Contains("@" + s) == false)
                    {
                        continue;
                    }

                    string[] mys = s.Split('=');
                    if (doc.Contains("@" + mys[0]) == false)
                    {
                        continue;
                    }
                    doc = doc.Replace("@" + mys[0], mys[1]);
                }
            }

            if (nev.HisDoType == EventDoType.URLOfSelf)
            {
                if (doc.Contains("?") == false)
                {
                    doc += "?1=2";
                }

                doc += "&UserNo=" + WebUser.No;
                doc += "&SID=" + WebUser.SID;
                doc += "&FK_Dept=" + WebUser.FK_Dept;
                // doc += "&FK_Unit=" + WebUser.FK_Unit;
                doc += "&OID=" + en.PKVal;

                if (SystemConfig.IsBSsystem)
                {
                    /*是bs系统,并且是url参数执行类型.*/
                    string url = BP.Sys.Glo.Request.RawUrl;
                    if (url.IndexOf('?') != -1)
                    {
                        url = url.Substring(url.IndexOf('?'));
                    }
                    string[] paras = url.Split('&');
                    foreach (string s in paras)
                    {
                        if (doc.Contains(s))
                        {
                            continue;
                        }
                        doc += "&" + s;
                    }
                    doc = doc.Replace("&?", "&");
                }

                if (SystemConfig.IsBSsystem == false)
                {
                    /*非bs模式下调用,比如在cs模式下调用它,它就取不到参数. */
                }

                if (doc.StartsWith("http") == false)
                {
                    /*如果没有绝对路径 */
                    if (SystemConfig.IsBSsystem)
                    {
                        /*在cs模式下自动获取*/
                        string host = BP.Sys.Glo.Request.Url.Host;
                        if (doc.Contains("@AppPath"))
                        {
                            doc = doc.Replace("@AppPath", "http://" + host + BP.Sys.Glo.Request.ApplicationPath);
                        }
                        else
                        {
                            doc = "http://" + BP.Sys.Glo.Request.Url.Authority + doc;
                        }
                    }

                    if (SystemConfig.IsBSsystem == false)
                    {
                        /*在cs模式下它的baseurl 从web.config中获取.*/
                        string cfgBaseUrl = SystemConfig.AppSettings["BaseUrl"];
                        if (string.IsNullOrEmpty(cfgBaseUrl))
                        {
                            string err = "调用url失败:没有在web.config中配置BaseUrl,导致url事件不能被执行.";
                            Log.DefaultLogWriteLineError(err);
                            throw new Exception(err);
                        }
                        doc = cfgBaseUrl + doc;
                    }
                }

                //增加上系统约定的参数.
                doc += "&EntityName=" + en.ToString() + "&EntityPK=" + en.PK + "&EntityPKVal=" + en.PKVal + "&FK_Event=" + nev.MyPK;
            }
            #endregion 处理执行内容

            if (atPara != null && doc.Contains("@") == true)
            {
                AtPara ap = new AtPara(atPara);
                foreach (string s in ap.HisHT.Keys)
                {
                    doc = doc.Replace("@" + s, ap.GetValStrByKey(s));
                }
            }

            if (dotype == FrmEventList.FrmLoadBefore)
            {
                en.Retrieve(); /*如果不执行,就会造成实体的数据与查询的数据不一致.*/
            }
            switch (nev.HisDoType)
            {
            //case EventDoType.SP:
            //    try
            //    {
            //        Paras ps = new Paras();
            //        DBAccess.RunSP(doc, ps);
            //        return nev.MsgOK(en);
            //    }
            //    catch (Exception ex)
            //    {
            //        throw new Exception(nev.MsgError(en) + " Error:" + ex.Message);
            //    }
            //    break;
            case EventDoType.SP:
            case EventDoType.SQL:
                try
                {
                    // 允许执行带有GO的sql.
                    DBAccess.RunSQLs(doc);
                    return(nev.MsgOK(en));
                }
                catch (Exception ex)
                {
                    throw new Exception(nev.MsgError(en) + " Error:" + ex.Message);
                }
                break;

            case EventDoType.URLOfSelf:
                string myURL = doc.Clone() as string;
                if (myURL.Contains("http") == false)
                {
                    if (SystemConfig.IsBSsystem)
                    {
                        string host = BP.Sys.Glo.Request.Url.Host;
                        if (myURL.Contains("@AppPath"))
                        {
                            myURL = myURL.Replace("@AppPath", "http://" + host + BP.Sys.Glo.Request.ApplicationPath);
                        }
                        else
                        {
                            myURL = "http://" + BP.Sys.Glo.Request.Url.Authority + myURL;
                        }
                    }
                    else
                    {
                        string cfgBaseUrl = SystemConfig.AppSettings["BaseUrl"];
                        if (string.IsNullOrEmpty(cfgBaseUrl))
                        {
                            string err = "调用url失败:没有在web.config中配置BaseUrl,导致url事件不能被执行.";
                            Log.DefaultLogWriteLineError(err);
                            throw new Exception(err);
                        }
                        myURL = cfgBaseUrl + myURL;
                    }
                }
                myURL = myURL.Replace("@SDKFromServHost", SystemConfig.AppSettings["SDKFromServHost"]);

                if (myURL.Contains("&FID=") == false && en.Row.ContainsKey("FID") == true)
                {
                    string str = en.Row["FID"].ToString();
                    myURL = myURL + "&FID=" + str;
                }

                if (myURL.Contains("&FK_Flow=") == false && en.Row.ContainsKey("FK_Flow") == true)
                {
                    string str = en.Row["FK_Flow"].ToString();
                    myURL = myURL + "&FK_Flow=" + str;
                }

                if (myURL.Contains("&WorkID=") == false && en.Row.ContainsKey("WorkID") == true)
                {
                    string str = en.Row["WorkID"].ToString();
                    myURL = myURL + "&WorkID=" + str;
                }

                try
                {
                    Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
                    string   text   = DataType.ReadURLContext(myURL, 600000, encode);
                    if (text == null)
                    {
                        throw new Exception("@流程设计错误,执行的url错误:" + myURL + ", 返回为null, 请检查url设置是否正确。提示:您可以copy出来此url放到浏览器里看看是否被正确执行。");
                    }

                    if (text != null &&
                        text.Length > 7 &&
                        text.Substring(0, 7).ToLower().Contains("err"))
                    {
                        throw new Exception(text);
                    }

                    if (text == null || text.Trim() == "")
                    {
                        return(null);
                    }
                    return(text);
                }
                catch (Exception ex)
                {
                    throw new Exception("@" + nev.MsgError(en) + " Error:" + ex.Message);
                }
                break;
            //case EventDoType.URLOfSystem:
            //    string hos1t = BP.Sys.Glo.Request.Url.Host;
            //    string url = "http://" + hos1t + BP.Sys.Glo.Request.ApplicationPath + "/DataUser/AppCoder/FrmEventHandle.aspx";
            //    url += "?FK_MapData=" + en.ClassID + "&WebUseNo=" + WebUser.No + "&EventType=" + nev.FK_Event;
            //    foreach (Attr attr in attrs)
            //    {
            //        if (attr.UIIsDoc || attr.IsRefAttr || attr.UIIsReadonly)
            //            continue;
            //        url += "&" + attr.Key + "=" + en.GetValStrByKey(attr.Key);
            //    }

            //    try
            //    {
            //        string text = DataType.ReadURLContext(url, 800, System.Text.Encoding.UTF8);
            //        if (text != null && text.Substring(0, 7).Contains("Err"))
            //            throw new Exception(text);

            //        if (text == null || text.Trim() == "")
            //            return null; // 如果是Null 没有事件配置。
            //        return text;
            //    }
            //    catch (Exception ex)
            //    {
            //        throw new Exception("@" + nev.MsgError(en) + " Error:" + ex.Message);
            //    }
            //    break;
            case EventDoType.EventBase:     //执行事件类.

                // 获取事件类.
                string           evName = doc.Clone() as string;
                BP.Sys.EventBase ev     = null;
                try
                {
                    ev = BP.En.ClassFactory.GetEventBase(evName);
                }
                catch (Exception ex)
                {
                    throw new Exception("@事件名称:" + evName + "拼写错误,或者系统不存在。说明:事件所在的类库必须是以BP.开头,并且类库的BP.xxx.dll。");
                }

                //开始执行.
                try
                {
                    #region 处理整理参数.
                    Row r = en.Row;
                    try
                    {
                        //系统参数.
                        r.Add("FK_MapData", en.ClassID);
                    }
                    catch
                    {
                        r["FK_MapData"] = en.ClassID;
                    }

                    try
                    {
                        r.Add("EventType", nev.FK_Event);
                    }
                    catch
                    {
                        r["EventType"] = nev.FK_Event;
                    }

                    if (atPara != null)
                    {
                        AtPara ap = new AtPara(atPara);
                        foreach (string s in ap.HisHT.Keys)
                        {
                            try
                            {
                                r.Add(s, ap.GetValStrByKey(s));
                            }
                            catch
                            {
                                r[s] = ap.GetValStrByKey(s);
                            }
                        }
                    }

                    if (SystemConfig.IsBSsystem == true)
                    {
                        /*如果是bs系统, 就加入外部url的变量.*/
                        foreach (string key in BP.Sys.Glo.Request.QueryString)
                        {
                            string val = BP.Sys.Glo.Request.QueryString[key];
                            try
                            {
                                r.Add(key, val);
                            }
                            catch
                            {
                                r[key] = val;
                            }
                        }
                    }
                    #endregion 处理整理参数.

                    ev.SysPara = r;
                    ev.HisEn   = en;
                    ev.Do();
                    return(ev.SucessInfo);
                }
                catch (Exception ex)
                {
                    throw new Exception("@执行事件(" + ev.Title + ")期间出现错误:" + ex.Message);
                }
                break;

            default:
                throw new Exception("@no such way." + nev.HisDoType.ToString());
            }
        }
 public override int DirectInsert()
 {
     this.OID = DBAccess.GenerOID();
     return(base.DirectInsert());
 }
Esempio n. 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!User.Identity.IsAuthenticated)
                {
                    Response.Redirect("../Login.aspx", false);
                }
                if (Session["user"] != null)
                {
                    usr = (AppUser)Session["user"];
                }
                else
                {
                    Response.Redirect("../Login.aspx", false);
                    return;
                }
                if (!IsPostBack)
                {
                    Utility.BindBudgetYear(ddlbudyr);
                    Utility.BindDept(ddlDept);
                    Utility.BindBudgetStatus(ddlStatus);
                    lbMsg.Text = "";
                    int      byrID = int.Parse(ddlbudyr.SelectedValue);
                    DBAccess db    = new DBAccess();
                    db.AddParameter("budgetYrId", byrID);
                    rpt    = new ReportParameter[3];
                    rpt[2] = new ReportParameter("status", "1");

                    rpt[1] = new ReportParameter("deptID", "1");
                    rpt[0] = new ReportParameter("budgetYrID", byrID.ToString());
                    if (ddlDept.SelectedValue != "")
                    {
                        rpt[1] = new ReportParameter("deptID", ddlDept.SelectedValue);
                        db.AddParameter("@deptId", int.Parse(ddlDept.SelectedValue));
                    }
                    if (ddlStatus.SelectedValue != "")
                    {
                        rpt[2] = new ReportParameter("status", ddlStatus.SelectedValue);
                        db.AddParameter("@status", int.Parse(ddlStatus.SelectedValue));
                    }
                    DataSet ds = new DataSet();
                    ds = db.ExecuteDataSet("bc_rpt_Capex");

                    ReportDataSource datasource = new
                                                  ReportDataSource("dsBudget",
                                                                   ds.Tables[0]);

                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.SetParameters(rpt);
                    ReportViewer1.LocalReport.DataSources.Add(datasource);

                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        lbMsg.Text = "Sorry, No record found!";
                    }

                    ReportViewer1.LocalReport.Refresh();
                    return;
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 28
0
 //-----------------------------------------------------------------
 public Sites()
 {
     db = new DBAccess(DbConstants.CONNECTION_STRING);
 }
Esempio n. 29
0
        public LoginSessionMonitor()
        {
            DBAccess db = new DBAccess();

            conn = db.conn;
        }
Esempio n. 30
0
 //-----------------------------------------------------------------
 public Sites(string constr)
 {
     db = new DBAccess((constr == "") ? DbConstants.CONNECTION_STRING : constr);
 }
Esempio n. 31
0
        private void createForAllDupsModToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Please select replacement texture (same size)");
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.dds|*.dds";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                byte[] data = File.ReadAllBytes(d.FileName);
                MessageBox.Show("Please select mod save location");
                SaveFileDialog d2 = new SaveFileDialog();
                d2.Filter = "*.DAIMWV|*.DAIMWV";
                if (d2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Mod mod = new Mod();
                    mod.jobs = new List <Mod.ModJob>();
                    Mod.ModJob mj = new Mod.ModJob();
                    mj.type        = 0;
                    mj.bundlePaths = new List <string>();
                    mj.tocPaths    = new List <string>();
                    int  plen = GlobalStuff.FindSetting("gamepath").Length;
                    bool skip = false;
                    for (int i = 0; i < bil.Length; i++)
                    {
                        DBAccess.BundleInformation  buni = bil[i];
                        DBAccess.TextureInformation ti   = new DBAccess.TextureInformation();
                        foreach (DBAccess.TextureInformation t in til)
                        {
                            if (t.bundleIndex == buni.index)
                            {
                                ti = t;
                            }
                        }
                        DBAccess.TOCInformation toci = DBAccess.GetTocInformationByIndex(buni.tocIndex);
                        mj.respath = ti.name;
                        skip       = false;
                        foreach (string p in mj.bundlePaths)
                        {
                            if (p == buni.bundlepath)
                            {
                                skip = true;
                                break;
                            }
                        }
                        if (!skip)
                        {
                            mj.bundlePaths.Add(buni.bundlepath);
                        }
                        string tpath = toci.path.Substring(plen, toci.path.Length - plen);
                        skip = false;
                        foreach (string p in mj.tocPaths)
                        {
                            if (p == tpath)
                            {
                                skip = true;
                                break;
                            }
                        }
                        if (tpath.ToLower().Contains("\\patch\\"))
                        {
                            skip = true;
                        }
                        if (!skip)
                        {
                            mj.tocPaths.Add(tpath);
                        }
                    }
                    MemoryStream m = new MemoryStream();
                    m.Write(data, 0x80, data.Length - 0x80);
                    mj.data = m.ToArray();
                    mod.jobs.Add(mj);
                    mod.Save(d2.FileName);
                    MessageBox.Show("Done.");
                }
            }
        }
Esempio n. 32
0
        public void FetchAllContactsTest()
        {
            DBAccess target = new DBAccess();

            target.FetchAllContacts("(local)", "CONTACT");
        }
Esempio n. 33
0
 public DBUserTest() {
     db = new DBAccess();
     db.Open();
     db.ClearDatabase(); //Clears the database, and initialises it to a test state
 }
        public AdminDeleteParkHistoryMethods()
        {
            DBAccess db = new DBAccess();

            conn = db.conn;
        }
Esempio n. 35
0
    protected void BtSignUp_Click(object sender, EventArgs e)
    {
        string userName = TbName.Text;
        if (string.IsNullOrEmpty(userName))
        {
            LbErrMsg.Text = "请输入【登录用户】!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbName.Focus();
            return;
        }
        Regex reg = new Regex("^\\w+[\\w\\d\\.]*$");
        if (!reg.IsMatch(userName))
        {
            LbErrMsg.Text = "您输入的【登录用户】不合法:登录用户仅能为大小写字母、下划线及英文点号!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbName.Focus();
            return;
        }
        if (!CharUtil.IsValidate(userName, 4, 32))
        {
            LbErrMsg.Text = "【登录用户】字符串长度应在 4 到 32 个字符之间!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbName.Focus();
            return;
        }

        string userPwds = TbPass1.Text;
        if (string.IsNullOrEmpty(userPwds))
        {
            LbErrMsg.Text = "请输入【登录口令】!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbPass1.Focus();
            return;
        }
        if (userPwds.Length < 4)
        {
            LbErrMsg.Text = "【登录口令】字符串长度不能小于 4 位!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbPass1.Focus();
            return;
        }
        if (userPwds != TbPass2.Text)
        {
            LbErrMsg.Text = "您两次输入的口令不一致,请重新输入!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbPass1.Text = "";
            TbPass2.Text = "";
            TbPass1.Focus();
            return;
        }

        string userMail = TbMail.Text;
        if (!CharUtil.IsValidate(userMail))
        {
            LbErrMsg.Text = "请输入【电子邮件】!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbMail.Focus();
            return;
        }
        reg = new Regex("^\\w+[\\w\\.]*@\\w+(\\.[\\w\\.]+)+$");
        if (!reg.IsMatch(userMail))
        {
            LbErrMsg.Text = "您输入的【电子邮件】格式不正确,正确格式为:[email protected]!";
            TrErrMsg.Attributes.Add("style", "display:;");
            TbMail.Focus();
            return;
        }

        // 用户名重复检测
        DBAccess dba = new DBAccess();
        dba.AddTable(DBConst.C3010400);
        dba.AddColumn(DBConst.C3010405);
        dba.AddWhere(DBConst.C3010405, userName);
        DataTable dv = dba.ExecuteSelect();
        if (dv != null && dv.Rows.Count > 0)
        {
            LbErrMsg.Text = string.Format("用户名 {0} 已存在,请选择其它用户名!", userName);
            TrErrMsg.Attributes.Add("style", "display:;");
            TbName.Focus();
            return;
        }

        UserModel userModel = UserModel.Current(Session);
        if (IMsg.MSG_SIGNUP_SUCCESS == userModel.WpSignUp(userName, userPwds, userMail))
        {
            tr_RegData1.Visible = false;
            tr_RegData2.Visible = false;
            tr_RegInfo.Visible = true;
        }
        else
        {
            LbErrMsg.Text = "用户注册失败,请稍后重试!";
            TrErrMsg.Attributes.Add("style", "display:;");
        }
    }
Esempio n. 36
0
        /// <summary>
        /// 自动计算未来处理人(该方法在发送成功后执行.)
        /// </summary>
        /// <param name="CurrWorkNode">当前的节点</param>
        /// <param name="nd"></param>
        /// <param name="toND"></param>
        public FullSA(WorkNode currWorkNode)
        {
            //如果当前不需要计算未来处理人.
            if (currWorkNode.HisFlow.IsFullSA == false &&
                currWorkNode.IsSkip == false)
            {
                return;
            }

            //如果到达最后一个节点,就不处理了。
            if (currWorkNode.HisNode.IsEndNode)
            {
                return;
            }

            //初始化一些变量.
            this.HisCurrWorkNode = currWorkNode;
            Node  currND = currWorkNode.HisNode;
            Int64 workid = currWorkNode.HisWork.OID;

            //查询出来所有的节点.
            Nodes nds = new Nodes(this.HisCurrWorkNode.HisFlow.No);

            // 开始节点需要特殊处理》
            /* 如果启用了要计算未来的处理人 */
            SelectAccper sa = new SelectAccper();

            //首先要清除以前的计算,重新计算。
            sa.Delete(SelectAccperAttr.WorkID, workid);

            //求出已经路过的节点.
            DataTable dt            = DBAccess.RunSQLReturnTable("SELECT FK_Node FROM WF_GenerWorkerList WHERE WorkID=" + BP.Sys.SystemConfig.AppCenterDBVarStr + "WorkID", "WorkID", workid);
            string    passedNodeIDs = "";

            foreach (DataRow item in dt.Rows)
            {
                passedNodeIDs += item[0].ToString() + ",";
            }

            //遍历当前的节点。
            foreach (Node item in nds)
            {
                if (item.IsStartNode == true)
                {
                    continue;
                }

                //如果已经包含了,就说明该节点已经经过了,就不处理了。
                if (passedNodeIDs.Contains(item.NodeID + ",") == true)
                {
                    continue;
                }

                //如果按照岗位计算(默认的第一个规则.)
                if (item.HisDeliveryWay == DeliveryWay.ByStation)
                {
                    string sql = "SELECT No, Name FROM Port_Emp WHERE No IN (SELECT A.FK_Emp FROM " + BP.WF.Glo.EmpStation + " A, WF_NodeStation B WHERE A.FK_Station=B.FK_Station AND B.FK_Node=" + item.NodeID + ")";
                    dt = BP.DA.DBAccess.RunSQLReturnTable(sql);
                    if (dt.Rows.Count != 1)
                    {
                        continue;
                    }

                    string no   = dt.Rows[0][0].ToString();
                    string name = dt.Rows[0][1].ToString();

                    // sa.Delete(SelectAccperAttr.FK_Node,item.NodeID, SelectAccperAttr.WorkID, workid); //删除已经存在的数据.
                    sa.FK_Emp  = no;
                    sa.EmpName = name;
                    sa.FK_Node = item.NodeID;

                    sa.WorkID  = workid;
                    sa.Info    = "无";
                    sa.AccType = 0;
                    sa.ResetPK();
                    if (sa.IsExits)
                    {
                        continue;
                    }

                    //计算接受任务时间与应该完成任务时间.
                    InitDT(sa, item);

                    sa.Insert();
                    continue;
                }

                //处理与指定节点相同的人员.
                if (item.HisDeliveryWay == DeliveryWay.BySpecNodeEmp &&
                    item.DeliveryParas == currND.NodeID.ToString())
                {
                    sa.FK_Emp  = WebUser.No;
                    sa.FK_Node = item.NodeID;

                    sa.WorkID  = workid;
                    sa.Info    = "无";
                    sa.AccType = 0;
                    sa.EmpName = WebUser.Name;

                    sa.ResetPK();
                    if (sa.IsExits)
                    {
                        continue;
                    }

                    //计算接受任务时间与应该完成任务时间.
                    InitDT(sa, item);

                    sa.Insert();
                    continue;
                }

                //处理绑定的节点人员..
                if (item.HisDeliveryWay == DeliveryWay.ByBindEmp)
                {
                    NodeEmps nes = new NodeEmps();
                    nes.Retrieve(NodeEmpAttr.FK_Node, item.NodeID);
                    foreach (NodeEmp ne in nes)
                    {
                        sa.FK_Emp  = ne.FK_Emp;
                        sa.FK_Node = item.NodeID;

                        sa.WorkID  = workid;
                        sa.Info    = "无";
                        sa.AccType = 0;
                        sa.EmpName = ne.FK_EmpT;

                        sa.ResetPK();
                        if (sa.IsExits)
                        {
                            continue;
                        }

                        //计算接受任务时间与应该完成任务时间.
                        InitDT(sa, item);

                        sa.Insert();
                    }
                }

                //按照节点的 岗位与部门的交集计算.
                #region  部门与岗位的交集计算.
                if (item.HisDeliveryWay == DeliveryWay.ByDeptAndStation)
                {
                    string dbStr = BP.Sys.SystemConfig.AppCenterDBVarStr;
                    string sql   = string.Empty;

                    //added by liuxc,2015.6.30.
                    //区别集成与BPM模式
                    if (BP.WF.Glo.OSModel == BP.Sys.OSModel.OneOne)
                    {
                        sql  = "SELECT No FROM Port_Emp WHERE No IN ";
                        sql += "(SELECT No as FK_Emp FROM Port_Emp WHERE FK_Dept IN ";
                        sql += "( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + dbStr + "FK_Node1)";
                        sql += ")";
                        sql += "AND No IN ";
                        sql += "(";
                        sql += "SELECT FK_Emp FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN ";
                        sql += "( SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node1 )";
                        sql += ") ORDER BY No ";

                        Paras ps = new Paras();
                        ps.Add("FK_Node1", item.NodeID);
                        ps.Add("FK_Node2", item.NodeID);
                        ps.SQL = sql;
                        dt     = DBAccess.RunSQLReturnTable(ps);
                    }
                    else
                    {
                        sql = "SELECT pdes.FK_Emp AS No"
                              + " FROM   Port_DeptEmpStation pdes"
                              + "        INNER JOIN WF_NodeDept wnd"
                              + "             ON  wnd.FK_Dept = pdes.FK_Dept"
                              + "             AND wnd.FK_Node = " + item.NodeID
                              + "        INNER JOIN WF_NodeStation wns"
                              + "             ON  wns.FK_Station = pdes.FK_Station"
                              + "             AND wnd.FK_Node =" + item.NodeID
                              + " ORDER BY"
                              + "        pdes.FK_Emp";

                        dt = DBAccess.RunSQLReturnTable(sql);
                    }

                    foreach (DataRow dr in dt.Rows)
                    {
                        Emp emp = new Emp(dr[0].ToString());
                        sa.FK_Emp   = emp.No;
                        sa.FK_Node  = item.NodeID;
                        sa.DeptName = emp.FK_DeptText;

                        sa.WorkID  = workid;
                        sa.Info    = "无";
                        sa.AccType = 0;
                        sa.EmpName = emp.Name;

                        sa.ResetPK();
                        if (sa.IsExits)
                        {
                            continue;
                        }

                        //计算接受任务时间与应该完成任务时间.
                        InitDT(sa, item);

                        sa.Insert();
                    }
                }
                #endregion  部门与岗位的交集计算.
            }

            //预制当前节点到达节点的数据。
            Nodes toNDs = currND.HisToNodes;
            foreach (Node item in toNDs)
            {
                if (item.HisDeliveryWay == DeliveryWay.ByStation || item.HisDeliveryWay == DeliveryWay.FindSpecDeptEmpsInStationlist)
                {
                    /*如果按照岗位访问*/
                    #region 最后判断 - 按照岗位来执行。
                    string dbStr = BP.Sys.SystemConfig.AppCenterDBVarStr;
                    string sql   = "";
                    Paras  ps    = new Paras();
                    /* 如果执行节点 与 接受节点岗位集合不一致 */
                    /* 没有查询到的情况下, 先按照本部门计算。*/

                    switch (BP.Sys.SystemConfig.AppCenterDBType)
                    {
                    case DBType.MySQL:
                    case DBType.MSSQL:
                        sql  = "select x.No from Port_Emp x inner join (select FK_Emp from " + BP.WF.Glo.EmpStation + " a inner join WF_NodeStation b ";
                        sql += " on a.FK_Station=b.FK_Station where FK_Node=" + dbStr + "FK_Node) as y on x.No=y.FK_Emp inner join Port_DeptEmp z on";
                        sql += " x.No=z.FK_Emp where z.FK_Dept =" + dbStr + "FK_Dept order by x.No";
                        break;

                    default:
                        sql = "SELECT No FROM Port_Emp WHERE NO IN "
                              + "(SELECT  FK_Emp  FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN (SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + dbStr + "FK_Node) )"
                              + " AND  NO IN "
                              + "(SELECT  FK_Emp  FROM Port_DeptEmp WHERE FK_Dept =" + dbStr + "FK_Dept)";
                        sql += " ORDER BY No ";
                        break;
                    }

                    ps     = new Paras();
                    ps.SQL = sql;
                    ps.Add("FK_Node", item.NodeID);
                    ps.Add("FK_Dept", WebUser.FK_Dept);

                    dt = DBAccess.RunSQLReturnTable(ps);
                    foreach (DataRow dr in dt.Rows)
                    {
                        Emp emp = new Emp(dr[0].ToString());
                        sa.FK_Emp   = emp.No;
                        sa.FK_Node  = item.NodeID;
                        sa.DeptName = emp.FK_DeptText;

                        sa.WorkID  = workid;
                        sa.Info    = "无";
                        sa.AccType = 0;
                        sa.EmpName = emp.Name;

                        sa.ResetPK();
                        if (sa.IsExits)
                        {
                            continue;
                        }

                        //计算接受任务时间与应该完成任务时间.
                        InitDT(sa, item);

                        sa.Insert();
                    }
                    #endregion   照岗位来执行。
                }
            }
        }
Esempio n. 37
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (BP.WF.Dev2Interface.Flow_IsCanStartThisFlow(this.FK_Flow, WebUser.No) == false)
            {
            }

            Flow fl = new Flow(this.FK_Flow);

            this.Page.Title = fl.Name;
            MapAttrs attrs = new MapAttrs(this.FK_MapData);

            if (fl.BatchStartFields.Length == 0)
            {
                this.Pub1.AddFieldSet("流程属性设置错误");
                this.Pub1.Add("您需要在流程属性里设置批量发起需要填写的字段。");
                this.Pub1.AddFieldSetEnd();
            }

            MapExts mes = new MapExts(this.FK_MapData);

            BP.WF.Node nd = new BP.WF.Node(int.Parse(this.FK_Flow + "01"));
            Work       wk = nd.HisWork;

            wk.ResetDefaultVal();

            this.Pub1.AddTable();
            this.Pub1.AddCaptionMsg("批量发起:" + fl.Name);

            #region 输出标题.
            this.Pub1.AddTR();
            this.Pub1.AddTDTitle("序");

            string str1 = "<INPUT id='checkedAll' onclick=\"SelectAllBS(this);\" value='选择' type='checkbox' name='checkedAll' >全部选择";
            this.Pub1.AddTDTitle("align='left'", str1);

            //this.Pub1.AddTDTitle("align='left'", "");

            string[] strs = fl.BatchStartFields.Split(',');
            foreach (string str in strs)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                foreach (MapAttr attr in attrs)
                {
                    if (str != attr.KeyOfEn)
                    {
                        continue;
                    }
                    this.Pub1.AddTDTitle(attr.Name);
                }
            }
            this.Pub1.AddTREnd();
            #endregion 输出标题.

            #region 输出标题.
            for (int i = 1; i <= this.RowNum; i++)
            {
                this.Pub1.AddTR();
                this.Pub1.AddTDIdx(i);
                CheckBox cbIdx = new CheckBox();
                cbIdx.Checked = false;
                cbIdx.Text    = "发起否?";
                cbIdx.ID      = "CB_IDX_" + i;
                this.Pub1.AddTD(cbIdx);

                foreach (string str in strs)
                {
                    if (string.IsNullOrEmpty(str))
                    {
                        continue;
                    }
                    foreach (MapAttr attr in attrs)
                    {
                        if (str != attr.KeyOfEn)
                        {
                            continue;
                        }

                        TB tb = new TB();
                        tb.ID = "TB_" + attr.KeyOfEn + "_" + i;
                        switch (attr.LGType)
                        {
                        case FieldTypeS.Normal:
                            switch (attr.MyDataType)
                            {
                            case BP.DA.DataType.AppString:
                                if (attr.UIRows == 1)
                                {
                                    tb.Text = attr.DefVal;
                                    tb.Attributes["style"] = "width: " + attr.UIWidth + "px; text-align: left; height: 15px;padding: 0px;margin: 0px;";
                                    if (attr.UIIsEnable)
                                    {
                                        tb.CssClass = "TB";
                                    }
                                    else
                                    {
                                        tb.CssClass = "TBReadonly";
                                    }
                                    this.Pub1.AddTD(tb);
                                }
                                else
                                {
                                    tb.TextMode = TextBoxMode.MultiLine;
                                    tb.Text     = attr.DefVal;

                                    tb.Attributes["style"]     = "width: " + attr.UIWidth + "px; text-align: left;padding: 0px;margin: 0px;";
                                    tb.Attributes["maxlength"] = attr.MaxLen.ToString();
                                    tb.Rows = attr.UIRows;

                                    if (attr.UIIsEnable)
                                    {
                                        tb.CssClass = "TBDoc";
                                    }
                                    else
                                    {
                                        tb.CssClass = "TBReadonly";
                                    }

                                    this.Pub1.AddTD(tb);
                                }
                                break;

                            case BP.DA.DataType.AppDate:
                                tb.ShowType = TBType.Date;
                                tb.Text     = attr.DefVal;

                                if (attr.UIIsEnable)
                                {
                                    tb.Attributes["onfocus"] = "WdatePicker();";
                                }

                                if (attr.UIIsEnable)
                                {
                                    tb.Attributes["class"] = "TB";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }

                                tb.Attributes["style"] = "width: " + attr.UIWidth + "px; text-align: left; height: 19px;";
                                this.Pub1.AddTD(tb);
                                break;

                            case BP.DA.DataType.AppDateTime:
                                tb.ShowType = TBType.DateTime;
                                tb.Text     = attr.DefVal;     // en.GetValStrByKey(attr.KeyOfEn);

                                if (attr.UIIsEnable)
                                {
                                    tb.Attributes["class"] = "TBcalendar";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }

                                if (attr.UIIsEnable)
                                {
                                    tb.Attributes["onfocus"] = "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});";
                                }
                                tb.Attributes["style"] = "width: " + attr.UIWidth + "px; text-align: left; height: 19px;";
                                this.Pub1.AddTD(tb);
                                break;

                            case BP.DA.DataType.AppBoolean:
                                CheckBox cb = new CheckBox();
                                //cb.Width = 350;
                                cb.Text    = attr.Name;
                                cb.ID      = "CB_" + attr.KeyOfEn + "_" + i;
                                cb.Checked = attr.DefValOfBool;
                                cb.Enabled = attr.UIIsEnable;
                                cb.Checked = attr.DefValOfBool;

                                if (cb.Enabled == false)
                                {
                                    cb.Enabled = false;
                                }
                                else
                                {
                                    //add by dgq 2013-4-9,添加内容修改后的事件
                                    // cb.Attributes["onmousedown"] = "Change('" + attr.FK_MapData + "')";
                                    cb.Enabled = true;
                                }
                                this.Pub1.AddTD(cb);
                                break;

                            case BP.DA.DataType.AppDouble:
                            case BP.DA.DataType.AppFloat:
                                tb.Attributes["style"] = "width: " + attr.GetValStrByKey("UIWidth") + "px; text-align: right; height: 19px;word-break: keep-all;";
                                tb.Text = attr.DefVal;

                                if (attr.UIIsEnable)
                                {
                                    //增加验证
                                    tb.Attributes.Add("onkeyup", @"Change('" + attr.FK_MapData + "');");
                                    tb.Attributes.Add("onblur", @"value=value.replace(/[^-?\d+\.*\d*$]/g,'');TB_ClickNum(this,0);");
                                    tb.Attributes.Add("onClick", "TB_ClickNum(this)");
                                    tb.Attributes["OnKeyPress"] += @"javascript:return  VirtyNum(this,'float');";
                                    tb.Attributes["class"]       = "TBNum";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }

                                this.Pub1.AddTD(tb);
                                break;

                            case BP.DA.DataType.AppInt:
                                tb.Attributes["style"] = "width: " + attr.GetValStrByKey("UIWidth") + "px; text-align: right; height: 19px;word-break: keep-all;";
                                tb.Text = attr.DefVal;

                                if (attr.UIIsEnable)
                                {
                                    //增加验证
                                    tb.Attributes.Add("onkeyup", @"Change('" + attr.FK_MapData + "');");
                                    tb.Attributes.Add("onblur", @"value=value.replace(/[^-?\d]/g,'');TB_ClickNum(this,0);");
                                    tb.Attributes.Add("onClick", "TB_ClickNum(this)");
                                    tb.Attributes["OnKeyPress"] += @"javascript:return  VirtyNum(this,'int');";
                                    tb.Attributes["class"]       = "TBNum";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }

                                this.Pub1.AddTD(tb);
                                break;

                            case BP.DA.DataType.AppMoney:
                                if (attr.UIIsEnable)
                                {
                                    //增加验证
                                    tb.Attributes.Add("onkeyup", @"Change('" + attr.FK_MapData + "');");
                                    tb.Attributes.Add("onblur", @"value=value.replace(/[^-?\d+\.*\d*$]/g,'');TB_ClickNum(this,'0.00');");
                                    tb.Attributes.Add("onClick", "TB_ClickNum(this)");
                                    tb.Attributes["OnKeyPress"] += @"javascript:return  VirtyNum(this,'float');";
                                    tb.Attributes["class"]       = "TBNum";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }
                                //  tb.ShowType = TBType.Moneny;
                                tb.Text = attr.DefVal;

                                tb.Attributes["style"] = "width: " + attr.GetValStrByKey("UIWidth") + "px; text-align: right; height: 19px;";
                                this.Pub1.AddTD(tb);
                                break;

                            case BP.DA.DataType.AppRate:
                                if (attr.UIIsEnable)
                                {
                                    tb.Attributes["class"] = "TBNum";
                                }
                                else
                                {
                                    tb.Attributes["class"] = "TBReadonly";
                                }
                                tb.ShowType            = TBType.Moneny;
                                tb.Text                = attr.DefVal;
                                tb.Attributes["style"] = "width: " + attr.GetValStrByKey("UIWidth") + "px; text-align: right; height: 19px;";
                                this.Pub1.AddTD(tb);
                                break;

                            default:
                                break;
                            }
                            break;

                        case FieldTypeS.Enum:
                            if (attr.UIContralType == UIContralType.DDL)
                            {
                                DDL ddle = new DDL();
                                ddle.ID = "DDL_" + attr.KeyOfEn + "_" + i;
                                ddle.BindSysEnum(attr.UIBindKey);
                                ddle.SetSelectItem(attr.DefVal);
                                ddle.Enabled = attr.UIIsEnable;
                                ddle.Attributes["tabindex"] = attr.Idx.ToString();
                                if (attr.UIIsEnable)
                                {
                                    //add by dgq 2013-4-9,添加内容修改后的事件
                                    //   ddle.Attributes["onchange"] = "Change('" + attr.FK_MapData + "')";
                                }
                                //    ddle.Enabled = false;
                                this.Pub1.AddTD(ddle);
                            }
                            else
                            {
                            }
                            break;

                        case FieldTypeS.FK:
                            DDL ddl1 = new DDL();
                            ddl1.ID = "DDL_" + attr.KeyOfEn + "_" + i;
                            ddl1.Attributes["tabindex"] = attr.Idx.ToString();
                            if (ddl1.Enabled)
                            {
                                EntitiesNoName ens = attr.HisEntitiesNoName;
                                ens.RetrieveAll();
                                ddl1.BindEntities(ens);
                                ddl1.SetSelectItem(attr.DefVal);
                                //add by dgq 2013-4-9,添加内容修改后的事件
                                //  ddl1.Attributes["onchange"] = "Change('" + attr.FK_MapData + "')";
                            }
                            else
                            {
                                ddl1.Attributes["style"] = "width: " + attr.UIWidth + "px;height: 19px;";
                                if (ddl1.Enabled == true)
                                {
                                    ddl1.Enabled = false;
                                }
                                ddl1.Attributes["Width"] = attr.UIWidth.ToString();
                                ddl1.Items.Add(new ListItem(attr.DefVal, attr.DefVal));
                            }
                            ddl1.Enabled = attr.UIIsEnable;
                            this.Pub1.AddTD(ddl1);
                            break;

                        default:
                            break;
                        }
                    }
                }
                this.Pub1.AddTREnd();
            }
            #endregion 输出标题.

            this.Pub1.AddTableEnd();

            #region 处理扩展属性.
            if (mes.Count != 0)
            {
                this.Page.RegisterClientScriptBlock("s81",
                                                    "<script language='JavaScript' src='/WF/Scripts/jquery-1.4.1.min.js' ></script>");
                this.Page.RegisterClientScriptBlock("b81",
                                                    "<script language='JavaScript' src='/WF/CCForm/MapExt.js' defer='defer' type='text/javascript' ></script>");
                this.Pub1.Add("<div id='divinfo' style='width: 155px; position: absolute; color: Lime; display: none;cursor: pointer;align:left'></div>");
                this.Page.RegisterClientScriptBlock("dCd",
                                                    "<script language='JavaScript' src='/DataUser/JSLibData/" + this.FK_MapData + ".js' ></script>");

                for (int i = 1; i <= this.RowNum; i++)
                {
                    foreach (MapExt me in mes)
                    {
                        switch (me.ExtType)
                        {
                        case MapExtXmlList.DDLFullCtrl:     // 自动填充.
                            DDL ddlOper = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper + "_" + i);
                            if (ddlOper == null)
                            {
                                continue;
                            }
                            ddlOper.Attributes["onchange"] = "DDLFullCtrl(this.value,\'" + ddlOper.ClientID + "\', \'" + me.MyPK + "\')";
                            break;

                        case MapExtXmlList.ActiveDDL:
                            DDL       ddlPerant = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper + "_" + i);
                            string    val, valC;
                            DataTable dt;
                            if (ddlPerant == null)
                            {
                                continue;
                            }
#warning 此处需要优化
                            string ddlC = "ContentPlaceHolder1_BatchStart1_DDL_" + me.AttrsOfActive + "_" + i;
                            //  ddlPerant.Attributes["onchange"] = " isChange=true; DDLAnsc(this.value, \'" + ddlC + "\', \'" + me.MyPK + "\')";
                            ddlPerant.Attributes["onchange"] = "DDLAnsc(this.value, \'" + ddlC + "\', \'" + me.MyPK + "\')";

                            DDL ddlChild = this.Pub1.GetDDLByID("DDL_" + me.AttrsOfActive + "_" + i);
                            val = ddlPerant.SelectedItemStringVal;
                            if (ddlChild.Items.Count == 0)
                            {
                                valC = wk.GetValStrByKey(me.AttrsOfActive);
                            }
                            else
                            {
                                valC = ddlChild.SelectedItemStringVal;
                            }

                            string mysql = me.Doc.Replace("@Key", val);
                            if (mysql.Contains("@") && i >= 100)
                            {
                                mysql = BP.WF.Glo.DealExp(mysql, wk, null);
                            }
                            else
                            {
                                continue;
                            }

                            dt = DBAccess.RunSQLReturnTable(mysql);

                            ddlChild.Bind(dt, "No", "Name");
                            if (ddlChild.SetSelectItem(valC) == false)
                            {
                                ddlChild.Items.Insert(0, new ListItem("请选择" + valC, valC));
                                ddlChild.SelectedIndex = 0;
                            }
                            //  ddlChild.Attributes["onchange"] = " isChange=true;";

                            break;

                        case MapExtXmlList.AutoFullDLL:     //自动填充下拉框的范围.
                            DDL ddlFull = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper + "_" + i);
                            if (ddlFull == null)
                            {
                                continue;
                            }

                            string valOld = wk.GetValStrByKey(me.AttrOfOper);
                            //string valOld =ddlFull.SelectedItemStringVal;

                            string fullSQL = me.Doc.Replace("@WebUser.No", WebUser.No);
                            fullSQL = fullSQL.Replace("@WebUser.Name", WebUser.Name);
                            fullSQL = fullSQL.Replace("@WebUser.FK_Dept", WebUser.FK_Dept);
                            fullSQL = fullSQL.Replace("@WebUser.FK_DeptName", WebUser.FK_DeptName);
                            fullSQL = fullSQL.Replace("@Key", this.Request.QueryString["Key"]);

                            if (fullSQL.Contains("@"))
                            {
                                Attrs attrsFull = wk.EnMap.Attrs;
                                foreach (Attr attr in attrsFull)
                                {
                                    if (fullSQL.Contains("@") == false)
                                    {
                                        break;
                                    }
                                    fullSQL = fullSQL.Replace("@" + attr.Key, wk.GetValStrByKey(attr.Key));
                                }
                            }

                            //if (fullSQL.Contains("@"))
                            //{
                            //    /*从主表中取数据*/
                            //    Attrs attrsFull = this.MainEn.EnMap.Attrs;
                            //    foreach (Attr attr in attrsFull)
                            //    {
                            //        if (fullSQL.Contains("@") == false)
                            //            break;

                            //        if (fullSQL.Contains("@" + attr.Key) == false)
                            //            continue;

                            //        fullSQL = fullSQL.Replace("@" + attr.Key, this.MainEn.GetValStrByKey(attr.Key));
                            //    }
                            //}

                            ddlFull.Items.Clear();
                            ddlFull.Bind(DBAccess.RunSQLReturnTable(fullSQL), "No", "Name");
                            if (ddlFull.SetSelectItem(valOld) == false)
                            {
                                ddlFull.Items.Insert(0, new ListItem("请选择" + valOld, valOld));
                                ddlFull.SelectedIndex = 0;
                            }
                            // ddlFull.Attributes["onchange"] = " isChange=true;";
                            break;

                        case MapExtXmlList.TBFullCtrl:     // 自动填充.
                            TextBox tbAuto = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                            if (tbAuto == null)
                            {
                                continue;
                            }
                            // tbAuto.Attributes["onkeyup"] = " isChange=true; DoAnscToFillDiv(this,this.value,\'" + tbAuto.ClientID + "\', \'" + me.MyPK + "\');";
                            tbAuto.Attributes["onkeyup"] = " DoAnscToFillDiv(this,this.value,\'" + tbAuto.ClientID + "\', \'" + me.MyPK + "\');";

                            tbAuto.Attributes["AUTOCOMPLETE"] = "OFF";
                            if (me.Tag != "")
                            {
                                /* 处理下拉框的选择范围的问题 */
                                string[] strsTmp = me.Tag.Split('$');
                                foreach (string str in strsTmp)
                                {
                                    string[] myCtl = str.Split(':');
                                    string   ctlID = myCtl[0];
                                    DDL      ddlC1 = this.Pub1.GetDDLByID("DDL_" + ctlID + "_" + i);
                                    if (ddlC1 == null)
                                    {
                                        //me.Tag = "";
                                        // me.Update();
                                        continue;
                                    }

                                    string sql = myCtl[1].Replace("~", "'");
                                    sql = sql.Replace("@WebUser.No", WebUser.No);
                                    sql = sql.Replace("@WebUser.Name", WebUser.Name);
                                    sql = sql.Replace("@WebUser.FK_Dept", WebUser.FK_Dept);
                                    sql = sql.Replace("@Key", tbAuto.Text.Trim());
                                    dt  = DBAccess.RunSQLReturnTable(sql);
                                    string valC1 = ddlC1.SelectedItemStringVal;
                                    ddlC1.Items.Clear();
                                    foreach (DataRow dr in dt.Rows)
                                    {
                                        ddlC1.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                                    }
                                    ddlC1.SetSelectItem(valC1);
                                }
                            }
                            break;

                        case MapExtXmlList.InputCheck:
                            TextBox tbCheck = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                            if (tbCheck != null)
                            {
                                tbCheck.Attributes[me.Tag2] += " rowPK=" + i + "; " + me.Tag1 + "(this);";
                            }
                            break;

                        case MapExtXmlList.PopVal:     //弹出窗.
                            TB tb = this.Pub1.GetTBByID("TB_" + me.AttrOfOper + "_" + i);
                            //  tb.Attributes["ondblclick"] = " isChange=true; ReturnVal(this,'" + me.Doc + "','sd');";
                            tb.Attributes["ondblclick"] = " ReturnVal(this,'" + me.Doc + "','sd');";
                            break;

                        case MapExtXmlList.Link:     // 超链接.
                            //TB tb = this.Pub1.GetTBByID("TB_" + me.AttrOfOper + "_" + mydtl.OID);
                            //tb.Attributes["ondblclick"] = " isChange=true; ReturnVal(this,'" + me.Doc + "','sd');";
                            break;

                        case MapExtXmlList.RegularExpression:    //正则表达式,对数据控件处理
                            TextBox tbExp = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                            if (tbExp == null || me.Tag == "onsubmit")
                            {
                                continue;
                            }
                            //验证输入的正则格式
                            string regFilter = me.Doc;
                            if (regFilter.LastIndexOf("/g") < 0 && regFilter.LastIndexOf('/') < 0)
                            {
                                regFilter = "'" + regFilter + "'";
                            }
                            //处理事件
                            tbExp.Attributes.Add("" + me.Tag + "", "return txtTest_Onkeyup(this," + regFilter + ",'" + me.Tag1 + "')");    //[me.Tag] += "this.value=this.value.replace(" + regFilter + ",'')";
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            #endregion 拓展属性

            Button btn = new Button();
            btn.Text          = "执行发起";
            btn.ID            = "Btn_Start";
            btn.Click        += new EventHandler(btn_Send_Click);
            btn.OnClientClick = "return checkType()";
            this.Pub1.Add(btn);

            #region 文件上传.
            this.Pub1.AddFieldSet("通过Excel导入方式发起:<a href='/DataUser/BatchStartFlowTemplete/" + this.FK_Flow + ".xls'><img src='/WF/Img/FileType/xls.gif' />下载Excel模版</a>");
            this.Pub1.Add("文件名:");
            FileUpload fu = new FileUpload();
            fu.ID = "File1";
            this.Pub1.Add(fu);
            btn        = new Button();
            btn.Text   = "导入";
            btn.ID     = "Btn_Imp";
            btn.Click += new EventHandler(btn_Upload_Click);
            this.Pub1.Add(btn);
            this.Pub1.AddFieldSetEnd();
            #endregion 文件上传.
        }
Esempio n. 38
0
        public static Boolean GetMotivationGroupAndDetailForPartner(Int64 APartnerKey,
                                                                    ref String AMotivationGroup,
                                                                    ref String AMotivationDetail)
        {
            Boolean PartnerKeyIsValid = false;

            if (APartnerKey != 0)
            {
                string motivationGroup  = MFinanceConstants.MOTIVATION_GROUP_GIFT;
                string motivationDetail = AMotivationDetail;

                TDBTransaction readTransaction = new TDBTransaction();
                TDataBase      db = DBAccess.Connect("GetMotivationGroupAndDetailForPartner");

                db.ReadTransaction(
                    ref readTransaction,
                    delegate
                {
                    PPartnerTable myPPartnerTable = PPartnerAccess.LoadByPrimaryKey(APartnerKey, readTransaction);

                    if (myPPartnerTable.Rows.Count == 1)
                    {
                        // partnerKey is valid
                        PartnerKeyIsValid      = true;
                        PPartnerRow partnerRow = myPPartnerTable[0];

                        // Change motivationDetail if PartnerClass is UNIT
                        if (partnerRow.PartnerClass.Equals(MPartnerConstants.PARTNERCLASS_UNIT))
                        {
                            // AND KEY-MIN
                            bool KeyMinFound = false;

                            // first check if a specific motivation detail is linked to this partner
                            AMotivationDetailTable MotivationDetailTable
                                = AMotivationDetailAccess.LoadViaPPartner(APartnerKey, readTransaction);

                            if ((MotivationDetailTable != null) && (MotivationDetailTable.Rows.Count > 0))
                            {
                                foreach (AMotivationDetailRow Row in MotivationDetailTable.Rows)
                                {
                                    if (Row.MotivationStatus)
                                    {
                                        motivationGroup  = MotivationDetailTable[0].MotivationGroupCode;
                                        motivationDetail = MotivationDetailTable[0].MotivationDetailCode;

                                        KeyMinFound = true;
                                        break;     // Go with the first entry found.
                                    }
                                }
                            }

                            if (!KeyMinFound)
                            {
                                // Is this is a key min, or a field?
                                PUnitTable pUnitTable = PUnitAccess.LoadByPrimaryKey(APartnerKey, readTransaction);

                                if (pUnitTable.Rows.Count == 1)
                                {
                                    PUnitRow unitRow = pUnitTable[0];

                                    switch (unitRow.UnitTypeCode)
                                    {
                                    case MPartnerConstants.UNIT_TYPE_AREA:
                                    case MPartnerConstants.UNIT_TYPE_FUND:
                                    case MPartnerConstants.UNIT_TYPE_FIELD:
                                        motivationDetail = MFinanceConstants.GROUP_DETAIL_FIELD;
                                        break;

                                    case MPartnerConstants.UNIT_TYPE_KEYMIN:
                                        motivationDetail = MFinanceConstants.GROUP_DETAIL_KEY_MIN;
                                        break;

                                    case MPartnerConstants.UNIT_TYPE_COUNTRY:
                                    case MPartnerConstants.UNIT_TYPE_CONFERENCE:
                                    case MPartnerConstants.UNIT_TYPE_OTHER:
                                    case MPartnerConstants.UNIT_TYPE_ROOT:
                                    case MPartnerConstants.UNIT_TYPE_TEAM:
                                    case MPartnerConstants.UNIT_TYPE_WORKING_GROUP:
                                    default:
                                        motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            motivationDetail = MFinanceConstants.GROUP_DETAIL_SUPPORT;
                        }
                    }
                });

                db.CloseDBConnection();

                AMotivationGroup  = motivationGroup;
                AMotivationDetail = motivationDetail;
            }

            return(PartnerKeyIsValid);
        }
Esempio n. 39
0
 public FileTest() {
     db = new DBAccess();
     db.Open();
 }
Esempio n. 40
0
        /// <summary>
        /// This method needs to be implemented by extracts that can't follow the default processing with just one query.
        /// </summary>
        /// <param name="AParameters"></param>
        /// <param name="ATransaction"></param>
        /// <param name="AExtractId"></param>
        protected override bool RunSpecialTreatment(TParameterList AParameters, TDBTransaction ATransaction, out int AExtractId)
        {
            Boolean        ReturnValue = false;
            Int32          ExtractId   = -1;
            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("RunSpecialTreatment");

            db.ReadTransaction(ref Transaction,
                               delegate
            {
                DataTable giftdetails;

                string SqlStmt = TDataBase.ReadSqlFile("Gift.Queries.ExtractDonorByAmount.sql");

                List <OdbcParameter> SqlParameterList = new List <OdbcParameter>();
                bool AddressFilterAdded;
                DataTable partnerkeys = new DataTable();


                // call to derived class to retrieve parameters specific for extract
                RetrieveParameters(AParameters, ref SqlStmt, ref SqlParameterList);

                // add address filter information to sql statement and parameter list
                AddressFilterAdded = AddAddressFilter(AParameters, ref SqlStmt, ref SqlParameterList);

                // now run the database query
                TLogging.Log("Getting the data from the database...", TLoggingType.ToStatusBar);
                giftdetails = db.SelectDT(SqlStmt, "partners", Transaction,
                                          SqlParameterList.ToArray());

                // if this is taking a long time, every now and again update the TLogging statusbar, and check for the cancel button
                // TODO: we might need to add this functionality to TExtractsHandling.CreateExtractFromListOfPartnerKeys as well???
                if (AParameters.Get("CancelReportCalculation").ToBool() == true)
                {
                    return;
                }

                TLogging.Log("Preparing the extract...", TLoggingType.ToStatusBar);

                // With the result of the original query process the data and identify the partner keys for
                // the extract.
                partnerkeys.Columns.Add("0", typeof(Int64));
                partnerkeys.Columns.Add("1", typeof(string));
                partnerkeys.Columns.Add("p_site_key_n", typeof(Int64));
                partnerkeys.Columns.Add("p_location_key_i", typeof(Int32));
                ProcessGiftDetailRecords(giftdetails, AddressFilterAdded, AParameters, ref partnerkeys);

                // filter data by postcode (if applicable)
                PostcodeFilter(ref partnerkeys, ref AddressFilterAdded, AParameters, Transaction);

                // create an extract with the given name in the parameters
                int keyCount;
                List <long> ignoredPartnerKeys = null;
                ReturnValue = TExtractsHandling.CreateExtractFromListOfPartnerKeys(
                    AParameters.Get("param_extract_name").ToString(),
                    AParameters.Get("param_extract_description").ToString(),
                    out ExtractId,
                    partnerkeys,
                    0,
                    AddressFilterAdded,
                    out keyCount,
                    out ignoredPartnerKeys);
            });
            AExtractId = ExtractId;
            return(ReturnValue);
        } // Run Special Treatment
 public DBDirectorTest() {
     db = new DBAccess();
     db.Open();
     db.ClearDatabase();
     
 }
Esempio n. 42
0
        /// <summary>
        /// 重置当前用户编号
        /// </summary>
        /// <param name="userNo">当前用户编号</param>
        /// <returns>返回重置信息</returns>
        public string DoChangeUserNo(string userNo)
        {
            if (BP.Web.WebUser.No != "admin")
            {
                return("非超级管理员,不能执行。");
            }

            string msg = "";
            int    i   = 0;
            //更新待办.
            string sql = "update wf_generworkerlist set fk_emp='" + userNo + "' where fk_emp='" + this.No + "'";

            i = BP.DA.DBAccess.RunSQL(sql);
            if (i != 0)
            {
                msg += "@待办更新[" + i + "]个。";
            }

            sql = "UPDATE WF_GENERWORKFLOW  SET STARTER='" + userNo + "'  WHERE STARTER='" + this.No + "'";
            i   = BP.DA.DBAccess.RunSQL(sql);
            if (i != 0)
            {
                msg += "@流程注册更新[" + i + "]个。";
            }


            //更换流程信息的数据表
            BP.WF.Flows fls = new Flows();
            fls.RetrieveAll();
            foreach (Flow fl in fls)
            {
                sql = "UPDATE " + fl.PTable + " SET FlowEnder='" + userNo + "' WHERE FlowEnder='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);

                if (i != 0)
                {
                    msg += "@流程注册更新[" + i + "]个。";
                }

                sql = "UPDATE  " + fl.PTable + "  SET FlowStarter='" + userNo + "' WHERE FlowStarter='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);
                if (i != 0)
                {
                    msg += "@流程业务表发起人,更新了[" + i + "]个。";
                }


                sql = "UPDATE  " + fl.PTable + "  SET Rec='" + userNo + "' WHERE Rec='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);
                if (i != 0)
                {
                    msg += "@流程业务表记录人,更新了[" + i + "]个。";
                }

                string trackTable = "ND" + int.Parse(fl.No) + "Track";
                sql = "UPDATE  " + trackTable + "  SET EmpFrom='" + userNo + "' WHERE EmpFrom='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);
                if (i != 0)
                {
                    msg += "@轨迹表 EmpFrom,更新了[" + i + "]个。";
                }


                sql = "UPDATE  " + trackTable + "  SET EmpTo='" + userNo + "' WHERE EmpTo='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);
                if (i != 0)
                {
                    msg += "@轨迹表 EmpTo,更新了[" + i + "]个。";
                }


                sql = "UPDATE  " + trackTable + "  SET Exer='" + userNo + "' WHERE Exer='" + this.No + "'";
                i   = DBAccess.RunSQL(sql);
                if (i != 0)
                {
                    msg += "@轨迹表 Exer,更新了[" + i + "]个。";
                }
            }


            //更新其他字段.
            BP.Sys.MapAttrs attrs = new Sys.MapAttrs();
            attrs.RetrieveAll();
            foreach (BP.Sys.MapAttr attr in attrs)
            {
                if (attr.DefValReal.Contains("@WebUser.No") == true)
                {
                    try
                    {
                        BP.Sys.MapData md = new Sys.MapData(attr.FK_MapData);
                        sql = "UPDATE " + md.PTable + " SET " + attr.KeyOfEn + "='" + userNo + "' WHERE " + attr.KeyOfEn + "='" + this.No + "'";
                        i   = DBAccess.RunSQL(sql);
                        if (i != 0)
                        {
                            msg += "@表[" + md.Name + "],[" + md.PTable + "] [" + attr.KeyOfEn + "],更新了[" + i + "]个。";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            //人员主表信息-手动修改

            return(msg);
        }
Esempio n. 43
0
 public DBMovieTest() {
     db = new DBAccess();
     db.Open();
     db.ClearDatabase();
     
 }
Esempio n. 44
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="GroupName"></param>
 /// <returns></returns>
 public static bool GroupExist(string GroupName, string GroupID)
 {
     return(int.Parse(DBAccess.GetRelation().ExecuteScalar("select count(1) from KPI_Group where GroupName='" + GroupName + "' and GroupID<>'" + GroupID + "'").ToString()) > 0);
 }