【黑马程序员】(续)SqlHelper+三层架构 +例子1)复习创建客户和三层的知识+、(例子2)项目初始框架(HRMSys)

------- WindowsPhone 7手机开发.Net培训、期待与您交流! -------

五、(例子2续)管理员管理的知识:
数据的软删除
bool:IsDeleted
一个表引用另一张表的时候最好引用主键

DeleteById(Guid  id)
Insert(Operator op)
public Operator[] ListAll()
ToOperator()

(add,edit,delete)
Commhelper.cs
{
   public static string GetPwdSale()
 {
  ConfigurationManager.AppSettings["pwdSalt"];
 }
}
SqlHelper.cs
OperatorDAL.cs
{
public Operator GetById(Guid id)
Upublic void pdate(Guid id,string userName,string realName)//不更新密码泛型的方法
Upublic void Update(Guid id,string userName,string realName,string pwd)//重载更新密码
}

 


Operator.cs


HRMSys.UI:
LoginWindow.xaml
MainWindow.xaml.cs
{

miOperatorMgr_Click()
{}

 

}
app.config
{
 <connectionString></connectionString>
 <appSettings><add key="pwdSalt" value="love@baijnig"/></appSettings>
}
OperatorEditUI.xaml.cs
{
public bool IsInsert;
public int EditingId;
btnOK_Click()
{
新增:
略(密码加盐GetMD5值处理)
编辑:
密码为空则保留现有密码,反之则把密码重置为用户密码
}
Window_Load//
{

}
}

OperatorListUI.xaml.cs:
btnAdd_Click()
{}
btnDelete_Click()
{
获取删除行,软删除,重新加载数据
}
btnEdit_Click()
{}
private void LoadData()
{
//加载数据
}
Window_Load
{加载数据}

六、复合搜索
<GropBox Header="搜索条件" DockPanel.Dock="Top" Height="100">
   <Grid>
     <CheckBox Content="姓名"/><TextBox>
     <CheckBox Content="入职时间"/>一个时间段
     <CheckBox Content="部门"/><ComboBox>
   </Grid>
</GropBox>
DateTime.Today.AddMonths(-1);一个月之前
btnSearch_Click()
{
  //动态拼SQL
 List<string> whereList=new List<string>();
 List<SqlParameter> parametersList=new  List<SqlParameter>();
 if(cbSearchByName.IsChecked==true)
 {
  whereList.Add("Name=@Name");
  parametersList.Add(new SqlParameter("@Name",txtName.Text))
 }
 if(cbSearchByInDate.IsChecked==true)
 {
   whereList.Add("InDate between @InDateStart and @InDateEnd");
   parametersList.Add(new SqlParamete("@nDateStart",txtnDateStart.Text));
   parametersList.Add(new SqlParamete("@nDateEnd",txtnDateEnd.Text));
 }
 if(cbSearchByDept.IsChecked==true)
 {
  whereList.Add("DeptId=@Dept");
  parametersList.Add(new SqlParameter("@Dept",cmbDept.SelectedValue));
 }
 string whereSql=string.Join("  and  ", whereList);
 string sql="select * from T_Employee";
 if(whereSql>0)//勾选有查询条件
  {
    sql=sql+"  where  "+whereSql;
  }
}

 未完待续。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值