void SaveModel() { MainBar.Focus(); if (string.IsNullOrEmpty(txtFullName.Text)) { MessageBox.Show("请填写姓名"); return; } model.FModifyDate = DateTime.Now; model.FModifyUser = MainContext.UserID; if (model.FID == 0 || model.FID.ToString() == "") { visaORM.TB_AuditPosition.AddObject(model); model.FCreateDate = DateTime.Now; model.FCreateUser = MainContext.UserID; model.FStatus = true; visaORM.SaveChanges(); vietnamCollection.Add(model); } else { visaORM.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); visaORM.SaveChanges(); } MessageBox.Show("保存成功"); }
void SaveModel() { MainBar.Focus(); if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("请填写国家英文名"); return; } if (string.IsNullOrEmpty(txtEnName.Text)) { MessageBox.Show("请填写国家英文名"); return; } if (model.FID == 0 || model.FID.ToString() == "") { visaORM.TCountry.AddObject(model); visaORM.SaveChanges(); countryCollection.Add(model); } else { visaORM.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); visaORM.SaveChanges(); } MessageBox.Show("保存成功"); }
private void UserSave() { MainBar.Focus(); if (txtPassConfirm.Text != txtPassword.Text) { MessageBox.Show("两次输入的密码不一致,保存失败。"); return; } if (model.FUserName == null || model.FCompanyName == null) { MessageBox.Show("必须录入用户名和公司。"); return; } if (model.FID == 0 || model.FID.ToString() == "") { var tempObj = visaORM.User.FirstOrDefault(u => u.FUserName == model.FUserName); { if (tempObj != null) { MessageBox.Show("该用户名已经存在,请使用其他用户名"); return; } } visaORM.User.AddObject(model); model.FIsDelete = false; visaORM.SaveChanges(); NowUserId = model.FID; userList.Add(model); //getDefaultModel = 0; InitData(); } else { if (visaORM.ObjectStateManager.GetObjectStateEntries(EntityState.Modified).Count() == 0) { visaORM.User.Attach(model); } visaORM.ObjectStateManager.ChangeObjectState(model, EntityState.Modified); visaORM.SaveChanges(); NowUserId = model.FID; } var list = from m in visaORM.TB_Menu join ur in visaORM.TB_UserRights on m.FID equals ur.FMenuID where m.FType == 1 && ur.FUserID == model.FID select ur; foreach (TB_UserRights urObj in list) { visaORM.DeleteObject(urObj); } selectedMenu.Clear(); foreach (var nodeObjLevel1 in MenuTree.View.Nodes) { foreach (var nodeObjLevel2 in nodeObjLevel1.Nodes) { foreach (var nodeObjLevel3 in nodeObjLevel2.Nodes) { if (nodeObjLevel3.IsChecked == true) { selectedMenu.Add(nodeObjLevel3.Content as TB_Menu); } } if (nodeObjLevel2.IsChecked == true) { selectedMenu.Add(nodeObjLevel2.Content as TB_Menu); } } if (nodeObjLevel1.IsChecked == true) { selectedMenu.Add(nodeObjLevel1.Content as TB_Menu); } } TB_UserRights urModel; foreach (var menuObj in selectedMenu) { urModel = new TB_UserRights(); urModel.FUserID = model.FID; urModel.FMenuID = menuObj.FID; urModel.FCreateDate = DateTime.Now; urModel.FCreateUser = MainContext.UserID; urModel.FModifyDate = DateTime.Now; urModel.FModifyUser = MainContext.UserID; urModel.FStatus = true; visaORM.TB_UserRights.AddObject(urModel); } TB_UserRights outMenuObj; if (CreateURModel(cbTable2Admin, out outMenuObj) == true) { if (outMenuObj != null) { visaORM.TB_UserRights.AddObject(outMenuObj); } } else { if (outMenuObj != null) { visaORM.DeleteObject(outMenuObj); } } visaORM.SaveChanges(); InitData(); MessageBox.Show("保存成功"); }
void auditList() { MainBar.Focus(); if (cbSentVisa.SelectedIndex == -1) { MessageBox.Show("请选择需要审核的名单"); return; } //string SentNo = cbSentVisa.SelectedItem.ToString(); //var modelCollection = from c in visaORM.Customer // join s in visaORM.SendInfo // on c.FID equals s.FCustomerID // where s.FSendNo == SentNo // select c; string todayStringShort = DateTime.Now.ToString("yyMMdd"); string todayStringAll = DateTime.Now.ToShortDateString(); int i = 0; foreach (var model in sendCollection) { sp_SelectTable3ForExcel_Result rowObj = gridMain.GetRow(i) as sp_SelectTable3ForExcel_Result; i++; if (rowObj.SelectChk == false) { continue; } Customer cModel = visaORM.Customer.FirstOrDefault(c => c.FID == model.QID); if (cModel != null) { visaORM.Customer.Attach(cModel); cModel.FSysChk = true; cModel.FSysChkDate = DateTime.Now; cModel.FSysChkUser = MainContext.UserID; visaORM.ObjectStateManager.ChangeObjectState(cModel, System.Data.EntityState.Modified); var modelSend = visaORM.SendInfo.FirstOrDefault(s => s.FCustomerID == cModel.FID); if (modelSend != null) { modelSend.FModifyDate = DateTime.Now; modelSend.FModifyUser = MainContext.UserID; modelSend.FSysChk = true; modelSend.FSysChkDate = cModel.FSysChkDate; modelSend.FSysChkUser = MainContext.UserID; visaORM.ObjectStateManager.ChangeObjectState(modelSend, System.Data.EntityState.Modified); } } } visaORM.SaveChanges(); MessageBox.Show("审核成功"); InitData(); }