/// <summary> /// ��Ŀ����[����Ŀ��Ŀ] /// </summary> /// <returns></returns> public bool ColumnsCopy(String id, String newid) { bool ret = true; DAO db = new DAO(); try { // �����ж�id�Ƿ���� string sql = "SELECT * FROM JpColumns WHERE cid = @id"; SqlParameter[] sqlparam = { db.MakeInParam("@id",SqlDbType.VarChar,id), }; DataTable dt = db.GetDataTable(sql, sqlparam); if (dt.Rows.Count <= 0) { return false; } // �ж�newid�����Ƿ�Ϊ3�������� if (newid.Length % 3 != 0) return false; // ������ȴ���3������һ����Ŀ�Ƿ���� if (newid.Length > 3) { String pid = newid.Substring(0, newid.Length - 3); sql = "SELECT * FROM JpColumns WHERE cid = @cid"; sqlparam = new SqlParameter[] { db.MakeInParam("@cid",SqlDbType.VarChar,pid), }; DataTable dt1 = db.GetDataTable(sql, sqlparam); if (dt1.Rows.Count <= 0) { return false; } } // �ж�newid�Ƿ���� sql = "SELECT * FROM JpColumns WHERE cid = @cid"; sqlparam = new SqlParameter[] { db.MakeInParam("@cid",SqlDbType.VarChar,newid), }; DataTable dt2 = db.GetDataTable(sql, sqlparam); if (dt2.Rows.Count > 0) { return false; } // ������ID������Ŀ���浽dtsub�� sql = "SELECT cid FROM JpColumns WHERE cid LIKE @cid"; sqlparam = new SqlParameter[]{ db.MakeInParam("@cid",SqlDbType.VarChar,id + "%"), }; DataTable dtsub = db.GetDataTable(sql, sqlparam); // ���θ�����Ŀ for (int i = 0; i < dtsub.Rows.Count; i++) { String cid = dtsub.Rows[i]["cid"].ToString(); //MpColumn column = new MpColumn(cid); JpColumns column = new JpColumns(cid); //cid = cid.replaceFirst(id, newid); string strTemp = id; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(id); if (reg.IsMatch(strTemp)) { strTemp = reg.Replace(cid, newid, 1); } cid = strTemp; //column.duplicate(cid); column.ColumnCopy(cid); } } catch { ret = false; } finally { db.Close(); db.Dispose(); } return ret; }