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 ...
随机推荐
- http://blog.csdn.net/chenleixing/article/details/43740759
http://blog.csdn.net/chenleixing/article/details/43740759
- iris数据集
iris以鸢尾花的特征作为数据来源,数据集包含150个数据集,分为3类,每类50个数据,每个数据包含4个属性,是在数据挖掘.数据分类中非常常用的测试集.训练集. 链接地址
- Android MuPDF 阅读PDF文件
MuPDF是一款轻量级的开源软件,可以用来阅读PDF文件.下载完源代码以后,想要运行成功,除了Android SDK之外,还需要Android NDK环境,因此有点麻烦. 但是一旦安装完必须的环境以后 ...
- APP测试流程
1 APP测试基本流程 1.1流程图 1.2测试周期 测试周期可按项目的开发周期来确定测试时间,一般测试时间为两三周(即15个工作日),根据项目情况以及版本质量可适当缩短或延长测试时间.正式测试前先向 ...
- 给@dudu 一个idea
好长时间没写文章了,因为我最近一直在琢磨博客园如何才能成为一家上市公司,上市前我在博客园买点原始股,说不定就发了. 现在遇到错误总是先谷歌,谷歌背墙,在百度,百度不到在到博客园找 找看看 因为找找 ...
- 10秒钟sublime text 3安装SVN插件
注意:此处我提前已经安装了towerSVN,你可能需要提前安装好 towerSVN,之前安装redis之后我才明白,安装插件时安装软件好像 是一个必要的步骤,也就是说安装插件只是让你能在这里使用你已 ...
- MySQL数据库迁移(转)
MySQL数据库迁移(数据文件直接迁移) 在今年10月下旬的时候,公司的服务器需要迁移,其中涉及到了MySQL数据库迁移.查看了一下MySQL数据文件的大小,接近60G的大小(实际数据并没用那么多). ...
- nginx“虚拟目录”不支持php的解决办法
这几天在配置Nginx,PHP用FastCGI,想装一个phpMyAdmin管理数据库,phpMyAdmin不想放在网站根目录 下,这样不容易和网站应用混在一起,这样phpMyAdmin的目录就放在别 ...
- 粉笔网iPhone端使用的第三方开源库
粉笔网iPhone端使用的第三方开源库 前言 最近有朋友问我粉笔网 iPhone 端使用了哪些第三方的开源库.我在这儿整理了一下,分享给大家. ASIHttpRequest ASIHttpReques ...
- android中的Dialog
一.Dialog概述 二.使用系统自带的Dialog 1.新建Builder AlertDialog.Builder builder = new AlertDialog.Builder(StoryAc ...