/// <summary> /// Retourne la note totale de la recette /// </summary> public static int GetNoteTotaleByRecette(DBO.Recette recette) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { return Convert.ToInt32(cuisineEntities.T_Note.Where(e => e.idRecette == recette.Id).Sum(e => e.note)); } }
/// <summary> /// Retourne les commentaires de cette recette /// </summary> public static List<DBO.Commentaire> GetCommentaireByRecette(DBO.Recette recette) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { return ConvertToDBO(cuisineEntities.T_Commentaire.Where(e => e.recetteID == recette.Id).ToList()); } }
/// <summary> /// Retourne la liste des notes d'un utilisateur /// </summary> public static List<DBO.Note> GetNoteByUser(DBO.User user) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { return ConvertToDBO(cuisineEntities.T_Note.Where(e => e.idUser == user.Id).ToList()); } }
public virtual string Presentation(DBO.Atelier atelier) { string str = ""; str ="Name : " + atelier.Name + "\n\n\n"+"Description : "+ atelier.Description; return str; }
/// <summary> /// Retourne les commentaires de cet utilisateur /// </summary> public static List<DBO.Commentaire> GetCommentaireByUser(DBO.User user) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { return ConvertToDBO(cuisineEntities.T_Commentaire.Where(e => e.utilisateurID == user.Id).ToList()); } }
public decimal Calculate(DBO.Atelier atelier) { decimal restrack = 0; decimal resviva = 0; decimal result = 0; if (CalculateStrategy != null) { return CalculateStrategy.CalculateAverage(atelier); } else { foreach (decimal elt in atelier.TrackMark) { restrack += elt; } foreach (decimal elt in atelier.VivaMark) { resviva += elt; } result = (restrack + resviva) / (atelier.TrackMark.Length + atelier.VivaMark.Length); } return result; }
public static void checkCompany(string username) { SqlConnection connection = DBO.CreateConn(); SqlDataAdapter adapter = new SqlDataAdapter("select usertype,end_time from company where username='******'", connection); DataSet ds = new DataSet(); adapter.Fill(ds); string strType = ds.Tables[0].Rows[0]["usertype"].ToString(); string strSpan = ds.Tables[0].Rows[0]["end_time"].ToString(); if (strType == "0") { DBO.UserRole(username, "c_test"); } else { DateTime now = DateTime.Now; TimeSpan span = (TimeSpan)(DateTime.Parse(strSpan) - now); if (span.Hours > 0) { DBO.UserRole(username, "c_normal"); } else { DBO.UserRole(username, "c_end"); } } }
protected void Page_Load(object sender, EventArgs e) { string Logon = Request.Form["Logon"]; if (!string.IsNullOrEmpty(Logon)) { FormsAuthentication.SignOut(); return; } string loginName = Request.Form["loginName"]; if (string.IsNullOrEmpty(loginName)) { return; } FormsAuthentication.SetAuthCookie(loginName, true); var stsdt = DBO.UserRole(loginName, "myrole1"); var sdfs = DBO.Login_Role(); var sdgf = DBO.isRole("sdgklfas"); var sdgf2 = DBO.isRole("myrole1"); }
public ActionResult UpdEmployee(int id) { var dbo = DBO.GetInstance(); var emp = dbo.getEmployee(id); return(View(emp)); }
public Form_ListaPalestrante() { dashboard = new Dashboard(); dbo = new DBO(); estados = new Estados(); InitializeComponent(); }
/// <summary> /// Création d'un ingrédient /// </summary> public static string NewIngredient(DBO.Ingredient ingredient) { try { using (CuisineEntities cuisineEntities = new CuisineEntities()) { T_Ingredient item = cuisineEntities.T_Ingredient.SingleOrDefault(e => e.nom == ingredient.Nom); if (item == null) { cuisineEntities.T_Ingredient.AddObject(ConvertToEntity(ingredient)); cuisineEntities.SaveChanges(); } T_RecetteIngredient ring = new T_RecetteIngredient(); ring.ingredientID = cuisineEntities.T_Ingredient.SingleOrDefault(e => e.nom == ingredient.Nom).id; ring.recetteID = ingredient.idRecette; cuisineEntities.T_RecetteIngredient.AddObject(ring); cuisineEntities.SaveChanges(); return string.Empty; } } catch (Exception e) { Console.Out.WriteLine(e.Message); return e.Message; } }
/// <summary> /// 取消入住 /// </summary> /// <param name="intID"></param> /// <param name="intBedID"></param> /// <param name="intEmployeeCheckInID"></param> public void CancelCheckIn(int intID, int intBedID, int intEmployeeCheckInID) { //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //更新床位状态为空闲 _mTB_BedDAL.Update(intBedID, _tran, _db, TypeManager.BedStatus.Free); //删除入住记录 _mTB_EmployeeCheckInDAL.Delete(intEmployeeCheckInID, _tran, _db); //删除分配记录 _mTB_AssignRoomDAL.Delete(intID, _tran, _db); //提交事务 _tran.Commit(); } catch (Exception ex) { //回滚事务 _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } }
/// <summary> /// 房间分配 /// </summary> /// <param name="tb_EmployeeCheckIn"></param> public bool AssignRoom(TB_EmployeeCheckIn tb_EmployeeCheckIn) { //启用事务 var bAssign = true; _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); _tran = _connection.BeginTransaction(); try { //更新床位状态为已分配未入住(已修改分配且入住) _mTB_BedDAL.Update(tb_EmployeeCheckIn.BedID, _tran, _db, TypeManager.BedStatus.Busy); //添加入住记录,注意现在的入住记录是无效的(已修改未一键分配,入住记录有效) _mTB_EmployeeCheckInDAL.Create(tb_EmployeeCheckIn, _tran, _db); //删除分配信息 _mTB_BedDAL.DeleteAssignDormArea(tb_EmployeeCheckIn.CardNo, _tran, _db); //提交事务 _tran.Commit(); } catch (Exception ex) { //回滚事务 bAssign = false; _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } return(bAssign); }
public override string Presentation(DBO.Atelier atelier) { DefaultAtelier ate = new DefaultAtelier(); string str = ate.Presentation(atelier); str += "\nUrl :" + "http://adobe.com"; return (str); }
/// <summary> /// 加载用户信息 /// </summary> private void load_user() { //要查询的信息 string UserPhone = "UserPhone"; string UserName = "******"; string UserEmail = "UserEmail"; string UserAdd = "UserAdd"; //开始查询 DBO dbo = new DBO(); dbo.Open(); string tableName = "user_table"; string userNameCol = "user_id"; string mge = dbo.FindRow(tableName, userNameCol, this.userID); dbo.Close(); //查询 结束 if (mge == null) { MessageBox.Show("未查找到!", "错误"); return; } string[] splitChar = { "," }; string[] result = mge.Split(splitChar, StringSplitOptions.None); this.phone = result[1]; this.username = result[2]; this.email = result[4]; this.add = result[6]; this.refreshLbl(); //MessageBox.Show(mge); }
public void LoadDataSource(DBO db) { if (dset == null) { dset = new DataSet(); } /* Prepare & Execute SQL */ foreach (KeyValuePair <string, string> pair in sqlList) { string tableName = pair.Key; string sql = pair.Value; sql = PrepareSql(sql, paramMap); // Execute SQL. int retcode; DataSet sqlSet = db.SqlQuery(out retcode, sql); if (retcode != 0) { throw new Exception("Execute SQL Error: [" + sql + "]"); } DataTable table = sqlSet.Tables [0]; table.TableName = tableName; sqlSet.Tables.Remove(table); dset.Tables.Add(table); // dset.Merge(table); } }
// GET: Claim public ActionResult Index() { try { using (var db = new ProjeEntities()) { var emp = Session["emp"] as Employee; var ct = db.ClaimTypes.ToList(); List <MVCProje.Models.ClaimType> ctt = new List <MVCProje.Models.ClaimType>(); foreach (ProjeDB.ClaimType item in ct) { ctt.Add(new Models.ClaimType { Id = item.Id, Name = item.Name }); } List <Models.ClaimOther> co = new List <Models.ClaimOther>(); List <Models.ClaimHoliday> ch = new List <Models.ClaimHoliday>(); var clistother = db.EmployeeClaims.Where(x => x.EmployeeId == emp.Id).Where(z => z.ClaimTypeId == 1).ToList(); var clistholiday = db.EmployeeClaims.Where(x => x.EmployeeId == emp.Id).Where(z => z.ClaimTypeId == 2).ToList(); var dbo = DBO.GetInstance(); foreach (var item in clistholiday) { var returnch = dbo.getCholidaybyId(item.Id); Models.ClaimHoliday mch = new Models.ClaimHoliday(); mch.Id = returnch.Id; mch.Start = Convert.ToDateTime(returnch.StartDate); mch.Finish = Convert.ToDateTime(returnch.FinishDate); mch.Accept = (Boolean)returnch.Accept; ch.Add(mch); } foreach (var item in clistother) { var returnch = dbo.getCOtherbyId(item.Id); Models.ClaimOther mco = new Models.ClaimOther(); mco.Id = returnch.Id; mco.Details = returnch.Details; co.Add(mco); } MVCProje.Models.ClaimModel Cmodel = new ClaimModel(); Cmodel.ClaimTypeModel = ctt; Cmodel.ClaimHolidayModel = ch; Cmodel.ClaimOtherModel = co; return(View(Cmodel)); } } catch (Exception) { throw; } }
public static string GenerateReportBug(DBO.BugReport bugReport) { string docName = System.Web.HttpContext.Current.Server.MapPath("~/download/")+"test.docx"; using (WordprocessingDocument package = WordprocessingDocument.Create( docName, WordprocessingDocumentType.Document)) { Run run = new Run(); //besoin de le faire si c'est une creation package.AddMainDocumentPart(); foreach (string str in bugReport.Comment) { run.Append(new Text(str), new Break()); } // Création du document. package.MainDocumentPart.Document = new Document( new Body( new Paragraph( new Run( new Text("Rapport de bug"))), new Run( new Text ("Titre :" + bugReport.Title), new Break(), new Text ("Personnable responble :" + bugReport.Responsable), new Break(), new Text ("Statut :" + bugReport.Statut), new Break (), new Text ("commentaire:") ),run)); // Enregistrer le contenu dans le document package.MainDocumentPart.Document.Save(); return docName; } }
/// <summary> /// Retourne les conseils créés par cet utilisateur /// </summary> public static List<DBO.Conseil> GetConseilByUser(DBO.User user) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { return ConvertToDBO(cuisineEntities.T_Conseil.Where(e => e.idCreateur == user.Id).ToList()); } }
/// <summary> /// Retourne true si le pseudo et le mot de passe sont valide /// </summary> public static bool IsValid(DBO.User user) { DBO.User tableUser = GetUserByName(user.Name); if (tableUser != null) return (tableUser.Password == user.Password); else return false; }
//2019-02-18 导入更新已经入住的记录 private void UpdateExistCheckin(DataTable dtError, DataRow dr, DataRow[] drCheckin) { dr["BZ"] = "已有入住记录,更新"; dtError.ImportRow(dr); //更新状态 _mTB_EmployeeCheckInDAL.UpdateExist(Convert.ToInt32(drCheckin[0][TB_EmployeeCheckIn.col_ID]), dr, null, DBO.GetInstance()); }
public DataTable showCustDetailsById(int id) { string sql = "spLoadCustActByAccNo"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@id", id) }; return(DBO.GetTable(sql, param, CommandType.StoredProcedure)); }
public DataTable showCustDetailsByName(string name) { string sql = "spLoadCustActByCustName"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@name", name + "%") }; return(DBO.GetTable(sql, param, CommandType.StoredProcedure)); }
public DataTable getChqIssueDetail(string custname) { string sql = "select * from tblchqNo where custName = @custNames"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@custNames", custname) }; return(DBO.GetTable(sql, param, CommandType.Text)); }
/// <summary>执行插入语句并返回新增行的自动编号</summary> /// <param name="sql">SQL语句</param> /// <returns>新增行的自动编号</returns> public static Int64 InsertAndGetIdentity(String sql) { WaitForInitData(); Int64 rs = DBO.InsertAndGetIdentity(sql, Meta.TableName); executeCount++; DataChange("修改数据"); return(rs); }
/// <summary>执行</summary> /// <param name="sql">SQL语句</param> /// <returns>影响的结果</returns> public static Int32 Execute(String sql) { WaitForInitData(); Int32 rs = DBO.Execute(sql, Meta.TableName); executeCount++; DataChange("修改数据"); return(rs); }
/// <summary>执行</summary> /// <param name="sql">SQL语句</param> /// <param name="type">命令类型,默认SQL文本</param> /// <param name="ps">命令参数</param> /// <returns>影响的结果</returns> public static Int32 Execute(String sql, CommandType type = CommandType.Text, params DbParameter[] ps) { WaitForInitData(); Int32 rs = DBO.Execute(sql, type, ps, Meta.TableName); executeCount++; DataChange("修改数据"); return(rs); }
public DataTable showcurrbalanceByaccno(string accno) { string sql = "spshowcurrentBalancecustNameByAccNo"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@acctno", accno) }; return(DBO.GetTable(sql, param, CommandType.StoredProcedure)); }
public DTO adapt(DBO dbo) { InsurranceLogic.EFDataBaseConecction.TiposCubrimiento TiposCubrimientoDBO = (InsurranceLogic.EFDataBaseConecction.TiposCubrimiento)dbo; InsurranceLogic.Model.TiposCubrimiento TiposCubrimientoDTO = new TiposCubrimiento(); TiposCubrimientoDTO.Nombre = TiposCubrimientoDBO.Nombre; TiposCubrimientoDTO.descripcion = TiposCubrimientoDBO.descripcion; TiposCubrimientoDTO.id = TiposCubrimientoDBO.id; return(TiposCubrimientoDTO); }
/// <summary>执行插入语句并返回新增行的自动编号</summary> /// <param name="sql">SQL语句</param> /// <param name="type">命令类型,默认SQL文本</param> /// <param name="ps">命令参数</param> /// <returns>新增行的自动编号</returns> public static Int64 InsertAndGetIdentity(String sql, CommandType type = CommandType.Text, params DbParameter[] ps) { WaitForInitData(); Int64 rs = DBO.InsertAndGetIdentity(sql, type, ps, Meta.TableName); executeCount++; DataChange("修改数据"); return(rs); }
/// <summary> /// Conversion DBO -> Entity /// </summary> public static T_Ingredient ConvertToEntity(DBO.Ingredient ingredient) { T_Ingredient entity = new T_Ingredient(); if (ingredient != null) { entity.nom = ingredient.Nom; } return entity; }
/// <summary> /// Retourne la note d'un utilisateur pour une recette /// </summary> public static DBO.Note GetNoteByUserForRecette(DBO.User user, DBO.Recette recette) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { T_Note note = cuisineEntities.T_Note.Where(e => e.idUser == user.Id && e.idRecette == recette.Id).SingleOrDefault(); if (note == null) return null; else return ConvertToDBO(note); } }
public int deleteAccount(string acctno, int id) { string sql = "spDeleteCustAct"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@acctno", acctno), new SqlParameter("@id", id) }; return(DBO.IUD(sql, param, CommandType.StoredProcedure)); }
public JsonResult DelEmp(int id) { using (var db = new ProjeEntities()) { var dbo = DBO.GetInstance(); var cus = Session["UserCompany"] as UserCompany; var delClaim = dbo.delEmployee(id); db.SaveChanges(); return(Json("")); } }
/// <summary> /// 菜单保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.game_id != null) { return; } //GUID生成GAME ID string game_id = Guid.NewGuid().ToString(); this.game_id = game_id; DBO dbo = new DBO(); dbo.Open(); //在game table中插入初始化信息 string[] mge1 = { "game_id", "match_id", "game_home_id", "game_visit_id", "game_date", "game_begin_time", "game_half_scored", "game_end_scored", "game_extra_time_scored", "game_penalty_scored", game_id, "01", "0001", "0002", "", "", "", "", "", "" }; dbo.Insert("game_table", mge1.Length / 2, mge1); //在user_work中插入初始化信息 string[] mge2 = { "user_work_id", "user_id", "game_id", "work_state", this.home.get_userId() + game_id, this.home.get_userId(), game_id, "未完成" }; dbo.Insert("user_work_table", mge2.Length / 2, mge2); //GameRefereeTable中插入相关信息 string[] mge3 = { "Greferee_id", "game_id", "referee_id_1", "0001" + game_id, game_id, "0001" }; dbo.Insert("game_referee_table", mge3.Length / 2, mge3); //RefereeDataTable RefereePostionDataTable ActionDataTable 插入信息 int rowLen = this.dataGridView1.Rows.Count; int colLen = this.dataGridView1.Columns.Count; for (int i = 0; i < rowLen; i++) { //this.dataGridView1[j, i].Value; //RefereeDataTable string RefereeDataID = i.ToString() + game_id; string[] mge6 = { "referee_data_id", "game_id", RefereeDataID, game_id, }; dbo.Insert("referee_data_table", mge6.Length / 2, mge6); //RefereePostionDataTable string RPositionDataID = Guid.NewGuid().ToString(); string[] mge4 = { "R_position_data_id", "referee_data_id", "R_position", "P_time", RPositionDataID, RefereeDataID, (string)this.dataGridView1[2, i].Value, (string)this.dataGridView1[1, i].Value }; dbo.Insert("referee_postion_data_table", mge4.Length / 2, mge4); //ActionDataTable string ActionDataID = Guid.NewGuid().ToString(); string[] mge5 = { "action_data_id", "referee_data_id", "action_type", "action_position", "action_time", ActionDataID, RefereeDataID, "action id", (string)this.dataGridView1[4, i].Value, (string)this.dataGridView1[1, i].Value }; dbo.Insert("action_data_table", mge5.Length / 2, mge5); //添加 RefereeDataTable 的信息 string[] mge7 = { "action_data_id", ActionDataID, "R_position_id", RPositionDataID }; dbo.Set("referee_data_table", "referee_data_id", RefereeDataID, mge7); } dbo.Close(); MessageBox.Show("保存成功!"); }
/// <summary> /// 调房---退房记录 /// </summary> /// <param name="intID"></param> public void AddCheckOut(int intID) { DataTable dtCheckIn = null; //入住信息 TB_EmployeeCheckOut mTB_EmployeeCheckOut = null; //退房记录 //启用事务 _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); try { dtCheckIn = _mTB_EmployeeCheckInDAL.Get(intID); //添加退房记录 mTB_EmployeeCheckOut = new TB_EmployeeCheckOut(); mTB_EmployeeCheckOut.BedID = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BedID]); mTB_EmployeeCheckOut.BU = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BU].ToString(); mTB_EmployeeCheckOut.BUID = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_BUID]); mTB_EmployeeCheckOut.CardNo = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CardNo].ToString(); mTB_EmployeeCheckOut.CheckInDate = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate] is DBNull ? DateTime.Now : Convert.ToDateTime(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_CheckInDate]); mTB_EmployeeCheckOut.CheckOutDate = DateTime.Now; mTB_EmployeeCheckOut.Company = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Company].ToString(); mTB_EmployeeCheckOut.Creator = SessionHelper.Get(HttpContext.Current, TypeManager.User) == null ? ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account : ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount; mTB_EmployeeCheckOut.EmployeeNo = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeNo].ToString(); mTB_EmployeeCheckOut.IsSmoking = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking] is DBNull ? false : Convert.ToBoolean(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_IsSmoking]); mTB_EmployeeCheckOut.Name = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Name].ToString(); mTB_EmployeeCheckOut.Province = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Province].ToString(); mTB_EmployeeCheckOut.RoomID = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_RoomID]); mTB_EmployeeCheckOut.Sex = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex] is DBNull ? 0 : Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Sex]); mTB_EmployeeCheckOut.SiteID = Convert.ToInt32(dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_SiteID]); mTB_EmployeeCheckOut.Telephone = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone] is DBNull ? string.Empty : dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_Telephone].ToString(); mTB_EmployeeCheckOut.Reason = "换房"; mTB_EmployeeCheckOut.Remark = "换房产生"; mTB_EmployeeCheckOut.EmployeeTypeName = dtCheckIn.Rows[0][TB_EmployeeCheckIn.col_EmployeeTypeName].ToString(); _mTB_EmployeeCheckOutDAL.Create(mTB_EmployeeCheckOut); //提交事务 } catch (Exception ex) { //回滚事务 _tran.Rollback(); throw ex; } finally { //关闭连接 _connection.Close(); } }
/// <summary> /// Retourne les ingredients de cette recette /// </summary> public static List<DBO.Ingredient> GetIngredientByRecette(DBO.Recette recette) { using (CuisineEntities cuisineEntities = new CuisineEntities()) { List<T_Ingredient> ingredients = new List<T_Ingredient>(); foreach (T_RecetteIngredient item in cuisineEntities.T_RecetteIngredient.Where(e => e.recetteID == recette.Id).ToList()) { ingredients.Add(item.T_Ingredient); } return ConvertToDBO(ingredients); } }
void form_FormClosed(object sender, FormClosedEventArgs e) { try { HardDeviceManaging.rec = this; } catch (Exception ex) { DBO.Err(ex); MessageBox.Show(ex.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MainWithGrid_Load(object sender, EventArgs e) { try { HardDeviceManaging.rec = this; } catch (Exception ex) { DBO.Err(ex); MessageBox.Show(ex.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 点击登陆按钮,检查输入后,从数据库中查找用户信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sign_Click(object sender, EventArgs e) { this.username = text_userName.Text; this.password = text_password.Text; bool isSuccess = false; //检查用户名和密码不能为空,为空者获得相应的输入焦点,并且函数return if (this.username == "" || this.username == null) { MessageBox.Show("请输入用户名!", "错误"); text_userName.Focus(); return; } if (this.password == "" || this.password == null) { MessageBox.Show("请输入密码!", "错误"); text_password.Focus(); return; } //要查询的信息 string tableName = "user_table"; string userNameCol = "user_id"; string passwordCol = "user_pwd"; //数据库中检查用户名和密码 //检查用户名和密码 开始 DBO dbo = new DBO(); dbo.Open(); isSuccess = dbo.IsAllExisted(tableName, userNameCol, "123456", passwordCol, "123456"); dbo.Close(); //检查用户名和密码 结束 //输入正确则打开主页面,不正确提示用户名或密码错误,清空密码,密码框获得焦点 if (isSuccess) { MessageBox.Show("登陆成功!", "提示"); //打开主页面 this.Hide(); optForm optform = new optForm(this.username); optform.StartPosition = FormStartPosition.CenterScreen; optform.Show(); } else { MessageBox.Show("用户名或密码错误!", "提示"); text_password.Text = ""; text_password.Focus(); } }
/// <summary> /// Conversion DBO -> Entity /// </summary> public static T_Note ConvertToEntity(DBO.Note note) { T_Note entity = new T_Note(); if (note != null) { entity.idRecette = note.idRecette; entity.idUser = note.idUser; entity.note = note.NoteRecette; } return entity; }
/// <summary> /// Conversion DBO -> Entity /// </summary> public static T_Commentaire ConvertToEntity(DBO.Commentaire commentaire) { T_Commentaire entity = new T_Commentaire(); if (commentaire != null) { entity.texte = commentaire.Text; entity.utilisateurID = commentaire.idUser; entity.recetteID = commentaire.idRecette; } return entity; }
/// <summary>回滚事务</summary> /// <returns></returns> public static Int32 Rollback() { TransCount = DBO.Rollback(); // 回滚的时候貌似不需要更新缓存 //if (TransCount <= 0 && executeCount > 0) DataChange(); if (TransCount <= 0 && executeCount > 0) { // 因为在事务保护中添加或删除实体时直接操作了实体缓存,所以需要更新 DataChange("修改数据后回滚事务"); executeCount = 0; } return(TransCount); }
private void AddToLog(String ucard) { if (timer1.Enabled) { return; } try { Entities.Students stu = DBO.getStudentKH(ucard); String dt = DateTime.Now.ToString(); String evnt = "禁止进门."; if (stu != null) { if (stu.ENABLE) { HardDeviceManaging.OpenTheDoor(); timer1.Enabled = true; evnt = "允许进门."; lbl_ordre.BackColor = Color.Blue; } else { lbl_ordre.BackColor = Color.Red; } lbl_card.Text = stu.CARD; lbl_class.Text = stu.CLASS; lbl_dtime.Text = dt; lbl_name.Text = stu.NAME; lbl_ordre.Text = evnt; lbl_sno.Text = stu.SNO; DBO.Record(stu, dt, evnt); } else { lbl_card.Text = "N/A"; lbl_class.Text = "N/A"; lbl_dtime.Text = dt; lbl_name.Text = "N/A"; lbl_ordre.Text = evnt; lbl_ordre.BackColor = Color.Red; lbl_sno.Text = "N/A"; //MessageBox.Show("未注册!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception e) { DBO.Err(e); MessageBox.Show(e.Message); } }
/// <summary>提交事务</summary> /// <returns></returns> public static Int32 Commit() { TransCount = DBO.Commit(); // 提交事务时更新数据,虽然不是绝对准确,但没有更好的办法 // 即使提交了事务,但只要事务内没有执行更新数据的操作,也不更新 // 2012-06-13 测试证明,修改数据后,提交事务后会更新缓存等数据 if (TransCount <= 0 && executeCount > 0) { DataChange("修改数据后提交事务"); // 回滚到顶层才更新数据 executeCount = 0; } return(TransCount); }
public JsonResult sentvalue(int id) { var db = DBO.GetInstance(); var st = db.getEmployee(id); Models.EmployeeModel emp = new Models.EmployeeModel(); emp.Id = st.Id; emp.Name = st.Name; emp.Surname = st.Surname; emp.Username = st.UserName; emp.Password = st.Password; emp.CardId = st.CardNumber; return(Json(emp)); }
/// <summary> /// Création d'un utilisateur /// Retourne un string vide si tout s'est bien passé, une string contenant les erreurs sinon /// </summary> public static string NewUser(DBO.User user) { try { using (CuisineEntities cuisineEntities = new CuisineEntities()) { cuisineEntities.T_User.AddObject(ConvertToEntity(user)); cuisineEntities.SaveChanges(); return string.Empty; } } catch (Exception e) { return e.Message; } }
/// <summary> /// Création d'une note /// </summary> public static string NewNote(DBO.Note note) { try { using (CuisineEntities cuisineEntities = new CuisineEntities()) { cuisineEntities.T_Note.AddObject(ConvertToEntity(note)); cuisineEntities.SaveChanges(); return string.Empty; } } catch (Exception e) { return e.Message; } }
/// <summary> /// Création d'un commentaire /// Retourne un string vide si tout s'est bien passé, une string contenant les erreurs sinon /// </summary> public static string NewCommentaire(DBO.Commentaire commentaire) { try { using (CuisineEntities cuisineEntities = new CuisineEntities()) { cuisineEntities.T_Commentaire.AddObject(ConvertToEntity(commentaire)); cuisineEntities.SaveChanges(); return string.Empty; } } catch (Exception e) { return e.InnerException.Message; } }
/// <summary> /// Change le mot de passe de l'utilisateur /// </summary> public static bool ChangePassword(DBO.User user, string newPassword) { try { using (CuisineEntities cuisineEntities = new CuisineEntities()) { T_User t_user = cuisineEntities.T_User.SingleOrDefault(e => e.nom == user.Name); t_user.password = newPassword; cuisineEntities.SaveChanges(); return true; } } catch { return false; } }
public static bool SavePerson(DBO.Person person) { try { if (true) { throw new Exception("Exception aleatoire ;)"); } return true; } catch (Exception ex) { ex = ex; LogMe.Log(ex); return false; } }
public decimal CalculateAverage(DBO.Atelier atelier) { decimal restrack = 0; decimal resviva = 0; decimal result = 0; foreach (decimal elt in atelier.TrackMark) { restrack += elt * 2; } foreach (decimal elt in atelier.VivaMark) { resviva += elt * 1; } result = (restrack + resviva) / (atelier.TrackMark.Length + atelier.VivaMark.Length); return result; }
/// <summary> /// Retourne le temps total de confection pour une recette /// </summary> public static int GetTempsTotal(DBO.Recette recette) { return recette.TempsPreparation + recette.TempsCuisson + recette.TempsRepos; }
/// <summary> /// Retourne les recettes favoris d'un utilisateur /// </summary> public static List<DBO.Recette> GetRecetteByUser(DBO.User user) { return DA.Recette.GetRecetteByUser(user); }
/// <summary> /// Création d'une recette /// Retourne un string vide si tout s'est bien passé, une string contenant les erreurs sinon /// </summary> public static string NewRecette(DBO.Recette recette) { return DA.Recette.NewRecette(recette); }
/// <summary> /// Conversion DBO -> Entity /// </summary> public static T_Recette ConvertToEntity(DBO.Recette recette) { T_Recette entity = new T_Recette(); if (recette != null) { entity.nom = recette.Nom; entity.introduction = recette.Intro; entity.realisation = recette.Realisation; entity.temps_cuisson = recette.TempsCuisson; entity.temps_prepa = recette.TempsPreparation; entity.temps_repos = recette.TempsRepos; entity.difficulte = recette.Difficulte; entity.photo = recette.Photo; entity.categorie = recette.Categorie; entity.date = DateTime.Now; entity.createurID = recette.idCreateur; } return entity; }
/// <summary> /// Retourne les commentaires de cet utilisateur /// </summary> public static List<DBO.Commentaire> GetCommentaireByUser(DBO.User user) { return DA.Commentaire.GetCommentaireByUser(user); }
/// <summary> /// Retourne les commentaires de cette recette /// </summary> public static List<DBO.Commentaire> GetCommentaireByRecette(DBO.Recette recette) { return DA.Commentaire.GetCommentaireByRecette(recette); }
/// <summary> /// Création d'un commentaire /// Retourne un string vide si tout s'est bien passé, une string contenant les erreurs sinon /// </summary> public static string NewCommentaire(DBO.Commentaire commentaire) { return DA.Commentaire.NewCommentaire(commentaire); }
/// <summary> /// Conversion DBO -> Entity /// </summary> public static T_Conseil ConvertToEntity(DBO.Conseil conseil) { T_Conseil entity = new T_Conseil(); if (conseil != null) { entity.nom = conseil.Nom; entity.idCreateur = conseil.idCreateur; entity.texte = conseil.Text; entity.dateCreation = conseil.DateCreation; } return entity; }