public OperatorManagerVm(Dal.SoheilEdmContext uow) { _uow = uow; //OperatorsList.Add(OperatorEditorVm.CreateAnonymous()); #region get all operators and convert them to VM OperatorDataService = new DataServices.OperatorDataService(_uow); var allOperators = OperatorDataService.GetActives(); foreach (var oper in allOperators) { var operVm = new OperatorEditorVm(oper); //Notify // Add|Remove selected|deselected operator in vm operVm.SelectedOperatorChanged += Operator_SelectedOperatorChanged; //Updates role in uow operVm.OperatorRoleChanged += Operator_RoleChanged; OperatorsList.Add(operVm); } #endregion #region init commands ClearSearchCommand = new Commands.Command(textBox => { if (textBox is System.Windows.Controls.TextBox) (textBox as System.Windows.Controls.TextBox).Clear(); }); RefreshCommand = new Commands.Command(o => refresh()); #endregion }
public IList<UserBookRequest> SearchUser(String searchString) { try { String searchPattern = "%" + searchString + "%"; IDal<UserBookRequest> dal = new Dal<UserBookRequest>(); NHibernate.ISession session = dal.GetSession(); var criteriaQuery = session.CreateCriteria<UserBookRequest>("ubr") .CreateAlias("ubr.User","u") .CreateAlias("ubr.BookRequest","br") .CreateAlias("br.Book","b") .Add(Restrictions.Disjunction() .Add(Restrictions.Like("u.Name", searchPattern)) .Add(Restrictions.Like("u.Username", searchPattern)) .Add(Restrictions.Like("b.Name", searchPattern))); IList<UserBookRequest> returnedList = dal.Search(criteriaQuery); return returnedList; } catch (Exception e) { Console.WriteLine("Some problem with UserDal SearchUser()"); Console.Write(e.ToString()); return null; } }
public User FindById(int id) { String query = "from User u where u.id=" + id; try { IDal<User> dal = new Dal<User>(); IList<User> objectList = dal.Read(query); if (objectList.Count != 0) { User returnedUser = (User) objectList.FirstOrDefault(); return returnedUser; } return null; } catch (Exception e) { Console.Write("Error at UserDal, FindById"); Console.Write(e.ToString()); return null; } }
// [TestMethod] public void TestDal() { Dal<User> dal = new Dal<User>(); String query="SELECT * FROM lib_user " + "WHERE username='******' AND password='******'"; dal.Read(query); }
public Book GetById(int id) { String query = "from Book b where b.id="+id; try { IDal<Book> dal = new Dal<Book>(); IList<Book> objectList = dal.Read(query); if (objectList.Count != 0) { Book returnedBook = objectList.FirstOrDefault(); return returnedBook; } return null; } catch (Exception e) { Console.WriteLine("Some problem with BookDal getAllBooks()"); Console.Write(e.ToString()); return null; } }
/// <summary> /// Creates an instance of FilterBoxVmCollection to be used as a collection of guilty operators /// </summary> /// <param name="models">collection of ODR or OSR models which represent guilty operators</param> /// <returns></returns> public static FilterBoxVmCollection CreateForGuiltyOperators(dynamic models, Dal.SoheilEdmContext uow) { //find all active operators var operatorDs = new DataServices.OperatorDataService(uow); var operatorModels = operatorDs.GetActives(); //create vm for all active operators var operatorVms = new FilterableItemVm[operatorModels.Count]; for (int i = 0; i < operatorVms.Length; i++) { operatorVms[i] = FilterableItemVm.CreateForGuiltyOperator(operatorModels[i]); } //initiate this vm to auto-add operatorVms when a new FilterBoxVm is added to it var vm = new FilterBoxVmCollection(); vm.AddCommand = new Commands.Command(o => vm.AddOperator(operatorVms)); //add new FilterBoxVm for each of guilty operators and select the guilty operator in it if (models != null) { foreach (var model in models) { vm.AddOperator(operatorVms, model); } } return vm; }
public IList<Book> GetAllBooks() { String query = "from Book"; try { IDal<Book> dal = new Dal<Book>(); IList<Book> objectList = dal.Read(query); if (objectList.Count!= 0) { IList<Book> returnedBooks = (IList<Book>) objectList; return returnedBooks; } else { return null; } } catch (Exception e) { Console.WriteLine("Some problem with BookDal getAllBooks()"); Console.Write(e.ToString()); return null; } }
// // GET: /Univers/ public ActionResult Index() { using (IDal dal = new Dal()) { IEnumerable<Univers> univers = dal.ObtientTousLesUnivers(); return View(univers); } }
public ActionResult Edit(int id) { using (IDal dal = new Dal()) { Univers univers = dal.ObtientUnUnivers(id); return View("Edit", univers); } }
public ActionResult Index() { using (IDal dal = new Dal()) { IEnumerable<Pouvoir> pouvoirs = dal.ObtientTousLesPouvoirs(); return View(pouvoirs); } }
public ActionResult Edit(int id) { using (IDal dal = new Dal()) { Pouvoir pouvoir = dal.ObtientUnPouvoir(id); return View("Edit", pouvoir); } }
public ActionResult Delete(int id) { using (IDal dal = new Dal()) { dal.SupprimerUnPouvoir(id); List<Pouvoir> pouvoirs = dal.ObtientTousLesPouvoirs(); return View("Index", pouvoirs); } }
public ActionResult Delete(int id) { using (IDal dal = new Dal()) { dal.SupprimerUnAccessoire(id); List<Accessoire> accessoires = dal.ObtientTousLesAccessoires(); return View("Index", accessoires); } }
public ActionResult Delete(int id) { using (IDal dal = new Dal()) { dal.SupprimerUnUnivers(id); List<Univers> univers = dal.ObtientTousLesUnivers(); return View("Index", univers); } }
public ActionResult Delete(int id) { using (IDal dal = new Dal()) { dal.SupprimerUnPersonnage(id); List<Personnage> personnages = dal.ObtientTousLesPersonnages(); return View("Index", personnages); } }
public ActionResult Create(Univers univers) { using (IDal dal = new Dal()) { dal.CreerUnivers(univers.Nom); IEnumerable<Univers> lstUnivers = dal.ObtientTousLesUnivers(); return View("Index", lstUnivers); } }
public ActionResult Edit(Univers pUnivers) { using (IDal dal = new Dal()) { dal.ModifierUnivers(pUnivers.UniversId, pUnivers.Nom); IEnumerable<Univers> lstUnivers = dal.ObtientTousLesUnivers(); return View("Index", lstUnivers); } }
/// <summary> /// Creates an instance of <see cref="ProcessVm"/> for the given model /// </summary> public ProcessVm(Model.Process model, Dal.SoheilEdmContext uow) { Model = model; UOW = uow; StartDateTime = model.StartDateTime; DurationSeconds = model.DurationSeconds; TargetPoint = model.TargetCount; initializeCommands(); }
public ActionResult Edit(int id) { using (IDal dal = new Dal()) { Personnage personnage = dal.ObtientUnPersonnage(id); personnage.PouvoirsId = new List<int>(); foreach (Pouvoir pouvoir in personnage.Pouvoirs) personnage.PouvoirsId.Add(pouvoir.PouvoirId); return View("Edit", personnage); } }
public ActionResult Edit(int id) { using (IDal dal = new Dal()) { Accessoire accessoire = dal.ObtientUnAccessoire(id); accessoire.PouvoirsId = new List<int>(); foreach (Pouvoir pouvoir in accessoire.Pouvoirs) accessoire.PouvoirsId.Add(pouvoir.PouvoirId); return View("Edit", accessoire); } }
public bool SaveBooks(IList<Book> books) { try { IDal<Book> dal = new Dal<Book>(); bool status = dal.Save(books); return status; } catch (Exception e) { Console.WriteLine("Save bookdal has crashed"); return false; } }
public bool DeleteBookRequestForUser(IList<UserBookRequest> userBookRequestList) { try { IDal<UserBookRequest> dal = new Dal<UserBookRequest>(); Boolean status = dal.Save(userBookRequestList); return status; } catch (Exception e) { Console.WriteLine("Error at UserbookRequestDal , DeleteBookRequestForUser()"); Console.Write(e.ToString()); return false; } }
public ActionResult Edit(Pouvoir pouvoir) { using (IDal dal = new Dal()) { if (ModelState.IsValid) { dal.ModifierPouvoir(pouvoir.PouvoirId, pouvoir.Nom); List<Pouvoir> pouvoirs = dal.ObtientTousLesPouvoirs(); return View("Index", pouvoirs); } else { return View(pouvoir); } } }
public Boolean CreateNewUser(IList<User> userList) { try { IDal<User> user = new Dal<User>(); Boolean status = user.Save(userList); return status; } catch (Exception e) { Console.Write("Error at UserDal, CreateNewUser()"); Console.Write(e.ToString()); return false; } }
public Boolean Add(IList<BookRequest> bookRequestList) { try { IDal<BookRequest> dal = new Dal<BookRequest>(); Boolean status = dal.Save(bookRequestList); return status; } catch (Exception e) { Console.WriteLine("Error in BookRequest Dal , Add()"); Console.Write(e.ToString()); return false; } }
/// <summary> /// Creates a ViewModel for the given ProcessReport with given row and column /// </summary> /// <param name="model">if null, it automatically assign unreported process space</param> public ProcessReportVm(Model.ProcessReport model, Dal.SoheilEdmContext uow) { Model = model; Message = new EmbeddedException(); try { ActivityName = model.Process.StateStationActivity.Activity.Name; ProductName = model.Process.StateStationActivity.StateStation.State.FPC.Product.Name; ProductColor = model.Process.StateStationActivity.StateStation.State.FPC.Product.Color; } catch { } //uow UOW = uow; _processReportDataService = new DataServices.ProcessReportDataService(UOW); _taskReportDataService = new DataServices.TaskReportDataService(UOW); //properties //Model.ProducedG1 = Model.OperatorProcessReports.Sum(x => x.OperatorProducedG1);//??? can be different than sum ProducedG1 = Model.ProducedG1; Timing = new TimingSet(this); Timing.Saved += () => Save(); Timing.DurationChanged += v => Model.DurationSeconds = v; Timing.StartChanged += v => Model.StartDateTime = v; Timing.EndChanged += v => Model.EndDateTime = v; Timing.TargetPointChanged += tp => { TargetPointForOperator = Model.OperatorProcessReports.Any() ? string.Format("{0:F2}", (float)tp / Model.OperatorProcessReports.Count) : "---"; Model.ProcessReportTargetPoint = tp; updateEmptyCount(tp: tp); }; TargetPointForOperator = Model.OperatorProcessReports.Any() ? string.Format("{0:F2}", (float)Model.ProcessReportTargetPoint / Model.OperatorProcessReports.Count) : "---"; //reports OperatorReports = new OperatorReportCollection(this); DefectionReports = new DefectionReportCollection(this); DefectionCount = (int)Model.DefectionReports.Sum(x => x.CountEquivalence); StoppageReports = new StoppageReportCollection(this); StoppageCount = (int)Model.StoppageReports.Sum(x => x.CountEquivalence); IsUserDrag = false; _isInInitializingPhase = false; initializeCommands(); }
public void TestSave() { Dal<Book> dal = new Dal<Book>(); Book book = new Book(); book.Author = "Abhishek"; book.Copies = 2; book.Description = "Nice book"; book.Name = "New book"; book.Price = 500; book.Publisher = "Mehta Publisher"; IList<Book> books = new List<Book>(); books.Add(book); Assert.IsTrue(dal.Save(books)); }
public UserBookRequest GetUserBookRequestById(int returnid) { try { String query = "From UserBookRequest br where br.Id=" + returnid; IDal<UserBookRequest> dal = new Dal<UserBookRequest>(); IList<UserBookRequest> userBookRequestList = dal.Read(query); UserBookRequest userBookRequest = userBookRequestList.FirstOrDefault(); return userBookRequest; } catch (Exception e) { Console.WriteLine("Error at UserbookRequestDal , GetUserBookRequestById()"); Console.Write(e.ToString()); return null; } }
public TaskReportVm(Model.TaskReport model, Dal.SoheilEdmContext uow) { Model = model; UOW = uow; _taskReportDataService = new DataServices.TaskReportDataService(UOW); TargetPoint = Model.TaskReportTargetPoint; ProducedG1 = Model.TaskProducedG1; DurationSeconds = Model.ReportDurationSeconds; StartDateTime = Model.ReportStartDateTime; EndDateTime = Model.ReportEndDateTime; _isInInitializingPhase = false; IsUserDrag = false; initializeCommands(); }
protected void btnsubmit_Click(object sender, EventArgs e) { Dal d = new Dal(); int id =Convert.ToInt32( txtid.Text); string name = txtname.Text; string mobile = txtmobile.Text; string salary = txtsalary.Text; try { d.Insert(id, name, salary, mobile); Response.Write("data inserted"); } finally { d = null; } }
public List <string> GetKeys() { return(Dal.GetKeys()); }
///// <summary>执行SQL查询,返回记录集</summary> ///// <param name="builder">SQL语句</param> ///// <param name="startRowIndex">开始行,0表示第一行</param> ///// <param name="maximumRows">最大返回行数,0表示所有行</param> ///// <param name="convert">转换器</param> ///// <returns></returns> //public virtual T Query<T>(SelectBuilder builder, Int64 startRowIndex, Int64 maximumRows, Func<IDataReader, T> convert) //{ // InitData(); // return Dal.Query(builder, startRowIndex, maximumRows, convert); //} /// <summary>执行SQL查询,返回记录集</summary> /// <param name="builder">SQL语句</param> /// <param name="startRowIndex">开始行,0表示第一行</param> /// <param name="maximumRows">最大返回行数,0表示所有行</param> /// <returns></returns> public virtual DbSet Query(SelectBuilder builder, Int64 startRowIndex, Int64 maximumRows) { InitData(); return(Dal.Query(builder, startRowIndex, maximumRows)); }
/// <summary> /// 分页获取获取系统参数表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize, string orderby, ref int pageCount, ref int recordCount) { return(Dal.From <SystemCode>().OrderBy(new OrderByClip(orderby)).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount)); }
internal SystemCode GetItemByCode(string code) { return(Dal.Find <SystemCode>(SystemCode._.Code == code)); }
/// <summary> /// 批量删除ids格式为id1,id2,...的数据 /// </summary> public int DelateById(string IDS) { return(Dal.Delete <SystemCode>(SystemCode._.ID.In(IDS.Split(',')))); }
public int DeleteEmployee(string employeeNumber) { return(Dal.DeleteEmployee(employeeNumber)); }
public List <string> GetColumnsTwo() { return(Dal.GetColumnsTwo()); }
public List <TableConstraint> GetConstraints() { return(Dal.GetConstraints()); }
public List <Employee> GetSickleave() { return(Dal.GetSickleave()); }
/// <summary>查询记录数</summary> /// <param name="builder">查询生成器</param> /// <returns>记录数</returns> public virtual Int32 QueryCount(SelectBuilder builder) { InitData(); return(Dal.SelectCount(builder)); }
public List <Employee> GetMostSick() { return(Dal.GetMostSick()); }
public void Send(string Subject, string Body, string To) { string officeMails = ""; DataTable dtUsers = Dal.ExeSp("GetUsersTable"); DataRow[] result = dtUsers.Select("IsEmail=True And Email<>'' And Email Is Not Null"); bool isFirst = true; foreach (DataRow row in result) { if (isFirst) { officeMails = row["Email"].ToString(); isFirst = false; } else { officeMails += "," + row["Email"].ToString(); } } SmtpClient SmtpServer = new SmtpClient(); MailMessage actMSG = new MailMessage(); SmtpServer.Host = "yossilouk.cloudwm.com"; SmtpServer.Port = 25; SmtpServer.UseDefaultCredentials = false; string mail_user = "******"; string mail_pass = "******"; SmtpServer.Credentials = new System.Net.NetworkCredential(mail_user, mail_pass); actMSG.IsBodyHtml = true; actMSG.Subject = Subject; actMSG.Body = String.Format("{0}", Body); actMSG.To.Add("*****@*****.**"); //actMSG.To.Add("*****@*****.**"); //if (!string.IsNullOrEmpty(officeMails)) //{ // actMSG.To.Add(officeMails); //} if (!string.IsNullOrEmpty(To)) { actMSG.To.Add(To); } actMSG.From = new MailAddress("*****@*****.**"); try { SmtpServer.Send(actMSG); actMSG.Dispose(); } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } }
public List <Index> GetIndices() { return(Dal.GetIndices()); }
/// <summary> /// 根据where条件获取实体 /// </summary> public RoleInfo GetItemById(WhereClip where) { return(Dal.Find <RoleInfo>(where)); }
public List <string> GetTablesTwo() { return(Dal.GetTablesTwo()); }
/// <summary> /// 批量删除ids格式为id1,id2,...的数据 /// </summary> public int DelateById(string IDS) { return(Dal.Delete <RoleInfo>(RoleInfo._.ID.In(IDS.Split(',')))); }
public int AddEmployee(string employeeNumber, string firstname, string lastname) { return(Dal.AddEmployee(employeeNumber, firstname, lastname)); }
/// <summary> /// 是否存在相同编号,或名称 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool ExitCodeAndName(RoleInfo entity) { return(Dal.Exists <RoleInfo>(RoleInfo._.ID != entity.ID && (RoleInfo._.Code == entity.Code || RoleInfo._.Name == entity.Name))); }
/// <summary> /// 根据where条件获取实体 /// </summary> public SystemCode GetItemById(WhereClip where) { return(Dal.Find <SystemCode>(where)); }
public int DelateRolePersonById(Guid guid) { return(Dal.Delete <RolePerson>(guid)); }
/// <summary> /// 是否存在相同编号,或名称 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool ExitCodeAndName(SystemCode entity) { return(Dal.Exists <SystemCode>(SystemCode._.ID != entity.ID && (SystemCode._.Code == entity.Code || SystemCode._.Name == entity.Name))); }
/// <summary> /// 获取角色表datatable /// </summary> /// <returns></returns> public DataTable GetDataTable() { return(Dal.From <RoleInfo>().ToDataTable()); }
/// <summary> /// 获取系统参数表datatable /// </summary> /// <returns></returns> public DataTable GetDataTable() { return(Dal.From <SystemCode>().ToDataTable()); }
public ActionResult <IList <MostPlayedSongs> > Get() { return(new ActionResult <IList <MostPlayedSongs> >(Dal.GetMostPlayedSongs(null))); }
private Int64 GetCount(Int64 count) { //if (count >= 0) //{ // // 小于1000的精确查询,大于1000的快速查询 // if (count <= 1000L) // { // var builder = new SelectBuilder // { // Table = FormatedTableName // }; // return Dal.SelectCount(builder); // } //} // 第一次访问,SQLite的Select Count非常慢,数据大于阀值时,使用最大ID作为表记录数 if (count < 0 && Dal.DbType == DatabaseType.SQLite && Table.Identity != null) { var builder = new SelectBuilder { Table = FormatedTableName, OrderBy = Table.Identity.Desc() }; var ds = Dal.Query(builder, 0, 1); if (ds.Columns.Length > 0 && ds.Rows.Count > 0) { count = Convert.ToInt64(ds.Rows[0][0]); } //var rs = Dal.Query(builder, 0, 0, dr => dr.Read() ? dr[0].ToInt() : -1); //if (rs > 0) count = rs; } // 100w数据时,没有预热Select Count需要3000ms,预热后需要500ms if (count < 500000) { if (count <= 0) { count = Dal.Session.QueryCountFast(TableNameWithPrefix); } // 查真实记录数,修正FastCount不够准确的情况 if (count < 10000000) { var builder = new SelectBuilder { Table = FormatedTableName }; count = Dal.SelectCount(builder); } } else { // 异步查询弥补不足,千万数据以内 if (count < 10000000) { count = Dal.Session.QueryCountFast(TableNameWithPrefix); } } return(count); }
public List <Employee> GetEmployees() { return(Dal.GetEmployees()); }
/// <summary>执行SQL查询,返回记录集</summary> /// <param name="sql">SQL语句</param> /// <returns></returns> public virtual DbSet Query(String sql) { InitData(); return(Dal.Query(sql)); }
public List <EmployeeRelative> GetEmployeeRelatives() { return(Dal.GetEmployeeRelatives()); }
/// <summary>查询记录数</summary> /// <param name="sql">SQL语句</param> /// <returns></returns> public virtual Int32 QueryCount(String sql) { InitData(); return(Dal.SelectCount(sql, CommandType.Text, null)); }
// public bool IsFirst = true; public void txtChanged(object sender, EventArgs e) { string Passport = ((TextBox)sender).Text; DataTable dt = Dal.ExeSp("GetExpertRegister", Passport); if (dt.Rows.Count > 0) { // מכניס את המומחה עצמו txtSurname.Text = dt.Rows[0]["Surname"].ToString(); txtName.Text = dt.Rows[0]["Name"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); txtPhone.Text = dt.Rows[0]["Phone"].ToString(); txtJob.Text = dt.Rows[0]["Job"].ToString(); txtPassportIssueDate.Text = dt.Rows[0]["PassportIssueDate"].ToString(); txtPassportExpDate.Text = dt.Rows[0]["PassportExpDate"].ToString(); txtStreet.Text = dt.Rows[0]["StreetAndHouse"].ToString(); txtTown.Text = dt.Rows[0]["Town"].ToString(); txtCountry.Text = dt.Rows[0]["Country"].ToString(); txtDateofBirth.Text = dt.Rows[0]["DateofBirth"].ToString(); HiddenFieldExpertRegId.Value = dt.Rows[0]["ExpertRegId"].ToString(); // אישה if (dt.Rows.Count > 1) { txtSoupFamilyname.Text = dt.Rows[1]["Surname"].ToString(); txtSoupGivenname.Text = dt.Rows[1]["Name"].ToString(); txtSoupPassport.Text = dt.Rows[1]["Passport"].ToString(); txtSoupPassportIsueDate.Text = dt.Rows[1]["PassportIssueDate"].ToString(); txtSoupPassportExpDate.Text = dt.Rows[1]["PassportExpDate"].ToString(); txtSoupPlaceofBirth.Text = dt.Rows[1]["Country"].ToString(); txtSoupMaidenname.Text = dt.Rows[1]["Maidenname"].ToString(); txtSoupFathersname.Text = dt.Rows[1]["Fathersname"].ToString(); txtSoupDateofBirth.Text = dt.Rows[1]["DateofBirth"].ToString(); HiddenFieldSoup.Value = dt.Rows[1]["ExpertRegId"].ToString(); } // ילדים if (dt.Rows.Count > 2) { int ChildCount = dt.Rows.Count - 2; for (int i = 1; i <= ChildCount; i++) { TextBox txtChildGivenname = Page.FindControl("txtChild" + i.ToString() + "Givenname") as TextBox; txtChildGivenname.Text = dt.Rows[1 + i]["Name"].ToString(); TextBox txtChildCountryofbirth = Page.FindControl("txtChild" + i.ToString() + "Countryofbirth") as TextBox; txtChildCountryofbirth.Text = dt.Rows[1 + i]["Country"].ToString(); TextBox txtChildDateofBirth = Page.FindControl("txtChild" + i.ToString() + "DateofBirth") as TextBox; txtChildDateofBirth.Text = dt.Rows[1 + i]["DateofBirth"].ToString(); TextBox txtChildPassport = Page.FindControl("txtChild" + i.ToString() + "Passport") as TextBox; txtChildPassport.Text = dt.Rows[1 + i]["Passport"].ToString(); TextBox txtChildPassportIsueDate = Page.FindControl("txtChild" + i.ToString() + "PassportIsueDate") as TextBox; txtChildPassportIsueDate.Text = dt.Rows[1 + i]["PassportIssueDate"].ToString(); TextBox txtChildPassportExpDate = Page.FindControl("txtChild" + i.ToString() + "PassportExpDate") as TextBox; txtChildPassportExpDate.Text = dt.Rows[1 + i]["PassportExpDate"].ToString(); HiddenField hdnFiled = Page.FindControl("HiddenFieldChild" + i.ToString()) as HiddenField; hdnFiled.Value = dt.Rows[1 + i]["ExpertRegId"].ToString(); } } } }