Пример #1
0
        /// <summary>
        /// 提交表单,返回行号
        /// </summary>
        /// <param name="tableId"></param>
        /// <param name="form"></param>
        /// <returns></returns>
        public int SubmitRow(int tableId, NameValueCollection form)
        {
            //table name :cms_form_tableid
            //column name:field_tableid_columnid
            //button name:cms_form_tableid_btn


            StringBuilder sb     = new StringBuilder();
            Regex         cregex = new Regex("^field_\\d+_(\\d+)$");

            IDictionary <int, string> rowsData = new Dictionary <int, string>();

            foreach (string key in form)
            {
                if (cregex.IsMatch(key))
                {
                    int columnId = int.Parse(cregex.Match(key).Groups[1].Value);
                    //sb.Append("$").Append(columnID.ToString()).Append("=").Append(form[key]);
                    rowsData.Add(columnId, form[key]);
                }
            }

            TableRowData[] rows = new TableRowData[rowsData.Count];

            int i = 0;

            foreach (KeyValuePair <int, string> pair in rowsData)
            {
                rows[i] = new TableRowData
                {
                    Value = pair.Value,
                    Cid   = pair.Key
                };
                ++i;
            }


            return(dal.CreateRow(tableId, rows));
        }