Exemple #1
0
        public frmNavQuery(QueryFieldCollection queryfields, InfoBindingSource bs, InfoNavigator nav)
        {
            //language = CliSysMegLag.GetClientLanguage();
            language = CliUtils.fClientLang;
            queryFields = queryfields;

            if (queryfields == null || queryfields.Count == 0)
            {
                DataColumnCollection dcc = ((InfoDataSet)bs.GetDataSource()).RealDataSet.Tables[bs.DataMember].Columns;
                colNum = dcc.Count;
                colName = new string[colNum];
                for (int j = 0; j < colNum; j++)
                {
                    colName[j] = dcc[j].ColumnName;
                }
            }
            else
            {
                colNum = queryfields.Count;
                colName = new string[colNum];
                for (int j = 0; j < colNum; j++)
                {
                    colName[j] = queryfields[j].FieldName;
                }
            }
            bSource = bs;
            infoNavigator = nav;
            InitializeComponent();
            InitializeQueryConditionItem();
        }
Exemple #2
0
 public frmAnyQuery(AnyQuery aq, InfoNavigator infoN, bool executeSQL)
 {
     aInfoNavigator = infoN;
     innerAnyQuery = aq;
     isExecute = executeSQL;
     InitializeComponent();
     Create();
 }
Exemple #3
0
 public String Execute(InfoNavigator aInfoNavigator, bool executeSQL)
 {
     if (faq == null || !this.KeepCondition)
         faq = new frmAnyQuery(this, aInfoNavigator, executeSQL);
     faq.ValueControlEdit += new EventHandler(faq_ValueControlEdit);
     DialogResult dr = faq.ShowDialog();
     if (dr == DialogResult.Yes && faq.Where != String.Empty)
         return faq.Where;
     else
         return null;
 }
Exemple #4
0
        internal bool ValidateRow(int index, DataRowView rowView, InfoNavigator nav)
        {
            bool isValidateSuccessful = true;
            bool continueToValidate = true;
            DataTable table = rowView.Row.Table;

            if (this.ValidActive)
            {
                foreach (FieldItem fieldItem in this.FieldItems)
                {
                    if (fieldItem.FieldName == null || fieldItem.FieldName == "")
                    {
                        continue;
                    }
                    DataColumn column = table.Columns[fieldItem.FieldName];
                    if (column != null)
                    {
                        // Validate funtion
                        Object obj = fieldItem.Validate;
                        if (obj != null)
                        {
                            string validateValue = GetValidateValue(fieldItem.Validate.Trim());
                            if (continueToValidate && validateValue != null && validateValue != "")
                            {
                                if (OwnerComp is Form)
                                {
                                    Type t = OwnerComp.GetType();
                                    MethodInfo method = null;
                                    try
                                    {
                                        method = t.GetMethod(validateValue, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                                    }
                                    catch (AmbiguousMatchException)
                                    {
                                        MessageBox.Show("More than one " + fieldItem.Validate.Trim() + " Method found, Please Rename the Validate Method of Field " + fieldItem.FieldName);
                                        continue;
                                    }
                                    if (method == null || method.ReturnType.FullName != "System.Boolean" || method.GetParameters().GetLength(0) != 1/* || method.GetParameters()[0].ParameterType.FullName != "System.Object"*/)
                                    {
                                        //language = CliSysMegLag.GetClientLanguage();
                                        String message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "DefaultValidate", "msg_ValidMethodNotFound");
                                        Exception ex = new Exception(string.Format(message, validateValue + "()"));
                                        CliUtils.Application_ThreadException(null, new System.Threading.ThreadExceptionEventArgs(ex));
                                        goto EndValidateField; // add by andy 2006.06.07
                                    }
                                    bool isValid = (bool)method.Invoke(OwnerComp, new object[] { rowView.Row[column].ToString() });
                                    if (isValid == false)
                                    {
                                        isValidateSuccessful = false;
                                        ShowMessageEventHandler showMessageHandler = Events[EventShowMessage] as ShowMessageEventHandler;

                                        if (showMessageHandler == null)
                                        {
                                            string message = "";
                                            if (fieldItem.WarningMsg != null && fieldItem.WarningMsg != "")
                                            {
                                                message = fieldItem.WarningMsg;
                                            }
                                            else
                                            {
                                                message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "DefaultValidate", "msg_DefaultValidateCheckMethod");
                                            }
                                            this.Warn(message);
                                        }
                                        else
                                        {
                                            ShowMessageEventArgs showMessageArgs = new ShowMessageEventArgs(true);
                                            showMessageArgs.Collection = this.m_bindingSource.List;
                                            showMessageArgs.Index = index;
                                            showMessageArgs.FieldName = fieldItem.FieldName;
                                            OnShowMessage(showMessageArgs);
                                            continueToValidate = showMessageArgs.Continue;
                                        }
                                        this.BindingSource.CheckSucess = false;
                                        //2006/08/01
                                        if (nav != null)
                                        {
                                            this.BindingSource.bChk = true;
                                            this.BindingSource.CheckSucess = false;
                                            //modified by lily 2007/4/25 for state
                                            if (nav.GetCurrentState() != "Inserting")
                                            {
                                                nav.SetState("Editing");
                                            }
                                        }
                                        //2006/08/01
                                    }

                                }
                            EndValidateField: ;
                            }
                        }
                    }
                }
                // Invoke OnValidate
                OnValidate(new ValidateEventArgs(isValidateSuccessful));
            }

            return isValidateSuccessful;
        }