求:万能查询,设计思路!结帖给分! 前边发过的同名帖子,已经结帖。先新开帖,欢迎大家继续讨论。

lnzyquan 2005-09-02 11:18:40
原帖子地址:http://community.csdn.net/Expert/topic/4240/4240215.xml?temp=.6030084

在这里感谢:JasonHeung(拥有一切也不过就这样笑着哭) 的回复。


to : JasonHeung(拥有一切也不过就这样笑着哭)
谢谢你的指导啊,看来你做过这个东西,

能说说你是怎么存储数据的吗??

用数据库是吗??
...全文
220 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
LiaoWu 2005-09-21
  • 打赏
  • 举报
回复
非常好的東西!
JasonHeung 2005-09-07
  • 打赏
  • 举报
回复
/// <summary>
/// 提供增加接口的集合类
/// </summary>
public class AddCollectionBase : CollectionBase
{
public int Add(object obj)
{
return List.Add(obj);
}
}


lnzyquan 2005-09-02
  • 打赏
  • 举报
回复
to:JasonHeung(拥有一切也不过就这样笑着哭) (

你应该在使用它之前将硬盘用Ghost备份。用完再恢复。
这个什么意思??

还有:AddCollectionBase能发给我吗??^_^ 就缺少这个类了。
lnzyquan 2005-09-02
  • 打赏
  • 举报
回复
流涕感谢中...
JasonHeung 2005-09-02
  • 打赏
  • 举报
回复
一个例子:
public class CheckBoxCondition : ConditionControlBase
{

#region 构造方法

public CheckBoxCondition()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();

// TODO: 在 InitializeComponent 调用后添加任何初始化

}


#endregion

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.cbxValue = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// cbOutRelation
//
this.cbOutRelation.Name = "cbOutRelation";
//
// cbxSelect
//
this.cbxSelect.Name = "cbxSelect";
//
// cbxValue
//
this.cbxValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cbxValue.Enabled = false;
this.cbxValue.Location = new System.Drawing.Point(133, 2);
this.cbxValue.Name = "cbxValue";
this.cbxValue.Size = new System.Drawing.Size(192, 20);
this.cbxValue.TabIndex = 84;
//
// CheckBoxCondition
//
this.Controls.Add(this.cbxValue);
this.Name = "CheckBoxCondition";
this.Size = new System.Drawing.Size(393, 23);
this.Controls.SetChildIndex(this.cbOutRelation, 0);
this.Controls.SetChildIndex(this.cbxValue, 0);
this.Controls.SetChildIndex(this.cbxSelect, 0);
this.ResumeLayout(false);

}


#endregion

#region 私有字段

private System.Windows.Forms.CheckBox cbxValue;

/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

#endregion

#region 特性

/// <summary>
/// 参数值
/// </summary>
public bool Value
{
get
{
return this.cbxValue.Checked;
}
set
{
this.cbxValue.Checked = value;
}
}


/// <summary>
/// 参数值说明文本
/// </summary>
public string ValueText
{
get
{
return this.cbxValue.Text;
}
set
{
this.cbxValue.Text = value;
}
}


/// <summary>
/// 提示标签的尺寸
/// </summary>
public Size CaptionWidth
{
get
{
return this.cbxSelect.Size;
}
set
{
this.cbxSelect.Size = value;
this.cbxValue.Location = new Point(CaptionWidth.Width + cbxSelect.Location.X,cbxValue.Location.Y);
}
}


/// <summary>
/// 条件集合
/// </summary>
public ConditionCollection Conditions
{
get
{
ConditionCollection cc = new ConditionCollection();
if (this.cbxSelect.Checked)
{
Condition c = new Condition(ColumnName,"=",this.cbxValue.Checked ? 1 : 0);
c.relation = this.cbOutRelation.Text == "" ? "AND" : relations[this.cbOutRelation.SelectedIndex];
cc.Add(c);
}
return cc;
}
}


#endregion

#region 私有方法

private void cbxInput_CheckedChanged(object sender, System.EventArgs e)
{
this.cbxValue.Enabled = this.cbOutRelation.Enabled = this.cbxSelect.Checked;
}


#endregion

#region 保护方法

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


#endregion

}
JasonHeung 2005-09-02
  • 打赏
  • 举报
回复
/// <summary>
/// 条件控件基类。
/// </summary>
public class ConditionControlBase :UserControl, IConditionControl
{

#region 构造方法

public ConditionControlBase()
{
InitializeComponent();
//
// TODO: 在此处添加构造函数逻辑
//
if (GlobalObject.GetInstance().CultureID == 2052)
{
this.cbOutRelation.Items.Add(relationsName[0]);
this.cbOutRelation.Items.Add(relationsName[1]);
}
else
{
this.cbOutRelation.Items.Add(relations[0]);
this.cbOutRelation.Items.Add(relations[1]);
}
}


#endregion

#region Windows 窗体设计器生成的代码

private void InitializeComponent()
{
this.cbOutRelation = new System.Windows.Forms.ComboBox();
this.cbxSelect = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// cbOutRelation
//
this.cbOutRelation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cbOutRelation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbOutRelation.Enabled = false;
this.cbOutRelation.Location = new System.Drawing.Point(332, 2);
this.cbOutRelation.Name = "cbOutRelation";
this.cbOutRelation.Size = new System.Drawing.Size(61, 20);
this.cbOutRelation.TabIndex = 99;
//
// cbxSelect
//
this.cbxSelect.Location = new System.Drawing.Point(2, 2);
this.cbxSelect.Name = "cbxSelect";
this.cbxSelect.Size = new System.Drawing.Size(129, 20);
this.cbxSelect.TabIndex = 85;
this.cbxSelect.CheckedChanged += new System.EventHandler(this.cbxSelect_CheckedChanged);
//
// ConditionControlBase
//
this.Controls.Add(this.cbOutRelation);
this.Controls.Add(this.cbxSelect);
this.Name = "ConditionControlBase";
this.Size = new System.Drawing.Size(396, 26);
this.Load += new System.EventHandler(this.ConditionControlBase_Load);
this.ResumeLayout(false);

}


#endregion

#region 私有字段

bool readOnly = false;

/// <summary>
/// 列名
/// </summary>
string columnName = "";

#endregion

#region 特性

public bool Selected
{
get
{
return this.cbxSelect.Checked;
}
set
{
this.cbxSelect.Checked = value;
}
}


public bool ReadOnly
{
get
{
return readOnly;
}
set
{
readOnly = value;
OnReadOnlyChanged();
}
}


/// <summary>
/// 标签提示
/// </summary>
public string Caption
{
get
{
return this.cbxSelect.Text;
}
set
{
this.cbxSelect.Text = value;
}
}


/// <summary>
/// 列名
/// </summary>
public string ColumnName
{
get
{
return columnName;
}
set
{
columnName = value;
}
}


/// <summary>
/// 关系操作符
/// </summary>
public string Relation
{
get
{
return this.cbOutRelation.Text;
}
set
{
string s = value;
s = " " + s.Trim().ToUpper() + " ";
this.cbOutRelation.Text = s;
}
}


#endregion

#region 保护字段

protected System.Windows.Forms.ComboBox cbOutRelation;

#endregion

#region 公共字段

public System.Windows.Forms.CheckBox cbxSelect;

public static readonly string[] relations = new string[]{" AND "," OR "};

public static readonly string[] relationsName = new string[]{"并且","或者"};

#endregion

#region 私有方法

private void cbxSelect_CheckedChanged(object sender, System.EventArgs e)
{
OnSeclectChanged();
}


void OnSeclectChanged()
{
int i;
for (i = 0 ; i < this.Controls.Count; ++i)
{
if (this.Controls[i] != this.cbxSelect)
{
EnableControl(this.Controls[i],this.cbxSelect.Checked);
}
}
}


void EnableControl(Control obj, bool enable)
{
obj.Enabled = enable;
int i;
for (i = 0 ; i < obj.Controls.Count; ++i)
{
EnableControl(obj.Controls[i],enable);
}
}


private void ConditionControlBase_Load(object sender, System.EventArgs e)
{
OnSeclectChanged();
}


#endregion

#region 保护方法

protected virtual void OnReadOnlyChanged()
{
int i;
for (i = 0 ; i < this.Controls.Count; ++i)
{
this.Controls[i].Enabled = this.ReadOnly == false;
}
}


#endregion

}
JasonHeung 2005-09-02
  • 打赏
  • 举报
回复
/// <summary>
/// 条件控件接口。
/// </summary>
public interface IConditionControl
{
/// <summary>
/// 选择标志
/// </summary>
bool Selected{get;set;}

/// <summary>
/// 只读标志
/// </summary>
bool ReadOnly{get;set;}

/// <summary>
/// 外接关系操作符
/// </summary>
string Relation{get;set;}

/// <summary>
/// 提示文字
/// </summary>
string Caption{get;set;}

}
sukey00 2005-09-02
  • 打赏
  • 举报
回复
可以设计一个数据字典,专门存储各个表的信息,至少要包括
字段至少包括以下:表明,中文字段名,EN字段名,字段大小,字段类型,(字段有的是编码的话,当然得根据需求增加对应表的字段)

这个只是思路,具体实现具体分析
JasonHeung 2005-09-02
  • 打赏
  • 举报
回复
你应该在使用它之前将硬盘用Ghost备份。用完再恢复。
JasonHeung 2005-09-02
  • 打赏
  • 举报
回复
数据当然用数据库存储。再给你一个查询窗口基类:
/// <summary>
/// 查询条件设置窗口基类
/// 作者:JasonHeung
/// 建立时间:2004-04-01
/// </summary>
public class InquireSetBase : Form
{

#region 构造方法

public InquireSetBase()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}


#endregion

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btnOK.BackColor = System.Drawing.Color.PeachPuff;
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(89, 331);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 30);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "Inquire";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btnCancel.BackColor = System.Drawing.Color.PeachPuff;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(301, 331);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 30);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
//
// InquireSetBase
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(7, 16);
this.BackColor = System.Drawing.Color.AntiqueWhite;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(462, 378);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InquireSetBase";
this.Text = "Inquire";
this.ResumeLayout(false);

}


#endregion

#region 私有字段

/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

#endregion

#region 保护字段

/// <summary>
/// 存放条件集合
/// </summary>
protected ConditionCollection cc = new ConditionCollection();

#endregion

#region 公共字段

public System.Windows.Forms.Button btnOK;

public System.Windows.Forms.Button btnCancel;

#endregion

#region 私有方法

private void btnOK_Click(object sender, System.EventArgs e)
{
if (true == BeforeInquir())
{
if (OnInquire != null)
{
OnInquire(this,e);
}
Close();
}
}


#endregion

#region 保护方法

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


#endregion

#region 公共方法

/// <summary>
/// 查询前处理方法,将所有条件加入到条件集合cc中
/// </summary>
/// <returns>返回false则不进行下一步操作,也不关闭窗口</returns>
public virtual bool BeforeInquir()
{
return true;
}


/// <summary>
/// 返回查询条件集合
/// </summary>
/// <returns></returns>
public ConditionCollection GetConditions()
{
if (cc.Count > 0)
{
cc[cc.Count-1].relation = "AND";
}

return cc;
}


/// <summary>
/// 返回条件集合的描述性文本
/// </summary>
/// <returns></returns>
public virtual string GetConditionDescription()
{
return "";
}


/// <summary>
/// 添加条件或者条件集合
/// </summary>
/// <param name="obj">条件或者条件集合</param>
public void AddCondition(object obj)
{
if (obj == null)
{
return;
}
if (obj is Condition)
{
cc.Add(obj);
}
else if (obj is ConditionCollection)
{
cc.AddCollection((ConditionCollection)obj);
}
}


#endregion

#region 其它

/// <summary>
/// 查询按钮按下事件
/// </summary>
public event EventHandler OnInquire;


#endregion

}

lnzyquan 2005-09-02
  • 打赏
  • 举报
回复
一个下载软件,试用次数到期乐,卸乐,删除注册表有关信息,在安装,还是告诉我试用次数已过,怎么办啊??


改系统时间也不成!

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧