Ejemplo n.º 1
0
		protected void ParseDeleteQuery()
		{
			TableEntity te;
			string[] pvs;
			string pv;
			string sql = "";
			string pk = Form["pk"];
			string tb = FormatFieldName(Form["tb"]);
			te = new TableEntity(tb, Database);
			foreach (string key in Form.Keys)
			{
				string val;
				string fld = key;
				if (key.IndexOf("fld_") == 0 && key.Length > 4)
				{
					fld = key.Substring(4, key.Length - 4);
				}
				else
				{
					continue;
				}
				val = Form[key];
				if (!string.IsNullOrEmpty(val))
				{
					pvs = val.Split(',');
					foreach (string pval in pvs)
					{
						sql += te.MakeOpSql(fld, pval) + " or ";
					}
					if (pvs.Length > 0)
					{
						sql = sql.Substring(0, sql.Length - 4);
					}
					sql += " and ";
				}
			}
			if (!string.IsNullOrEmpty(sql))
			{
				sql = sql.Substring(0, sql.Length - 5);
			}
			//pv = Form["fld_" + pk];
			////pk = FormatFieldName(pk);
			//if (!string.IsNullOrEmpty(pv))
			//{
			//    pvs = pv.Split(',');
			//    foreach (string pval in pvs)
			//    {
			//        sql += te.MakeOpSql(pk, pval) + " or ";
			//    }
			//    if (pvs.Length > 1)
			//    {
			//        sql = sql.Substring(0, sql.Length - 4);
			//    }
			//}
			sql = te.MakeDeleteSql(sql);
			Sql = sql;
		}
Ejemplo n.º 2
0
		protected void ParseUpdateQuery()
		{
			DataColumnCollection cols;
			TableEntity te;
			string pv, sql;
			string tb = FormatFieldName(Form["tb"]);
			string pk = Form["pk"];
			te = new TableEntity(tb, Database);
			DataRow dr = te.GetNewRow();
			cols = te.GetColumns();
			pv = Form["fld_" + pk];
			foreach (DataColumn col in cols)
			{
				string v = Form["fld_" + col.ColumnName];
				if (!string.IsNullOrEmpty(v))
				{
					string rlt;
					te.MakeFieldSql(col.ColumnName, v, out rlt, false, false);
					dr[col.ColumnName] = rlt;
				}
			}
			sql = te.MakeUpdateSql(dr, te.MakeOpSql(pk, pv), true, false);
			Sql = sql;
		}