コード例 #1
0
ファイル: DynamicControl.cs プロジェクト: huamouse/Taoqi
		public DynamicControl(SplendidControl ctlPARENT, string sNAME)
		{
			this.ctlPARENT  = ctlPARENT ;
			this.sNAME      = sNAME     ;
			this.rowCurrent = null      ;
		}
コード例 #2
0
ファイル: DynamicControl.cs プロジェクト: huamouse/Taoqi
		// 11/18/2007   Use the current values for any that are not defined in the edit view. 
		public DynamicControl(SplendidControl ctlPARENT, DataRow rowCurrent, string sNAME)
		{
			this.ctlPARENT  = ctlPARENT ;
			this.sNAME      = sNAME     ;
			this.rowCurrent = rowCurrent;
		}
コード例 #3
0
ファイル: RulesUtil.cs プロジェクト: huamouse/Taoqi
		public SplendidControlThis(SplendidControl Container, string sModule, DataTable Table)
		{
			this.Container = Container;
			this.Module    = sModule  ;
			this.Table     = Table    ;
			this.L10n      = Container.GetL10n();
		}
コード例 #4
0
ファイル: RulesUtil.cs プロジェクト: huamouse/Taoqi
		public SafeDynamicButtons(SplendidControl ctlPARENT, string sNAME, DataRow row)
		{
			this.ctlPARENT  = ctlPARENT ;
			this.rowCurrent = row       ;
			this.ctlDynamicButtons = ctlPARENT.FindControl(sNAME) as _controls.DynamicButtons;
		}
コード例 #5
0
ファイル: RulesUtil.cs プロジェクト: huamouse/Taoqi
		public RulesValidator(SplendidControl Container)
		{
			this.Container = Container;
		}
コード例 #6
0
ファイル: RulesUtil.cs プロジェクト: huamouse/Taoqi
		public SplendidControlThis(SplendidControl Container, string sModule, DataRow Row)
		{
			this.Container = Container;
			this.Module    = sModule  ;
			this.Row       = Row      ;
			if ( Row != null )
				this.Table = Row.Table;
			this.L10n      = Container.GetL10n();
		}
コード例 #7
0
ファイル: SplendidDynamic.cs プロジェクト: huamouse/Taoqi
		// 09/09/2009   Change parameter name to be more logical.
		public static void UpdateCustomFields(SplendidControl ctlPARENT, IDbTransaction trn, Guid gID, string sTABLE_NAME, DataTable dtCustomFields)
		{
			if ( dtCustomFields.Rows.Count > 0 )
			{
				IDbConnection con = trn.Connection;
				using ( IDbCommand cmd = con.CreateCommand() )
				{
					cmd.Transaction = trn;
					cmd.CommandType = CommandType.Text;
					cmd.CommandText = "update " + sTABLE_NAME + "_CSTM" + ControlChars.CrLf;
					int nFieldIndex = 0;
					foreach(DataRow row in dtCustomFields.Rows)
					{
						// 01/11/2006   Uppercase looks better. 
						string sNAME   = Sql.ToString(row["NAME"  ]).ToUpper();
						string sCsType = Sql.ToString(row["CsType"]);
						// 01/13/2007   We need to truncate any long strings to prevent SQL error. 
						// String or binary data would be truncated. The statement has been terminated. 
						int    nMAX_SIZE = Sql.ToInteger(row["MAX_SIZE"]);
						DynamicControl ctlCustomField = new DynamicControl(ctlPARENT, sNAME);
						// 02/10/2008   Literals should not be updated. 
						if ( ctlCustomField.Exists && ctlCustomField.Type != "Literal" )
						{
							if ( nFieldIndex == 0 )
								cmd.CommandText += "   set ";
							else
								cmd.CommandText += "     , ";
							// 01/10/2006   We can't use a StringBuilder because the Sql.AddParameter function
							// needs to be able to replace the @ with the appropriate database specific token. 
							cmd.CommandText += sNAME + " = @" + sNAME + ControlChars.CrLf;
							
							DynamicControl ctlCustomField_File = new DynamicControl(ctlPARENT, sNAME + "_File");
							// 04/21/2006   If the type is Guid and it is accompanied by a File control, then assume it is an image. 
							if ( sCsType == "Guid" && ctlCustomField.Type == "HtmlInputHidden" && ctlCustomField_File.Exists )
							{
								LoadImage(ctlPARENT, gID, sNAME, trn);
							}
							// 04/21/2006   Even if there is no image to upload, we still need to update the field.
							// This is so that the image can be cleared. 
							switch ( sCsType )
							{
								case "Guid"    :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.ID          );  break;
								case "short"   :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.IntegerValue);  break;
								case "Int32"   :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.IntegerValue);  break;
								case "Int64"   :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.IntegerValue);  break;
								case "float"   :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.FloatValue  );  break;
								case "decimal" :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.DecimalValue);  break;
								case "bool"    :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.Checked     );  break;
								case "DateTime":  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.DateValue   );  break;
								default        :  Sql.AddParameter(cmd, "@" + sNAME, ctlCustomField.Text        , nMAX_SIZE);  break;
							}
							nFieldIndex++;
						}
					}
					if ( nFieldIndex > 0 )
					{
						cmd.CommandText += " where ID_C = @ID_C" + ControlChars.CrLf;
						Sql.AddParameter(cmd, "@ID_C", gID);
						cmd.ExecuteNonQuery();
					}
				}
			}
		}
コード例 #8
0
ファイル: SplendidDynamic.cs プロジェクト: huamouse/Taoqi
		public static bool LoadImage(SplendidControl ctlPARENT, Guid gParentID, string sFIELD_NAME, IDbTransaction trn)
		{
			bool bNewFile = false;
			HtmlInputFile fileIMAGE = ctlPARENT.FindControl(sFIELD_NAME + "_File") as HtmlInputFile;
			if ( fileIMAGE != null )
			{
				HttpPostedFile pstIMAGE  = fileIMAGE.PostedFile;
				if ( pstIMAGE != null )
				{
					long lFileSize      = pstIMAGE.ContentLength;
					long lUploadMaxSize = Sql.ToLong(HttpContext.Current.Application["CONFIG.upload_maxsize"]);
					if ( (lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize) )
					{
						throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString()));
					}
					// 04/13/2005   File may not have been provided. 
					if ( pstIMAGE.FileName.Length > 0 )
					{
						string sFILENAME       = Path.GetFileName (pstIMAGE.FileName);
						string sFILE_EXT       = Path.GetExtension(sFILENAME);
						string sFILE_MIME_TYPE = pstIMAGE.ContentType;
						
						Guid gImageID = Guid.Empty;
						SqlProcs.spIMAGES_Insert
							( ref gImageID
							, gParentID
							, sFILENAME
							, sFILE_EXT
							, sFILE_MIME_TYPE
							, trn
							);
						// 09/06/2008   PostgreSQL does not require that we stream the bytes, so lets explore doing this for all platforms. 
						if ( Sql.StreamBlobs(trn.Connection) )
						{
							SplendidDynamic.LoadFile(gImageID, pstIMAGE.InputStream, trn);
						}
						else
						{
							using ( BinaryReader reader = new BinaryReader(pstIMAGE.InputStream) )
							{
								byte[] binBYTES = reader.ReadBytes((int) pstIMAGE.InputStream.Length);
								SqlProcs.spIMAGES_CONTENT_Update(gImageID, binBYTES, trn);
							}
						}
						// 04/17/2006   Update the dynamic control so that it can be accessed below. 
						DynamicControl ctlIMAGE = new DynamicControl(ctlPARENT, sFIELD_NAME);
						ctlIMAGE.ID = gImageID;
						bNewFile = true;
					}
				}
			}
			return bNewFile;
		}
コード例 #9
0
ファイル: SplendidDynamic.cs プロジェクト: huamouse/Taoqi
		// 11/22/2010   For a ListView, it makes sense to allow a column to be added in a Pre Event and the column to be set in the Post Event. 
		public static void ApplyGridViewRules(string sGRID_NAME, SplendidControl parent, string sPRE_LOAD_XOML_FIELD_NAME, string sPOST_LOAD_XOML_FIELD_NAME, DataTable dt)
		{
			try
			{
				string sMODULE_NAME = sGRID_NAME.Split('.')[0];
				DataTable dtFields = SplendidCache.GridViewRules(sGRID_NAME);
				if ( dtFields.Rows.Count > 0 )
				{
					string sXOML = Sql.ToString(dtFields.Rows[0][sPRE_LOAD_XOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, dt);
						RuleExecution exec = new RuleExecution(validation, swThis);
						rules.Execute(exec);
					}
					sXOML = Sql.ToString(dtFields.Rows[0][sPOST_LOAD_XOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						foreach ( DataRow row in dt.Rows )
						{
							SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, row);
							RuleExecution exec = new RuleExecution(validation, swThis);
							rules.Execute(exec);
						}
					}
				}
			}
			catch(Exception ex)
			{
				SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
			}
		}
コード例 #10
0
ファイル: SplendidDynamic.cs プロジェクト: huamouse/Taoqi
		// 11/10/2010   Apply Business Rules. 
		public static void ApplyEditViewRules(string sEDIT_NAME, SplendidControl parent, string sXOML_FIELD_NAME, DataRow row)
		{
			try
			{
				string sMODULE_NAME = sEDIT_NAME.Split('.')[0];
				DataTable dtFields = SplendidCache.EditViewRules(sEDIT_NAME);
				if ( dtFields.Rows.Count > 0 )
				{
					string sXOML = Sql.ToString(dtFields.Rows[0][sXOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, row);
						RuleExecution exec = new RuleExecution(validation, swThis);
						rules.Execute(exec);
					}
				}
			}
			catch(Exception ex)
			{
				//SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
				// 11/10/2010   Throwing an exception will be the preferred method of displaying an error. 
				// We want to skip the filler message "The following error was encountered while executing method Taoqi.SplendidControlThis.Throw". 
				if ( ex.InnerException != null )
					throw(new Exception(ex.InnerException.Message));
				else
					throw(new Exception(ex.Message));
			}
		}
コード例 #11
0
ファイル: Utils.cs プロジェクト: huamouse/Taoqi
		// 03/14/2014   DUPLICATE_CHECHING_ENABLED enables duplicate checking. 
		// Duplicate check for EditView will provide input data from Form variables. 
		public static int DuplicateCheck(HttpApplicationState Application, IDbConnection con, string sMODULE_NAME, Guid gID, SplendidControl ctl, DataRow rowCurrent)
		{
			int nDuplicates = 0;
			string sGRID_NAME = sMODULE_NAME + ".SearchDuplicates";
			DataTable dtGridView = SplendidCache.GridViewColumns(sGRID_NAME);
			if ( dtGridView != null && dtGridView.Rows.Count > 0 )
			{
				DbProviderFactory dbf = DbProviderFactories.GetFactory();
				using ( IDbCommand cmd = con.CreateCommand() )
				{
					string sTABLE_NAME = Crm.Modules.TableName(sMODULE_NAME);
					// 04/10/2014   The first thought was just to use a count(*), but by getting all fields for matching records, we allow business rules to further filter the result. 
					cmd.CommandText = "select *" + ControlChars.CrLf
					                + "  from vw" + sTABLE_NAME + "_List" + ControlChars.CrLf;
					Security.Filter(cmd, sMODULE_NAME, "list");
					if ( !Sql.IsEmptyGuid(gID) )
					{
						cmd.CommandText += "  and ID <> @ID" + ControlChars.CrLf;
						Sql.AddParameter(cmd, "@ID", gID);
					}
					
					int nValues = 0;
					foreach(DataRow rowSearch in dtGridView.Rows)
					{
						string sDATA_FIELD  = Sql.ToString (rowSearch["DATA_FIELD" ]);
						string sDATA_FORMAT = Sql.ToString (rowSearch["DATA_FORMAT"]);
						// 03/16/2014   When searching for duplicates, multiple fields can match, but don't match an empty field. 
						string sVALUE = new DynamicControl(ctl, rowCurrent, sDATA_FIELD).Text;
						if ( !Sql.IsEmptyString(sVALUE) )
						{
							Sql.AppendParameter(cmd, sVALUE, sDATA_FIELD);
							nValues++;
						}
					}
					// 03/16/2014   If no required fields were specified, then don't search. 
					if ( nValues > 0 )
					{
						using ( DbDataAdapter da = dbf.CreateDataAdapter() )
						{
							((IDbDataAdapter)da).SelectCommand = cmd;
							using ( DataTable dtDuplicates = new DataTable() )
							{
								da.Fill(dtDuplicates);

								SplendidDynamic.ApplyGridViewRules(sGRID_NAME, ctl, "PRE_LOAD_EVENT_XOML", "POST_LOAD_EVENT_XOML", dtDuplicates);
								foreach ( DataRow rowDuplicates in dtDuplicates.Rows )
								{
									if ( rowDuplicates.RowState != DataRowState.Deleted )
									{
										nDuplicates++;
									}
								}
							}
						}
					}
				}
			}
			return nDuplicates;
		}