Beispiel #1
0
        public void UpdateTable(object table, string view, object parameters, string rowKey, ref string script, ref bool isInvalid)
        {
            DataRow drParams = parameters as DataRow;

            CiTable ciTable = table as CiTable;

            if (ciTable != null && drParams != null)
            {
                CiMacro ciMacro = ciTable.UpdateMacro;
                if (ciMacro != null)
                {
                    ciMacro.Run(drParams);
                    script    = ciMacro.ResultScript;
                    isInvalid = !MyUtils.IsEmpty(ciMacro.ErrorMessage);
                }
            }
        }
Beispiel #2
0
        public DataTable SelectTable(object table, string view, object parameters, ref string script)
        {
            DataRow   drParams = parameters as DataRow;
            DataTable dt       = null;

            CiTable ciTable = table as CiTable;

            if (ciTable != null)
            {
                if (parameters != null && parameters.GetType() == typeof(bool))
                {
                    // Do nothing - but can't remember what this is for???
                    throw new System.Exception("Aha!");
                }
                else if (ciTable.SelectMacro != null)
                {
                    CiMacro ciMacro = ciTable.SearchMacro;
                    if (ciMacro != null)
                    {
                        ciMacro.Run(drParams, true);
                        dt     = ciMacro.ResultTable;
                        script = ciMacro.ResultScript;
                    }
                }
                else if (ciTable.DataSource != null)
                {
                    dt = ciTable.DataTable;
                }

                if (dt == null)
                {
                    dt = new DataTable();
                }

                AddExpressionColumns(ciTable, dt, drParams);

                if (MyWebUtils.GetNumberOfColumns(dt) > 0 && !dt.Columns.Contains("RowKey"))
                {
                    dt.Columns.Add("RowKey").Expression = CreateRowKeyExpression(ciTable.RowKey);
                }
            }

            return(dt);
        }
Beispiel #3
0
        public void InsertTable(object table, string view, object parameters, ref string rowKey, ref string script, ref bool isInvalid)
        {
            DataRow drParams = parameters as DataRow;

            CiTable ciTable = table as CiTable;

            if (ciTable != null)
            {
                CiMacro ciMacro = ciTable.InsertMacro;
                if (ciMacro != null)
                {
                    ciMacro.Run(drParams);
                    script    = ciMacro.ResultScript;
                    isInvalid = !MyUtils.IsEmpty(ciMacro.ErrorMessage);

                    DataTable dt = ciMacro.ResultTable;
                    if (MyWebUtils.GetNumberOfRows(dt) > 0)
                    {
                        DataRow dr = dt.Rows[0];
                        int     i  = 0;
                        foreach (string key in ciTable.RowKeyNames)
                        {
                            if (i++ > 0)
                            {
                                rowKey += ",";
                            }

                            if (dt.Columns.Contains(key))
                            {
                                rowKey += MyUtils.Coalesce(dr[key], "").ToString();
                            }
                        }
                    }
                }
            }
        }