public static int Update(MGMixAndMatchItems o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); arrParams[1] = new SqlParameter("@MMID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMID, o.MMID.GetTypeCode())); arrParams[2] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode())); arrParams[3] = new SqlParameter("@ItemImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ItemImage, o.ItemImage.GetTypeCode())); arrParams[4] = new SqlParameter("@EasyLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyLabel, o.EasyLabel.GetTypeCode())); arrParams[5] = new SqlParameter("@MediumLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumLabel, o.MediumLabel.GetTypeCode())); arrParams[6] = new SqlParameter("@HardLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardLabel, o.HardLabel.GetTypeCode())); arrParams[7] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode())); arrParams[8] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode())); arrParams[9] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[11] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[12] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[13] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Insert(MGMixAndMatchItems o) { SqlParameter[] arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@MMID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMID, o.MMID.GetTypeCode())); arrParams[1] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode())); arrParams[2] = new SqlParameter("@ItemImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ItemImage, o.ItemImage.GetTypeCode())); arrParams[3] = new SqlParameter("@EasyLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyLabel, o.EasyLabel.GetTypeCode())); arrParams[4] = new SqlParameter("@MediumLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumLabel, o.MediumLabel.GetTypeCode())); arrParams[5] = new SqlParameter("@HardLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardLabel, o.HardLabel.GetTypeCode())); arrParams[6] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode())); arrParams[7] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode())); arrParams[8] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode())); arrParams[9] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[11] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[12] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[13] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); arrParams[13].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Insert", arrParams); o.MMIID = int.Parse(arrParams[13].Value.ToString()); return(o.MMIID); }
public void LoadPage() { var i1 = new MGMixAndMatchItems(); var i2 = new MGMixAndMatchItems(); var i3 = new MGMixAndMatchItems(); MGMixAndMatch.Get3RandomItems(int.Parse(MMID.Text), out i1, out i2, out i3); MGMixAndMatchItems correctItem = null; var correctItemNumber = new Random(DateTime.Now.Millisecond).Next(1, 3); switch(correctItemNumber) { case 1: correctItem = i1; break; case 2: correctItem = i2; break; case 3: correctItem = i3; break; } var difficulty = int.Parse(Difficulty.Text); if(correctItem != null) { MMIID.Text = correctItem.MMIID.ToString(); StringBuilder audio = new StringBuilder(MixMatchBasePath); switch(difficulty) { case 2: //medium lblMixMatch.Text = correctItem.MediumLabel; audio.AppendFormat("m_{0}.mp3", MMIID.Text); break; case 3: //hard lblMixMatch.Text = correctItem.HardLabel; audio.AppendFormat("h_{0}.mp3", MMIID.Text); break; default: lblMixMatch.Text = correctItem.EasyLabel; audio.AppendFormat("e_{0}.mp3", MMIID.Text); break; } if(System.IO.File.Exists(Server.MapPath(audio.ToString()))) { lblSound.Text = string.Format( "<audio controls><source src='{0}' type='audio/mpeg'>Your browser does not support this audio format.</audio>", VirtualPathUtility.ToAbsolute(audio.ToString())); pnlAudio.Visible = true; } } Correct.Text = correctItemNumber.ToString(); btn1.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i1.MMIID); btn2.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i2.MMIID); btn3.ImageUrl = string.Format("{0}{1}.png", MixMatchBasePath, i3.MMIID); }
public static int Delete(MGMixAndMatchItems o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static void Get3RandomItems(int MMID, out MGMixAndMatchItems i1, out MGMixAndMatchItems i2, out MGMixAndMatchItems i3) { var arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMID", MMID); var dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_GetRandom3", arrParams); DateTime _datetime; int _int; //decimal _decimal; i1 = i2 = i3 = null; for (var i = 0; i < 3; i++) { if (!dr.Read()) { continue; } var result = new MGMixAndMatchItems(); if (int.TryParse(dr["MMIID"].ToString(), out _int)) { result.MMIID = _int; } if (int.TryParse(dr["MMID"].ToString(), out _int)) { result.MMID = _int; } if (int.TryParse(dr["MGID"].ToString(), out _int)) { result.MGID = _int; } result.ItemImage = dr["ItemImage"].ToString(); result.EasyLabel = dr["EasyLabel"].ToString(); result.MediumLabel = dr["MediumLabel"].ToString(); result.HardLabel = dr["HardLabel"].ToString(); result.AudioEasy = dr["AudioEasy"].ToString(); result.AudioMedium = dr["AudioMedium"].ToString(); result.AudioHard = dr["AudioHard"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) { result.LastModDate = _datetime; } result.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) { result.AddedDate = _datetime; } result.AddedUser = dr["AddedUser"].ToString(); if (i == 0) { i1 = result; } if (i == 1) { i2 = result; } if (i == 2) { i3 = result; } } dr.Close(); }
public static int Delete(MGMixAndMatchItems o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Update(MGMixAndMatchItems o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); arrParams[1] = new SqlParameter("@MMID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMID, o.MMID.GetTypeCode())); arrParams[2] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode())); arrParams[3] = new SqlParameter("@ItemImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ItemImage, o.ItemImage.GetTypeCode())); arrParams[4] = new SqlParameter("@EasyLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyLabel, o.EasyLabel.GetTypeCode())); arrParams[5] = new SqlParameter("@MediumLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumLabel, o.MediumLabel.GetTypeCode())); arrParams[6] = new SqlParameter("@HardLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardLabel, o.HardLabel.GetTypeCode())); arrParams[7] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode())); arrParams[8] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode())); arrParams[9] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[11] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[12] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[13] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(MGMixAndMatchItems o) { SqlParameter[] arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@MMID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMID, o.MMID.GetTypeCode())); arrParams[1] = new SqlParameter("@MGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MGID, o.MGID.GetTypeCode())); arrParams[2] = new SqlParameter("@ItemImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ItemImage, o.ItemImage.GetTypeCode())); arrParams[3] = new SqlParameter("@EasyLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EasyLabel, o.EasyLabel.GetTypeCode())); arrParams[4] = new SqlParameter("@MediumLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MediumLabel, o.MediumLabel.GetTypeCode())); arrParams[5] = new SqlParameter("@HardLabel", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HardLabel, o.HardLabel.GetTypeCode())); arrParams[6] = new SqlParameter("@AudioEasy", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioEasy, o.AudioEasy.GetTypeCode())); arrParams[7] = new SqlParameter("@AudioMedium", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioMedium, o.AudioMedium.GetTypeCode())); arrParams[8] = new SqlParameter("@AudioHard", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AudioHard, o.AudioHard.GetTypeCode())); arrParams[9] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[11] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[12] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[13] = new SqlParameter("@MMIID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MMIID, o.MMIID.GetTypeCode())); arrParams[13].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_Insert", arrParams); o.MMIID = int.Parse(arrParams[13].Value.ToString()); return o.MMIID; }
public bool Fetch(int MMIID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMIID", MMIID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_GetByID", arrParams); if (dr.Read()) { // declare return value MGMixAndMatchItems result = new MGMixAndMatchItems(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["MMIID"].ToString(), out _int)) this.MMIID = _int; if (int.TryParse(dr["MMID"].ToString(), out _int)) this.MMID = _int; if (int.TryParse(dr["MGID"].ToString(), out _int)) this.MGID = _int; this.ItemImage = dr["ItemImage"].ToString(); this.EasyLabel = dr["EasyLabel"].ToString(); this.MediumLabel = dr["MediumLabel"].ToString(); this.HardLabel = dr["HardLabel"].ToString(); this.AudioEasy = dr["AudioEasy"].ToString(); this.AudioMedium = dr["AudioMedium"].ToString(); this.AudioHard = dr["AudioHard"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime; this.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime; this.AddedUser = dr["AddedUser"].ToString(); dr.Close(); return true; } dr.Close(); return false; }
public static void Get3RandomItems(int MMID, out MGMixAndMatchItems i1, out MGMixAndMatchItems i2, out MGMixAndMatchItems i3 ) { var arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMID", MMID); var dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_GetRandom3", arrParams); DateTime _datetime; int _int; //decimal _decimal; i1 = i2 = i3 = null; for (var i = 0; i < 3 ; i++ ) { if (!dr.Read()) continue; var result = new MGMixAndMatchItems(); if (int.TryParse(dr["MMIID"].ToString(), out _int)) result.MMIID = _int; if (int.TryParse(dr["MMID"].ToString(), out _int)) result.MMID = _int; if (int.TryParse(dr["MGID"].ToString(), out _int)) result.MGID = _int; result.ItemImage = dr["ItemImage"].ToString(); result.EasyLabel = dr["EasyLabel"].ToString(); result.MediumLabel = dr["MediumLabel"].ToString(); result.HardLabel = dr["HardLabel"].ToString(); result.AudioEasy = dr["AudioEasy"].ToString(); result.AudioMedium = dr["AudioMedium"].ToString(); result.AudioHard = dr["AudioHard"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime; result.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime; result.AddedUser = dr["AddedUser"].ToString(); if (i == 0) i1 = result; if (i == 1) i2 = result; if (i == 2) i3 = result; } dr.Close(); }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Setup/MGMixAndMatchItemsAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { Response.Redirect(String.Format("{0}?MGID={1}&MMID={2}", editpage, lblMGID.Text, lblMMID.Text)); //Response.Redirect(editpage); } if (e.CommandName.ToLower() == "back") { Response.Redirect("~/ControlRoom/Modules/Setup/MGMixAndMatchAddEdit.aspx"); //Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGMixAndMatchAddEdit.aspx?PK={0}", lblMGID.Text)); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Response.Redirect(String.Format("{0}?PK={1}", editpage, key)); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new MGMixAndMatchItems(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { MGMixAndMatchItems.FetchObject(key).Delete(); LoadData(); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageMessage = SRPResources.DeleteOK; } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); if (masterPage != null) masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { //string returnURL = "~/ControlRoom/Modules/Setup/MGMixAndMatchItemsList.aspx?MGID=" + lblMGID.Text; string returnURL = "~/ControlRoom/Modules/Setup/MGMixAndMatchItemsList.aspx"; if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "refresh") { try { odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageMessage = SRPResources.RefreshOK; } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback") { try { var obj = new MGMixAndMatchItems(); obj.MMID = FormatHelper.SafeToInt(lblMMID.Text); obj.MGID = FormatHelper.SafeToInt(lblMGID.Text); //obj.ItemImage = ((TextBox)((DetailsView)sender).FindControl("ItemImage")).Text; obj.EasyLabel = ((TextBox)((DetailsView)sender).FindControl("EasyLabel")).Text; obj.MediumLabel = ((TextBox)((DetailsView)sender).FindControl("MediumLabel")).Text; obj.HardLabel = ((TextBox)((DetailsView)sender).FindControl("HardLabel")).Text; //obj.AudioEasy = ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text; //obj.AudioMedium = ((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text; //obj.AudioHard = ((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text; obj.AddedDate = DateTime.Now; obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session obj.LastModDate = obj.AddedDate; obj.LastModUser = obj.AddedUser; if (obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); if (e.CommandName.ToLower() == "addandback") { Response.Redirect(returnURL); } lblPK.Text = obj.MMIID.ToString(); odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.AddedOK; } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { var obj = new MGMixAndMatchItems(); int pk = int.Parse(((TextBox)((DetailsView)sender).FindControl("MMIID")).Text); obj.Fetch(pk); obj.MMID = FormatHelper.SafeToInt(lblMMID.Text); obj.MGID = FormatHelper.SafeToInt(lblMGID.Text); //obj.ItemImage = ((TextBox)((DetailsView)sender).FindControl("ItemImage")).Text; obj.EasyLabel = ((TextBox)((DetailsView)sender).FindControl("EasyLabel")).Text; obj.MediumLabel = ((TextBox)((DetailsView)sender).FindControl("MediumLabel")).Text; obj.HardLabel = ((TextBox)((DetailsView)sender).FindControl("HardLabel")).Text; //obj.AudioEasy = ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text; //obj.AudioMedium = ((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text; //obj.AudioHard = ((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text; obj.LastModDate = DateTime.Now; obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session if (obj.IsValid(BusinessRulesValidationMode.UPDATE)) { obj.Update(); if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.SaveOK; } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }
public bool Fetch(int MMIID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@MMIID", MMIID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_MGMixAndMatchItems_GetByID", arrParams); if (dr.Read()) { // declare return value MGMixAndMatchItems result = new MGMixAndMatchItems(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["MMIID"].ToString(), out _int)) { this.MMIID = _int; } if (int.TryParse(dr["MMID"].ToString(), out _int)) { this.MMID = _int; } if (int.TryParse(dr["MGID"].ToString(), out _int)) { this.MGID = _int; } this.ItemImage = dr["ItemImage"].ToString(); this.EasyLabel = dr["EasyLabel"].ToString(); this.MediumLabel = dr["MediumLabel"].ToString(); this.HardLabel = dr["HardLabel"].ToString(); this.AudioEasy = dr["AudioEasy"].ToString(); this.AudioMedium = dr["AudioMedium"].ToString(); this.AudioHard = dr["AudioHard"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) { this.LastModDate = _datetime; } this.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) { this.AddedDate = _datetime; } this.AddedUser = dr["AddedUser"].ToString(); dr.Close(); return(true); } dr.Close(); return(false); }