public string PasteItem(string strFID, string strTID, string strSerial) //strfid为源复制的监测项目ID,strTid为目标复制的监测项目ID
        {
            i3.DataAccess.Channels.Env.Point.Common.CommonAccess com = new Common.CommonAccess();
            bool      b            = true;
            string    Msg          = string.Empty;
            DataTable dt           = new DataTable();
            string    sql          = string.Empty;
            ArrayList list         = new ArrayList();
            string    strID        = string.Empty;
            string    originalType = this.GetType(strFID);
            string    targetType   = this.GetType(strTID);

            if (!string.IsNullOrEmpty(originalType) && !string.IsNullOrEmpty(targetType))
            {
                if (originalType == targetType)
                {
                    #region//都为相同类型时,可以复制
                    sql = "select * from " + TEnvPPolluteItemVo.T_ENV_P_POLLUTE_ITEM_TABLE + " where POINT_ID='" + strFID + "'";
                    dt  = SqlHelper.ExecuteDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        sql = "delete from " + TEnvPPolluteItemVo.T_ENV_P_POLLUTE_ITEM_TABLE + " where POINT_ID='" + strTID + "'";
                        list.Add(sql);
                        foreach (DataRow row in dt.Rows)
                        {
                            strID = GetSerialNumber(strSerial);
                            sql   = com.getCopySql(TEnvPPolluteItemVo.T_ENV_P_POLLUTE_ITEM_TABLE, row, "", "", strTID, strID);
                            list.Add(sql);
                        }
                        if (SqlHelper.ExecuteSQLByTransaction(list))
                        {
                            b = true;
                        }
                        else
                        {
                            b   = false;
                            Msg = "数据库更新失败";
                        }
                    }
                    #endregion
                }
                else
                {
                    Msg = "两个监测点的类型不一致,不能复制";
                }
            }
            if (b)
            {
                return("({result:true,msg:''})");
            }
            else
            {
                return("({result:false,msg:'" + Msg + "'})");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 监测项目的复制逻辑
        /// </summary>
        /// <param name="strFID"></param>
        /// <param name="strTID"></param>
        /// <param name="strSerial"></param>
        /// <returns></returns>
        public string PasteItem(string strFID, string strTID, string strSerial)
        {
            i3.DataAccess.Channels.Env.Point.Common.CommonAccess com = new Common.CommonAccess();
            bool      b     = true;
            string    Msg   = string.Empty;
            DataTable dt    = new DataTable();
            string    sql   = string.Empty;
            ArrayList list  = new ArrayList();
            string    strID = string.Empty;

            sql = "select * from " + TEnvPSolidItemVo.T_ENV_P_SOLID_ITEM_TABLE + " where POINT_ID='" + strFID + "'";
            dt  = SqlHelper.ExecuteDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                sql = "delete from " + TEnvPSolidItemVo.T_ENV_P_SOLID_ITEM_TABLE + " where POINT_ID='" + strTID + "'";
                list.Add(sql);

                foreach (DataRow row in dt.Rows)
                {
                    strID = GetSerialNumber(strSerial);
                    sql   = com.getCopySql(TEnvPSolidItemVo.T_ENV_P_SOLID_ITEM_TABLE, row, "", "", strTID, strID);
                    list.Add(sql);
                }
                if (SqlHelper.ExecuteSQLByTransaction(list))
                {
                    b = true;
                }
                else
                {
                    b   = false;
                    Msg = "数据库更新失败";
                }
            }

            if (b)
            {
                return("({result:true,msg:''})");
            }
            else
            {
                return("({result:false,msg:'" + Msg + "'})");
            }
        }