Here are some save function for some situations:

Yes/No

/// <summary>
///保存数据到WCF
/// </summary>
/// <param name="ds"></param>
public void SaveDataSetSingleOrTwoTables(DataSet ds, string parent, string child)
{
string message = "您想保存数据吗?";
string caption = "保存数据"; if (ds.HasChanges())
{
DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
//DataSet dsChanged = ds.GetChanges();
DataTable tblParent = null;
DataTable tblChild = null; if (!string.IsNullOrEmpty(parent))
{
tblParent = ds.Tables[parent].GetChanges(); //error if table not existing
} if (!string.IsNullOrEmpty(child))
{
tblParent = ds.Tables[child].GetChanges(); //error if table not existing
} DataSet ds1 = new DataSet();
if (tblParent != null) ds1.Tables.Add(tblParent);
DataSet ds2 = new DataSet();
if (tblChild != null) ds2.Tables.Add(tblChild); //call save method(tblParent, tblChild, null);
TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient saveData = new TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient();
saveData.QualityCheckUpdate(ds1, ds2, null);
ds.AcceptChanges();
MessageBox.Show("数据已保存。");
}
catch (Exception ex)
{
Error.ErrProc(ex);
MessageBox.Show("由于某种原因,数据不能保存。数据丢失。");
ds.RejectChanges();
return;
} }
else
{
ds.RejectChanges();
MessageBox.Show("数据没有保存。已修改的已恢复。");
}
}
else
{
MessageBox.Show("没有数据要保存。");
ds.RejectChanges();
} }

Yes/No/Cancel

 /// <summary>
/// 保存数据到WCF
/// </summary>
/// <param name="ds"></param>
/// <param name="parent"></param>
/// <param name="child"></param>
public void SaveDataSetSingleOrTwoTablesWithCancel(DataSet ds, string parent, string child)
{
string message = "您想保存数据吗";
string caption = "保存数据"; if (ds.HasChanges())
{
DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
//DataSet dsChanged = ds.GetChanges();
DataTable tblParent = null;
DataTable tblChild = null; if (!string.IsNullOrEmpty(parent))
{
tblParent = ds.Tables[parent].GetChanges(); //error if table not existing
} if (!string.IsNullOrEmpty(child))
{
tblParent = ds.Tables[child].GetChanges(); //error if table not existing
} DataSet ds1 = new DataSet();
if (tblParent != null) ds1.Tables.Add(tblParent);
DataSet ds2 = new DataSet();
if (tblChild != null) ds2.Tables.Add(tblChild); //call save method(tblParent, tblChild, null);
TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient saveData = new TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient();
saveData.QualityCheckUpdate(ds1, ds2, null);
ds.AcceptChanges();
MessageBox.Show("数据已保存。");
}
catch (Exception ex)
{
Error.ErrProc(ex);
ds.RejectChanges();
MessageBox.Show("由于某种原因,数据不能保存。数据丢失。");
return;
} }
else if (result == DialogResult.No)
{
ds.RejectChanges();
MessageBox.Show("数据没有保存。已修改的已恢复。");
return;
}
else
{
MessageBox.Show("您修改的数据没有保存。但您可以保存。");
return;
}
}
else
{
MessageBox.Show("没有数据要保存。");
ds.RejectChanges();
} }

Yes/No => WCF

/// <summary>
///保存数据到WCF
/// </summary>
/// <param name="ds"></param>
public void SaveDataSetSingleOrTwoTables(DataSet ds, string parent, string child)
{
string message = "您想保存数据吗?";
string caption = "保存数据"; //index_item data changed?
UpdateCurrentDetail(); if (ds.HasChanges())
{
DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
//DataSet dsChanged = ds.GetChanges();
DataTable tblParent = null;
DataTable tblChild = null; if (!string.IsNullOrEmpty(parent))
{
tblParent = ds.Tables[parent].GetChanges(); //error if table not existing
} if (!string.IsNullOrEmpty(child))
{
tblChild = ds.Tables[child].GetChanges(); //error if table not existing
} DataSet ds1 = new DataSet();
if (tblParent != null) ds1.Tables.Add(tblParent);
DataSet ds2 = new DataSet();
if (tblChild != null) ds2.Tables.Add(tblChild); //call save method(tblParent, tblChild, null);
TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient saveData = new TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient();
saveData.QualityCheckUpdate(ds1, ds2, null);
ds.AcceptChanges();
MessageBox.Show("数据已保存。");
}
catch (Exception ex)
{
Error.ErrProc(ex);
MessageBox.Show("由于某种原因,数据不能保存。数据丢失。");
ds.RejectChanges();
return;
} }
else
{
ds.RejectChanges();
MessageBox.Show("数据没有保存。已修改的已恢复。");
}
}
else
{
MessageBox.Show("没有数据要保存。");
ds.RejectChanges();
} }

Yes/No/Cancel

/// <summary>
/// 保存数据到WCF
/// </summary>
/// <param name="ds"></param>
/// <param name="parent"></param>
/// <param name="child"></param>
public void SaveDataSetSingleOrTwoTablesWithCancel(DataSet ds, string parent, string child)
{
string message = "您想保存数据吗";
string caption = "保存数据"; //index_item data changed?
UpdateCurrentDetail(); if (ds.HasChanges())
{
DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
//DataSet dsChanged = ds.GetChanges();
DataTable tblParent = null;
DataTable tblChild = null; if (!string.IsNullOrEmpty(parent))
{
tblParent = ds.Tables[parent].GetChanges(); //error if table not existing
} if (!string.IsNullOrEmpty(child))
{
tblChild = ds.Tables[child].GetChanges(); //error if table not existing
} DataSet ds1 = new DataSet();
if (tblParent != null) ds1.Tables.Add(tblParent);
DataSet ds2 = new DataSet();
if (tblChild != null) ds2.Tables.Add(tblChild); //call save method(tblParent, tblChild, null);
TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient saveData = new TJ_Nurse_Service.NurseSvc.QualityCheckIBLLClient();
saveData.QualityCheckUpdate(ds1, ds2, null);
ds.AcceptChanges();
MessageBox.Show("数据已保存。");
}
catch (Exception ex)
{
Error.ErrProc(ex);
ds.RejectChanges();
MessageBox.Show("由于某种原因,数据不能保存。数据丢失。");
return;
} }
else if (result == DialogResult.No)
{
ds.RejectChanges();
MessageBox.Show("数据没有保存。已修改的已恢复。");
return;
}
else
{
MessageBox.Show("您修改的数据没有保存。但您可以保存。");
return;
}
}
else
{
MessageBox.Show("没有数据要保存。");
ds.RejectChanges();
} }

SaveData Functions的更多相关文章

  1. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  2. 【跟着子迟品 underscore】Array Functions 相关源码拾遗 & 小结

    Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...

  3. 【跟着子迟品 underscore】Object Functions 相关源码拾遗 & 小结

    Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...

  4. ajax的使用:(ajaxReturn[ajax的返回方法]),(eval返回字符串);分页;第三方类(page.class.php)如何载入;自动加载函数库(functions);session如何防止跳过登录访问(构造函数说明)

    一.ajax例子:ajaxReturn("ok","eval")->thinkphp中ajax的返回值的方法,返回参数为ok,返回类型为eval(字符串) ...

  5. QM模块包含主数据(Master data)和功能(functions)

    QM模块包含主数据(Master data)和功能(functions)   QM主数据   QM主数据 1 Material   Master MM01/MM02/MM50待测 物料主数据 2 Sa ...

  6. jQuery String Functions

    In today's post, I have put together all jQuery String Functions. Well, I should say that these are ...

  7. 2-4. Using auto with Functions

    在C++14中允许使用type deduction用于函数参数和函数返回值 Return Type Deduction in C++11 #include <iostream> using ...

  8. [Python] Pitfalls: About Default Parameter Values in Functions

    Today an interesting bug (pitfall) is found when I was trying debug someone's code. There is a funct ...

  9. Kernel Functions for Machine Learning Applications

    In recent years, Kernel methods have received major attention, particularly due to the increased pop ...

随机推荐

  1. Appium Java Windows环境搭建篇

    1. 安卓SDK及配置环境变量 1.1.先下载sdk安装包:installer_r24.4.1-windows.exe 下载地址:链接: http://pan.baidu.com/s/1dEyPSa9 ...

  2. 6754 Keyboard of a Mobile Telephone

    /*实践再次说明ch=getchar()的速度非常慢*/ /*大水题,不解释*/ #include<stdio.h> #include<string.h> int main() ...

  3. WPF XAML之bing使用StringFormat

    WPF XAML之bing使用StringFormat // 转化为百分比 Text="{Binding Progress, StringFormat=\{0:P\}}" < ...

  4. tomcat 部署spring工程乱码解决方案

    tomcat的server.xml文件,Connector标签增加useBodyEncodingForURI="true"属性 web.xml如下配置 <filter> ...

  5. Codeforces 696D Legen...(AC自动机 + 矩阵快速幂)

    题目大概说给几个字符串,每个字符串都有一个开心值,一个串如果包含一次这些字符串就加上对应的开心值,问长度n的串开心值最多可以是多少. POJ2778..复习下..太弱了都快不会做了.. 这个矩阵的乘法 ...

  6. BZOJ1701 : [Usaco2007 Jan]Cow School牛学校

    枚举剩下的分数个数$k$,设最高的$k$个分数和的分子分母分别为$U$和$D$. 那么在选了的里面找到$A=\min(Dt[x]-Up[x])$,没选的里面找到$B=\max(Dt[x]-Up[x]) ...

  7. 向 ViewPager 中添加 包含 ListView 的 Fragment

    对与fragment就不说什么了,直接看API手册吧,亲. 向 ViewPager 中添加 包含 ListView 的 Fragment 的过程比较麻烦.他所表现的效果就是新闻客户端的滑动翻页效果. ...

  8. BZOJ1798[Ahoi2009]Seq 维护序列seq 题解

    题目大意: 有长为N的数列,有如下三种操作形式: (1)把数列中的一段数全部乘一个值; (2)把数列中的一段数全部加一个值; (3)询问数列中的一段数的和,由于答案可能很大,你只需输出这个数模P的值. ...

  9. URAL 1057. Amount of Degrees(数位DP)

    题目链接 我看错题了...都是泪啊,不存在3*4^2这种情况...系数必须为1... #include <cstdio> #include <cstring> #include ...

  10. Android -- ListView(SimpleAdapter) 自定义适配器

    aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA ...