예제 #1
0
        public static string getFormColumnsAndDataForApproval(JObject jObject, int level)
        {
            string costSharingRecordId = jObject["costSharingRecordId"].ToString();

            JObject res = new JObject();

            if (costSharingRecordId == null || "".Equals(costSharingRecordId))
            {
                res.Add("ErrCode", 1);
                res.Add("ErrMsg", "缺少参数");

                return(res.ToString());
            }

            DataSet ds = NewBranchUpdateSrv.getFormColumnsAndDataForApproval(costSharingRecordId, level);

            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                res.Add("ErrCode", 1);
                res.Add("ErrMsg", "暂无数据");

                return(res.ToString());
            }

            DataTable dt = ds.Tables[0];

            res.Add("ErrCode", 0);

            JObject detailJObject = new JObject();

            dt.Columns.Add("columnRelativeData", typeof(string));

            foreach (DataRow dr in dt.Rows)
            {
                // 表单列中加入对应的表内容基础信息
                string    tableName = dr["RelativeTable"].ToString();
                DataTable columnRelativeDataTable = NewBranchUpdateSrv.showColumnRelativeData(tableName);
                if (columnRelativeDataTable != null && columnRelativeDataTable.Rows.Count > 0)
                {
                    dr["columnRelativeData"] = JsonHelper.DataTable2Json(columnRelativeDataTable);
                }

                string fieldName         = dr["FieldName"].ToString();
                string fieldValueId      = dr["NewValue"].ToString();
                string fieldValue        = dr["OldValue"].ToString();
                string relativeFieldName = dr["RelativeFieldName"].ToString();

                detailJObject.Add(fieldName, fieldValue);
                detailJObject.Add(fieldName + "Id", fieldValueId);
                detailJObject.Add(fieldName + "relativeFieldName", relativeFieldName);
            }

            res.Add("detail", detailJObject.ToString());
            res.Add("column", JsonHelper.DataTable2Json(dt));

            return(res.ToString());
        }
예제 #2
0
        public static string getFormColumnsAndDataForSubmit(JObject jObject, UserInfo userInfo)
        {
            string newCostSharingId = jObject["newCostSharingId"].ToString();

            JObject res = new JObject();

            if (newCostSharingId == null || "".Equals(newCostSharingId))
            {
                res.Add("ErrCode", 1);
                res.Add("ErrMsg", "缺少参数");

                return(res.ToString());
            }

            DataSet ds = NewBranchUpdateSrv.getFormColumnsAndDataForSubmit(newCostSharingId, userInfo);

            if (ds == null)
            {
                res.Add("ErrCode", 1);
                res.Add("ErrMsg", "数据库查询错误");

                return(res.ToString());
            }

            DataTable isUpdateFinishedTable = ds.Tables[0];
            DataTable columnDataTable       = ds.Tables[1];
            DataTable contentDataTable      = ds.Tables[2];

            if (isUpdateFinishedTable != null && isUpdateFinishedTable.Rows.Count > 0)
            {
                res.Add("ErrCode", 2);
                res.Add("ErrMsg", "该网点存在未结束的更新流程,请勿重复更新");

                return(res.ToString());
            }

            if (columnDataTable.Rows.Count == 0)
            {
                res.Add("ErrCode", 3);
                res.Add("ErrMsg", "暂无对应列数据");
            }
            else if (contentDataTable.Rows.Count == 0)
            {
                res.Add("ErrCode", 3);
                res.Add("ErrMsg", "暂无对应网点数据");
            }
            else
            {
                res.Add("ErrCode", 0);

                //res.Add("column", JsonHelper.DataTable2Json(columnDataTable));  // 表单列
                columnDataTable.Columns.Add("columnRelativeData", typeof(string));

                JObject columnDataJObjet = new JObject();

                // 从json中提取回显数据
                foreach (DataRow dr in columnDataTable.Rows)
                {
                    // 表单列中加入对应的表内容基础信息
                    string    tableName = dr["RelativeTable"].ToString();
                    DataTable columnRelativeDataTable = NewBranchUpdateSrv.showColumnRelativeData(tableName);
                    if (columnRelativeDataTable != null && columnRelativeDataTable.Rows.Count > 0)
                    {
                        dr["columnRelativeData"] = JsonHelper.DataTable2Json(columnRelativeDataTable);
                    }

                    string columnName = dr["FieldName"].ToString();

                    if (contentDataTable.Columns.Contains(columnName))
                    {
                        // 如果包含 则是在new_cost_sharing表中除datajson外的数据
                        string columnData = contentDataTable.Rows[0][columnName].ToString();

                        columnDataJObjet.Add(columnName, columnData);
                    }
                    else
                    {
                        // 如果不包含,则是dataJson的数据
                        string  columnData  = contentDataTable.Rows[0]["DataJson"].ToString();
                        JObject tempJObject = JsonHelper.DeserializeJsonToObject <JObject>(columnData);
                        if (tempJObject.Property(columnName) == null || "".Equals(tempJObject.Property(columnName).ToString()))
                        {
                            columnDataJObjet.Add(columnName, "");
                        }
                        else
                        {
                            columnDataJObjet.Add(columnName, tempJObject[columnName]);
                        }
                    }

                    string fieldType = dr["FieldType"].ToString();

                    if ("select".Equals(fieldType) && !"".Equals(columnDataJObjet[columnName].ToString()))
                    {
                        // 找到id字段
                        string relativeFieldName = dr["RelativeFieldName"].ToString();
                        if ("".Equals(relativeFieldName))
                        {
                            // 主要是处理开发人字段
                            string relativeTable = dr["RelativeTable"].ToString();
                            string tempSql       = string.Format("select userid from {0} where username = '******'",
                                                                 relativeTable, columnDataJObjet[columnName]);
                            try
                            {
                                columnDataJObjet.Add(columnName + "Id", SqlHelper.Find(tempSql).Tables[0].Rows[0][0].ToString());
                            }
                            catch (IndexOutOfRangeException e)
                            {
                                columnDataJObjet.Add(columnName + "Id", 0);
                            }
                        }
                        else
                        {
                            string columnDataId = contentDataTable.Rows[0][relativeFieldName].ToString();
                            columnDataJObjet.Add(columnName + "Id", columnDataId);
                        }
                    }
                    else
                    {
                        columnDataJObjet.Add(columnName + "Id", 0);
                    }
                }

                res.Add("column", JsonHelper.DataTable2Json(columnDataTable)); // 表单列
                res.Add("detail", columnDataJObjet.ToString());                // 回显详情内容
            }

            return(res.ToString());
        }