SaveData Functions
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的更多相关文章
- asp.net MVC helper 和自定义函数@functions小结
asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...
- 【跟着子迟品 underscore】Array Functions 相关源码拾遗 & 小结
Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...
- 【跟着子迟品 underscore】Object Functions 相关源码拾遗 & 小结
Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...
- ajax的使用:(ajaxReturn[ajax的返回方法]),(eval返回字符串);分页;第三方类(page.class.php)如何载入;自动加载函数库(functions);session如何防止跳过登录访问(构造函数说明)
一.ajax例子:ajaxReturn("ok","eval")->thinkphp中ajax的返回值的方法,返回参数为ok,返回类型为eval(字符串) ...
- QM模块包含主数据(Master data)和功能(functions)
QM模块包含主数据(Master data)和功能(functions) QM主数据 QM主数据 1 Material Master MM01/MM02/MM50待测 物料主数据 2 Sa ...
- jQuery String Functions
In today's post, I have put together all jQuery String Functions. Well, I should say that these are ...
- 2-4. Using auto with Functions
在C++14中允许使用type deduction用于函数参数和函数返回值 Return Type Deduction in C++11 #include <iostream> using ...
- [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 ...
- Kernel Functions for Machine Learning Applications
In recent years, Kernel methods have received major attention, particularly due to the increased pop ...
随机推荐
- ural 1251. Cemetery Manager
1251. Cemetery Manager Time limit: 1.0 secondMemory limit: 64 MB There is a tradition at the USU cha ...
- [转]maven安装以及eclipse配置maven
转自:http://jingyan.baidu.com/article/295430f136e8e00c7e0050b9.html 方法/步骤 下载maven的bin,在apache官方网站可以下载. ...
- 假装有题目 & Trie+贪心
题意: 从N个数中选出两个使其异或值最大. SOL: 建立一个01字典树,然后对每一个数在树上贪心即可...Trie一个挺好的运用,复杂度O(n*n的位数) CODE: #include <cs ...
- 关于jsp乱码问题的产生原因 及 解决方法。
http://blog.csdn.net/caoxiaohong/article/details/1781777 JSP/JDBC MySQL乱码问题JSP的request 默认为ISO8859_1, ...
- topcoder SRM 618 DIV2 LongWordsDiv2
此题给出的条件是: (1)word的每个字母都是大写字母(此条件可以忽略,题目给的输入都是大写字母) (2) 相等字符不能连续,即不能出现AABC的连续相同的情况 (3)word中不存在字母组成xyx ...
- jquery实现隐藏,简化和更多
HTML代码: <div class="box"> <div class="header"> <h3>图书分类</h3 ...
- [深入浅出WP8.1(Runtime)]Socket编程之UDP协议
13.3 Socket编程之UDP协议 UDP协议和TCP协议都是Socket编程的协议,但是与TCP协议不同,UDP协议并不提供超时重传,出错重传等功能,也就是说其是不可靠的协议.UDP适用于一次只 ...
- 20161007 NOIP 模拟赛 T1 解题报告
排序 3.1 题意描述 众所周知,熟练掌握至少一种排序算法是参加NOIP的必备技能.常见的排序算法有冒泡 排序.归并排序.快速排序.奇偶排序.猴子排序.梳排序.鸡尾酒排序.臭皮匠排序等. 在这里,介绍 ...
- 【SGU】495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...
- 使用C语言在windows下一口气打开一批网页
作者:郝峰波 mail : fengbohello@qq.com 本博客地址:http://www.cnblogs.com/fengbohello/p/4374450.html 1.核心函数说明 核心 ...