public void CreateActionPhpScript(string objectName, string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
        {
            string connName = GetConnectionCodeName();

            if (string.CompareOrdinal(methodName, "ExecuteWithParameterValues") == 0)
            {
                if (_sql != null && connect != null)
                {
                    code.Add("$GLOBALS[\"debugError\"] = '';\r\n");
                    code.Add("$msql = new JsonSourceMySql();\r\n");
                    code.Add(string.Format(CultureInfo.InvariantCulture, "$msql->SetCredential($this->{0});\r\n", connName));
                    code.Add("$msql->SetDebug($this->DEBUG);\r\n");
                    //
                    string        sql;
                    string[]      sqlParams;
                    List <string> inputParams  = new List <string>();
                    List <string> outputParams = new List <string>();
                    if (this.IsStoredProc)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("call ");
                        sb.Append(_sql.SQL);
                        sb.Append("(");
                        DatabaseExecuter de = this as DatabaseExecuter;
                        DbParameterList  ps = de.Parameters;
                        if (ps != null && ps.Count > 0)
                        {
                            ParameterDirection[] pds = de.Param_Directions;
                            for (int i = 0; i < ps.Count; i++)
                            {
                                if (i > 0)
                                {
                                    sb.Append(",");
                                }
                                ParameterDirection pd = ParameterDirection.Input;
                                if (pds != null && pds.Length > i)
                                {
                                    pd = pds[i];
                                }
                                switch (pd)
                                {
                                case ParameterDirection.Input:
                                    inputParams.Add(ps[i].Name);
                                    sb.Append(" ? ");
                                    break;

                                case ParameterDirection.InputOutput:
                                    outputParams.Add(ps[i].Name);
                                    sb.Append(string.Format(CultureInfo.InvariantCulture, " @{0} ", ps[i].Name));
                                    break;

                                case ParameterDirection.Output:
                                    outputParams.Add(ps[i].Name);
                                    sb.Append(string.Format(CultureInfo.InvariantCulture, " @{0} ", ps[i].Name));
                                    break;
                                }
                            }
                            sqlParams = inputParams.ToArray();
                        }
                        else
                        {
                            sqlParams = new string[] { };
                        }
                        sb.Append(")");
                        sql = sb.ToString();
                    }
                    else
                    {
                        sql       = _sql.SQL;
                        sqlParams = EasyQuery.GetParameterNames(sql, connect.NameDelimiterBegin, connect.NameDelimiterEnd);
                        if (sqlParams != null)
                        {
                            for (int i = 0; i < sqlParams.Length; i++)
                            {
                                sql = sql.Replace(sqlParams[i], "?");
                            }
                        }
                    }
                    code.Add(string.Format(CultureInfo.InvariantCulture, "$sql = \"{0} \";\r\n", sql));
                    code.Add("$ps = array();\r\n");
                    if (this.Parameters != null)
                    {
                        for (int i = 0; i < sqlParams.Length; i++)
                        {
                            int k = this.Parameters.GetIndex(sqlParams[i]);
                            if (k < 0)
                            {
                                throw new ExceptionLimnorDatabase("Query Parameter [{0}] not found", sqlParams[i]);
                            }
                            DbCommandParam dp = this.Parameters[k];
                            code.Add("$p = new SqlClientParameter();\r\n");
                            code.Add(string.Format(CultureInfo.InvariantCulture, "$p->name = '{0}';\r\n", dp.Name));
                            code.Add(string.Format(CultureInfo.InvariantCulture, "$p->type = '{0}';\r\n", ValueConvertor.OleDbTypeToPhpMySqlType(dp.Type)));
                            code.Add(string.Format(CultureInfo.InvariantCulture, "$p->value = {0};\r\n", parameters[k]));
                            code.Add("$ps[] = $p;\r\n//\r\n");
                        }
                    }
                    if (outputParams.Count > 0)
                    {
                        StringBuilder sb2 = new StringBuilder();
                        sb2.Append("SELECT ");
                        for (int i = 0; i < outputParams.Count; i++)
                        {
                            if (i > 0)
                            {
                                sb2.Append(",");
                            }
                            sb2.Append(string.Format(CultureInfo.InvariantCulture, "@{0} AS {0} ", outputParams[i]));
                        }
                        string s2 = string.Format(CultureInfo.InvariantCulture, "$qry{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
                        code.Add(string.Format(CultureInfo.InvariantCulture, "{0} = \"{1}\";\r\n", s2, sb2.ToString()));
                        code.Add(string.Format(CultureInfo.InvariantCulture, "$this->{0}->ExecuteWithOutputs($sql,{1},$ps,$msql);\r\n", this.Site.Name, s2));
                        for (int i = 0; i < outputParams.Count; i++)
                        {
                            code.Add(string.Format(CultureInfo.InvariantCulture, "$this->{0}->{1}=$this->{0}->outputValues['{1}'];\r\n", this.Site.Name, outputParams[i]));
                        }
                    }
                    else
                    {
                        code.Add(string.Format(CultureInfo.InvariantCulture, "$this->{0}->ExecuteNonQuery($sql,$ps,$msql);\r\n", this.Site.Name));
                    }
                    if (!string.IsNullOrEmpty(returnReceiver))
                    {
                        code.Add(string.Format(CultureInfo.InvariantCulture,
                                               "{0}=$this->{1}->errorMessage;\r\n", returnReceiver, this.Site.Name));
                    }
                    code.Add(string.Format(CultureInfo.InvariantCulture, "$this->SetServerComponentName('{0}');\r\n", this.Site.Name));
                }
            }
        }
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            List <PropertyDescriptor> lst = new List <PropertyDescriptor>();
            DatabaseExecuter          de  = this as DatabaseExecuter;

            if (de != null)
            {
                ParameterDirection[] pds = de.Param_Directions;
                if (pds != null && pds.Length > 0)
                {
                    DbParameterList pms = de.Parameters;
                    if (pms != null && pms.Count > 0)
                    {
                        for (int i = 0; i < pms.Count; i++)
                        {
                            ParameterDirection pd = ParameterDirection.Input;
                            if (pds != null && pds.Length > i)
                            {
                                pd = pds[i];
                            }
                            if (pd == ParameterDirection.Output || pd == ParameterDirection.InputOutput)
                            {
                                lst.Add(new PropertyDescriptorParam(pms[i]));
                            }
                        }
                    }
                }
            }
            PropertyDescriptorCollection ps = TypeDescriptor.GetProperties(this, attributes, true);

            if (typeof(EasyUpdator).Equals(this.GetType()) || typeof(DatabaseExecuter).Equals(this.GetType()))
            {
                foreach (PropertyDescriptor p in ps)
                {
                    lst.Add(p);
                }
            }
            else
            {
                bool forBrowsing = VPLUtil.GetBrowseableProperties(attributes);
                foreach (PropertyDescriptor p in ps)
                {
                    if (_subClassReadOnlyProperties.Contains(p.Name))
                    {
                        if (forBrowsing)
                        {
                            object v = p.GetValue(this);
                            string s;
                            if (v == null)
                            {
                                s = string.Empty;
                            }
                            else
                            {
                                s = v.ToString();
                            }
                            lst.Add(new PropertyDescriptorForDisplay(this.GetType(), p.Name, s, new Attribute[] { }));
                        }
                    }
                    else
                    {
                        lst.Add(p);
                    }
                }
            }
            return(new PropertyDescriptorCollection(lst.ToArray()));
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             DatabaseExecuter der = context.Instance as DatabaseExecuter;
             if (der != null)
             {
                 string          sText = der.ExecutionCommand.SQL;
                 ExecParameter[] ps    = new ExecParameter[der.ExecutionCommand.ParamCount];
                 for (int i = 0; i < der.ExecutionCommand.ParamCount; i++)
                 {
                     ExecParameter p = new ExecParameter();
                     p.Name      = der.ExecutionCommand.Param_Name[i];
                     p.Type      = der.ExecutionCommand.Param_OleDbType[i];
                     p.DataSize  = der.Param_DataSize[i];
                     p.Direction = der.Param_Directions[i];
                     ps[i]       = p;
                 }
                 DialogDbCommand dlg = new DialogDbCommand();
                 dlg.LoadData(sText, der.IsStoredProc, ps);
                 if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                 {
                     SQLNoneQuery sq = new SQLNoneQuery();
                     sq.CommandType = enmNonQueryType.StoredProcedure;
                     sq.SQL         = dlg.RetSQL;
                     ps             = dlg.RetParameters;
                     string[]             names = new string[dlg.RetParameters.Length];
                     OleDbType[]          types = new OleDbType[dlg.RetParameters.Length];
                     int[]                sizes = new int[dlg.RetParameters.Length];
                     ParameterDirection[] pds   = new ParameterDirection[dlg.RetParameters.Length];
                     //
                     for (int i = 0; i < dlg.RetParameters.Length; i++)
                     {
                         names[i] = dlg.RetParameters[i].Name;
                         types[i] = dlg.RetParameters[i].Type;
                         sizes[i] = dlg.RetParameters[i].DataSize;
                         pds[i]   = dlg.RetParameters[i].Direction;
                     }
                     //
                     sq.Param_Name        = names;
                     sq.Param_OleDbType   = types;
                     der.ExecutionCommand = sq;
                     DbParameterList pl = new DbParameterList(sq.Parameters);
                     der.SetParameterList(pl);
                     der.Param_DataSize   = sizes;
                     der.Param_Directions = pds;
                     if (dlg.IsStoredProc)
                     {
                         sq.CommandType = enmNonQueryType.StoredProcedure;
                     }
                     else
                     {
                         sq.CommandType = enmNonQueryType.Script;
                     }
                     value = sq;
                 }
             }
         }
     }
     return(value);
 }