编写数据库存储新增过程信息代码如下:
编写服务端后台代码如下:
[OperationContract] //(操作契约)定义服务协议
public int InsertPrize(string strPrize_number, string strPrize_name,
string strIntegral,bool bolWhether_activity,string strRemarks)
{
SqlParameter[] mysqlparameter = {
new SqlParameter("@type",SqlDbType.NChar),
new SqlParameter("@Prize_number",SqlDbType.NChar),
new SqlParameter("@Prize_name",SqlDbType.NChar),
new SqlParameter("@Integral",SqlDbType.NChar),
new SqlParameter("@Whether_activity",SqlDbType.Bit),
new SqlParameter("@Remarks",SqlDbType.NChar)
};
mysqlparameter[0].Value = "InsertPrize";
mysqlparameter[1].Value = strPrize_number;
mysqlparameter[2].Value = strPrize_name;
mysqlparameter[3].Value = strIntegral;
mysqlparameter[4].Value = bolWhether_activity;
mysqlparameter[5].Value = strRemarks;
int count = myDALMethod.UpdateData("Frm_Login", mysqlparameter);
return count;
}
编写客户端后台代码如下:
//确定新增按钮
private void btn_Affirm_Click(object sender, RoutedEventArgs e)
{
try
{
//判断数据不能为空
if (txt_number.Text.ToString()!=string.Empty && txt_name.Text.ToString() !=string.Empty)
{
//获取页面输入的数据
string strPrize_number = txt_number.Text.ToString();
string strPrize_name = txt_name.Text.ToString();
string strIntegral = txt_Integral.Text.ToString();
bool bolWhether_activity =(bool)chk_activity.IsChecked;
string strRemarks = txt_remarks.Text.ToString();
int count = myClient.InsertPrize(strPrize_number, strPrize_name, strIntegral, bolWhether_activity, strRemarks);
if (count > 0)
{
MessageBoxResult dt = MessageBox.Show("新增员工资料成功!", "系统提示", MessageBoxButton.OKCancel,
MessageBoxImage.Information); //弹出确定对话框
if (dt == MessageBoxResult.OK) //如果点了确定按钮
{
//关闭当前窗口
this.Close();
}
}
else if (count == -1)
{
MessageBox.Show("账号重复!,请继续");
}
}
else
{
MessageBox.Show("员工资料还没完整填完,请继续");
}
}
catch (Exception)
{
throw;
}
}
通过点击确定按钮,确定新增。
结果如图所示: