public TblClient InsertOrUpdate(TblClient data) { Exception cex = null; TblClient res = null; var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString); using (Sonartez_server db = new Sonartez_server(conn)) { var matchedObj = (from c in db.TblClient where c.ClientID == data.ClientID select c).SingleOrDefault(); if (matchedObj == null) { try { // does not exist Table<TblClient> TblObj = db.TblClient; data.UpdateDate = DateTime.Now; data.IsDeleted = 0; TblObj.InsertOnSubmit(data); TblObj.Context.SubmitChanges(); res = data; } catch (Exception ex) { cex = ex; } } else { try { matchedObj.ClientCode = data.ClientCode; matchedObj.ClientName = data.ClientName; matchedObj.Descriptions = data.Descriptions; matchedObj.LocationCode = data.LocationCode; matchedObj.LocationName = data.LocationName; matchedObj.UpdateDate = DateTime.Now; matchedObj.IsDeleted = data.IsDeleted; db.SubmitChanges(); res = matchedObj; } catch (Exception ex) { cex = ex; } } } if (cex != null) throw cex; else return res; }
public void LoadData(BBLConsultant cons) { //currentUser = new BBLUser().GetUser().FirstOrDefault(); currentClient = new BBLClient().GetAll().FirstOrDefault(); this.cons = cons; lstInfo = cons.GetAll(); List<TblConsultantLog> lst = new List<TblConsultantLog>(); lst.AddRange(lstInfo); lstInfo = lst; RunFilter(); }
public void LoadData(BBLInfo _info) { string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"]; currentClient = new BBLClient().GetAll().FirstOrDefault(x=>x.ClientCode==clientCode); if (currentClient == null) { MessageBox.Show("Xác minh lại thiết lập Máy Trạm"); new FrmConfig().ShowDialog(); } this.info = _info; lstInfo = info.GetAll().Where(x=>x.IsDeleted==0); List<TblInfor> lst = new List<TblInfor>(); lst.AddRange(lstInfo); lstInfo = lst; RunFilter(); }
public void LoadData(BBLInfo _info) { if (currentUser.Permission == Permission.Normal) chkStatus.Enabled = false; string clientCode = ConfigurationManager.AppSettings["CLIENTCODE"]; currentClient = new BBLClient().GetAll().FirstOrDefault(x => x.ClientCode == clientCode); if (currentClient == null) { MessageBox.Show("Xác minh lại thiết lập Máy Trạm"); new FrmConfig().ShowDialog(); } this.info = _info; lstInfo = info.GetAll().Where(x => x.IsDeleted == 0).ToList(); //List<TblInfor> lst = new List<TblInfor>(); //lst.AddRange(lstInfo); //lstInfo = lst; SettingAutoSuggest(); RunFilter(); }
public APIResult UpdateClient(TblClient data) { APIResult res = new APIResult(); using (Sonartez_server db = new Sonartez_server(connectionString)) { var matchedObj = (from c in db.TblClient where c.ClientID == data.ClientID select c).SingleOrDefault(); if (matchedObj == null) { try { // does not exist Table<TblClient> TblObj = db.TblClient; data.ServerUpdate = DateTime.Now; TblObj.InsertOnSubmit(data); TblObj.Context.SubmitChanges(); res.UpdateDate = data.UpdateDate.Value; res.Success = true; } catch (Exception ex) { res.Message = ex.Message; res.Success = false; } } else { try { matchedObj.ClientCode = data.ClientCode; matchedObj.ClientName = data.ClientName; matchedObj.Descriptions = data.Descriptions; matchedObj.LocationCode = data.LocationCode; matchedObj.LocationName = data.LocationName; matchedObj.ServerUpdate = DateTime.Now; matchedObj.UpdateDate = data.UpdateDate; db.SubmitChanges(); res.UpdateDate = data.ServerUpdate.Value; res.Success = true; } catch (Exception ex) { res.Message = ex.Message; res.Success = false; } } } return res; }
partial void DeleteTblClient(TblClient instance);
partial void UpdateTblClient(TblClient instance);
partial void InsertTblClient(TblClient instance);
private bool Delete(TblClient data) { Exception cex = null; bool res = false; var conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString); using (Sonartez_server db = new Sonartez_server(conn)) { var matchedObj = (from c in db.TblClient where c.ClientID == data.ClientID select c).SingleOrDefault(); if (matchedObj != null) { try { // does not exist db.TblClient.DeleteOnSubmit(matchedObj); db.SubmitChanges(); res = true; } catch (Exception ex) { cex = ex; res = false; } } else { res = true; } } if (cex != null) throw cex; else return res; }