本文整理汇总了C#中EntitySet.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.SaveChanges方法的具体用法?C# EntitySet.SaveChanges怎么用?C# EntitySet.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySet
的用法示例。
在下文中一共展示了EntitySet.SaveChanges方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnAddMenuToFavorite
protected virtual void OnAddMenuToFavorite()
{
if (!AllowAddToFavorite) return;
var es = new EntitySet<sysMyFavoriteMenu>();
if (!es.TableIsExists()) return;
es.Query("SELECT TOP 1 * FROM dbo.sysMyFavoriteMenu WITH(NOLOCK) WHERE UserId=:UserId and MenuId=:MenuId", Session.UserInfo.UserId, this.UniqueId);
if (es.Count <= 0)
{
var obj = es.AddNew();
obj.Iden = IdenGenerator.NewIden(obj.TableName);
obj.MenuId = Convert.ToInt32(this.UniqueId);
obj.UserId = Session.UserInfo.UserId;
obj.RowNumber = 10000;
es.SaveChanges();
}
MessageService.ShowMessage("菜单已经收藏至我的工作台.");
var shell = ApplicationService.Current.MainForm as IShell;
if (shell != null)
shell.RefreshFavorite();
}
示例2: ChangePassword
/// <summary>
///
/// </summary>
/// <param name="username"></param>
/// <param name="oldPassword"></param>
/// <param name="newPassword"></param>
/// <returns></returns>
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
var users = new EntitySet<sysUser>();
users.Query("select Iden, Password from sysUser with(nolock) where UserName=:UserName", username);
if (users.Count <= 0 || !users.CurrentEntity.Password.Equals(oldPassword, StringComparison.InvariantCulture))
return false;
users.CurrentEntity.Password = newPassword;
users.SaveChanges();
return true;
}
示例3: Save
public void Save()
{
var es = new EntitySet<sysAppConfig>();
es.Query("select * from sysAppConfig with(nolock) where UserId=:UserId", Session.UserInfo.UserId);
sysAppConfig entity = null;
if (es.Count <= 0)
{
entity = es.AddNew();
entity.Iden = IdenGenerator.NewIden(entity.TableName);
}
else
entity = es.First();
entity.UserId = Session.UserInfo.UserId;
entity.AppConfig = XmlSerializerHelper.Serialize<AppConfig>(this);
es.SaveChanges();
}
示例4: btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
var es = new EntitySet<sysUser>();
es.Query("SELECT Iden,UserName,Password,IsActive,IsDeleted FROM dbo.sysUser where Iden=:UserId", Session.UserInfo.UserId);
if (es.Count <= 0)
{
MessageService.ShowError("在系统中未找到用户,无法修改密码.");
return;
}
var user = es.CurrentEntity;
if (user.IsDeleted)
{
MessageService.ShowError("用户在系统中已被删除,无法修改密码.");
return;
}
if (!user.IsActive)
{
MessageService.ShowError("用户在系统中已被禁用,无法修改密码.");
return;
}
var oldPassword = SHA1Helper.Hash(this.txtOldPassword.Text);
if (!user.Password.Equals(oldPassword, StringComparison.InvariantCulture))
{
MessageService.ShowError("原密码错误,无法修改密码.");
this.txtOldPassword.Focus();
return;
}
if (!this.txtNewPassword.Text.Equals(this.txtNewPassword2.Text, StringComparison.InvariantCulture))
{
MessageService.ShowError("新密码与确认新密码不一致,无法修改密码.");
this.txtNewPassword.Focus();
return;
}
user.Password = SHA1Helper.Hash(this.txtNewPassword.Text);
es.SaveChanges();
MessageService.ShowMessageFormatted("密码修改成功,请使用新密码登录系统.");
this.Close();
}
示例5: UnlockUser
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public override bool UnlockUser(string userName)
{
var users = new EntitySet<sysUser>();
users.Query("select Iden,IsActive from sysUser with(nolock) where UserName=:UserName", userName);
if (users.Count <= 0)
return false;
users.CurrentEntity.IsActive = true;
users.SaveChanges();
return true;
}
示例6: readXmljp
private void readXmljp(string filename)
{
XmlSerializer xml = new XmlSerializer(typeof(开目信息文件));
using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
开目信息文件 obj = (开目信息文件)xml.Deserialize(file);
//MessageBox.Show(obj.数据.元素["产品代号"].Value);//.下级信息[0].数据[0].元素[0].标识
// MessageBox.Show(obj.数据.元素.FirstOrDefault(p => p.标识 == "产品代号").标识);
for (int i = 0; i < obj.数据.下级信息[0].数据.Count(); i++)
{
EntitySet<bomRoting> entity = new EntitySet<bomRoting>();
entity.Query("select * from bomRoting with(nolock) where 1=0");
bomRoting bm = entity.AddNew();
bm.Iden = IdenGenerator.NewIden("bomRoting");
bm.BomId = obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value.Substring(0, obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value.IndexOf("-"));
bm.BomChildId = string.IsNullOrEmpty(obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value) ? string.Empty : obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value;
bm.OpDep = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "生产部门").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "生产部门").Value;
bm.RotingId = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序号").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序号").Value;
bm.RotingName = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序名称").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序名称").Value;
bm.RotingDesc = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序内容").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序内容").Value;
var Production = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "设备");
if (Production == null)
{
bm.Production = string.Empty;
}
else
{
bm.Production = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "设备").Value;
}
var RotingProduction=obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工艺装备");
if(RotingProduction==null)
{
bm.RotingProduction=string.Empty;
}
else
{
bm.RotingProduction = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工艺装备").Value;
}
var FZMeterial = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "辅助材料");
if (FZMeterial == null)
{
bm.FZMeterial = string.Empty;
}
else
{
bm.FZMeterial = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "辅助材料").Value;
}
var ZhunJie = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "准结");
if (ZhunJie == null)
{
bm.ZhunJie =0;
}
else
{
bm.ZhunJie =Convert.ToDecimal(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "准结").Value);
}
var DanJian = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "单件");
if (DanJian == null)
{
bm.DanJian = 0;
}
else
{
bm.DanJian = Convert.ToDecimal(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "单件").Value);
}
if (isExportBomRoting(bm.BomId, bm.BomChildId, bm.RotingId))
continue;
entity.SaveChanges();
}
}
}