Esempio n. 1
0
		private static int DuplicateShow(UpdateQueryBatch batch, int curShowObjid, int parentElmObjid, int parentShowObjid, int objidBase, int hgbstShowTableID)
		{
			var sqlHelper = new SqlHelper(batch.Provider)
			             {
			             	Transaction = batch.Transaction,
			             	CommandText = @"SELECT * FROM table_hgbst_show WHERE objid = {0}"
			             };
			sqlHelper.Parameters.Add("curShowObjid", curShowObjid);

			var newObjid = GetNextObjid(batch, hgbstShowTableID, objidBase);

			var showSet = sqlHelper.ExecuteDataSet();

			if (showSet == null || showSet.Tables.Count != 1 || showSet.Tables[0].Rows.Count != 1)
			{
				throw new ApplicationException("Show with objid " + curShowObjid + " not found, or more than one row with that objid exists");
			}

			var showRow = showSet.Tables[0].Rows[0];

			var cmdParams = new DataParameterCollection
			                {
			                	{batch.GetUniqueParamName("objid"), newObjid},
			                	{batch.GetUniqueParamName("title"), showRow["title"]},
			                	{batch.GetUniqueParamName("def_val"), showRow["def_val"]},
			                	{batch.GetUniqueParamName("chld_prnt2hgbst_show"), parentShowObjid}
			                };
			batch.AddStatement(String.Format(
@"
INSERT INTO table_hgbst_show (objid, last_mod_time, title, def_val, dev, chld_prnt2hgbst_show)
VALUES ({{0}}, {0}, {{1}}, {{2}}, NULL, {{3}})",
					batch.Provider.GetDateStatement()), cmdParams);

			// Now relate it to the new parent
			cmdParams = new DataParameterCollection
			            {
			            	{batch.GetUniqueParamName("parentElmObjid"), parentElmObjid},
			            	{batch.GetUniqueParamName("newShowObjid"), newObjid}
			            };
			batch.AddStatement(@"INSERT INTO mtm_hgbst_elm0_hgbst_show1 (hgbst_elm2hgbst_show, hgbst_show2hgbst_elm) VALUES ({0}, {1})", cmdParams);


			return newObjid;
		}
Esempio n. 2
0
		private static int DuplicateElement(UpdateQueryBatch batch, int curElmObjid, int newParentShowObjid, int objidBase,
		                                    int hgbstElmTableID)
		{
			var sqlHelper = new SqlHelper(batch.Provider)
			             {
			             	Transaction = batch.Transaction,
			             	CommandText = @"SELECT * FROM table_hgbst_elm WHERE objid = {0}"
			             };
			sqlHelper.Parameters.Add("curElmObjid", curElmObjid);

			var newObjid = GetNextObjid(batch, hgbstElmTableID, objidBase);

			var elmSet = sqlHelper.ExecuteDataSet();

			if (elmSet == null || elmSet.Tables.Count != 1 || elmSet.Tables[0].Rows.Count != 1)
			{
				throw new ApplicationException("Element with objid " + curElmObjid + " not found, or more than one row with that objid exists");
			}

			var elementRow = elmSet.Tables[0].Rows[0];

			var commandParameters = new DataParameterCollection
									{
			                        	{batch.GetUniqueParamName("objid"), newObjid},
			                        	{batch.GetUniqueParamName("title"), elementRow["title"]},
			                        	{batch.GetUniqueParamName("rank"), elementRow["rank"]},
			                        	{batch.GetUniqueParamName("state"), elementRow["state"]},
			                        	{batch.GetUniqueParamName("intval1"), elementRow["intval1"]}
			                        };
			batch.AddStatement(@"INSERT INTO table_hgbst_elm (objid, title, rank, state, dev, intval1) VALUES ({0}, {1}, {2}, {3}, NULL, {4})", commandParameters);

			// Now relate it to the new parent
			commandParameters = new DataParameterCollection
			                    {
			                    	{batch.GetUniqueParamName("newObjid"), newObjid},
			                    	{batch.GetUniqueParamName("newParentShowObjid"), newParentShowObjid}
			                    };
			batch.AddStatement( @"INSERT INTO mtm_hgbst_elm0_hgbst_show1 (hgbst_elm2hgbst_show, hgbst_show2hgbst_elm) VALUES ({0}, {1})", commandParameters);

			return newObjid;
		}