protected void AddContactDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { string firstName = e.Values["FirstName"].ToString(); string lastName = e.Values["LastName"].ToString(); string city = e.Values["City"].ToString(); string country = e.Values["Country"].ToString(); string phone = e.Values["PhoneNumber"].ToString(); string email = string.Empty; if (e.Values["Email"] != null) email = e.Values["Email"].ToString(); else { email = ""; } try { AddressBookRepository context = new AddressBookRepository(); context.InsertContact(firstName, lastName, city, country, phone, email, User.Identity.Name); lblMessage.Text = "Contact Added: " + e.Values[0] + e.Values[1]; } catch (OptimisticConcurrencyException ocex) { lblMessage.Text = ocex.ToString(); } catch (Exception) { lblMessage.Text = "An error occured on inserting new contact. Try again."; } }
protected void CampaignDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { long userid; if (String.IsNullOrEmpty(Session["CompanyID"].ToString())) { return; } else { e.Values["CompanyID"] = Convert.ToInt32(Session["CompanyID"]); } if (String.IsNullOrEmpty(Session["UserID"].ToString())) { return; } else { userid = Convert.ToInt64(Session["UserID"]); } if (Convert.ToInt32(CampaignStatusDropDownList.SelectedValue) == 0) { e.Values["CampaignStatusID"] = null; } else { e.Values["CampaignStatusID"] = CampaignStatusDropDownList.SelectedValue; } if (Convert.ToInt32(CampaignTypeDropDownList.SelectedValue) == 0) { e.Values["CampaignTypeID"] = null; } else { e.Values["CampaignTypeID"] = CampaignTypeDropDownList.SelectedValue; } if (Convert.ToInt32(CurrencyDropDownList.SelectedValue) == 0) { e.Values["CurrencyID"] = null; } else { e.Values["CurrencyID"] = CurrencyDropDownList.SelectedValue; } if (Convert.ToInt32(AssignedUserDropDownList.SelectedValue) == 0) { e.Values["AssignedUserID"] = null; } else { e.Values["AssignedUserID"] = AssignedUserDropDownList.SelectedValue; } if (Convert.ToInt32(TeamDropDownList.SelectedValue) == 0) { e.Values["TeamID"] = null; } else { e.Values["TeamID"] = TeamDropDownList.SelectedValue; } e.Values["CreatedBy"] = userid; e.Values["CreatedTime"] = DateTime.Now; e.Values["ModifiedBy"] = userid; e.Values["ModifiedTime"] = DateTime.Now; }
protected void AccountDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["CreatedTime"] = DateTime.Now; e.Values["ModifiedTime"] = DateTime.Now; e.Values["CompanyID"] = Convert.ToInt32(Session["CompanyID"]); e.Values["CreatedBy"] = Convert.ToInt64(Session["UserID"]); }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { CatalogManager manager = new CatalogManager(); RequisitionItem item = new RequisitionItem(); item.StationeryID = Convert.ToInt32(((DropDownList)DetailsView1.FindControl("stDDL")).SelectedValue); item.QuantityRequested = Convert.ToInt32(((TextBox)DetailsView1.FindControl("stTextBox")).Text); item.QuantityIssued = 0; item.Price = 0; if (requisition.RequisitionItems.Count == 0) { requisition.RequisitionItems.Add(item); } else { foreach (var req in requisition.RequisitionItems) { if (item.StationeryID == req.StationeryID) { req.QuantityRequested += item.QuantityRequested; break; } else { requisition.RequisitionItems.Add(item); break; } } } GridDataBind(); }
/// <summary> /// Handles the ItemInserting event of dtlvCustomer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The DetailsViewInsertEventArgs.</param> protected void dtlvCustomer_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (this.IsValid) { try { Poco::ICustomer newCustomer = this.GetCustomerObject(); using (Bll::ICustomer blCustomer = new Bll::Customer()) { blCustomer.Create(newCustomer); } Response.Redirect("~/Customer.aspx"); // Go and show all data. } catch (SqlException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } }
protected void InsertItem(object sender, DetailsViewInsertEventArgs e) { TextBox question = (TextBox)DetailsView1.FindControl("NewPollQuestion"); Snitz.BLL.Polls.AddTopicPoll(-1, question.Text, new SortedList<int, string>()); Response.Redirect(Request.RawUrl); }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { DropDownList dlist = DetailsView1.FindControl("ddlDepartment") as DropDownList; TextBox txtName = DetailsView1.FindControl("txtLoginName") as TextBox; TextBox txtPwd = DetailsView1.FindControl("txtPassword") as TextBox; CheckBox chkSuper = DetailsView1.FindControl("chkSuperAdmin") as CheckBox; if (dlist == null || txtName == null || txtPwd == null || chkSuper == null) { Response.Write("出错,不能获取相关控件"); return; } int did=int.Parse(dlist.SelectedValue); AdminUserInfo a = new AdminUserInfo(); a.LoginName = txtName.Text; a.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPwd.Text, "SHA1"); a.DepartmentID = did; a.IsSuperAdmin = chkSuper.Checked; AdminUser.InsertAdminUser(a); this. ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功添加管理员信息')</script>"); DetailsView1.Visible = false; GridView1.DataBind(); e.Cancel = true; }
protected void DetailsView2_ItemInserting(object sender, DetailsViewInsertEventArgs e) { XmlDocument xdoc = XmlDataSource4.GetXmlDocument(); XmlElement FeedsList = xdoc.SelectSingleNode("/feeds") as XmlElement; XmlElement checkFeed = xdoc.SelectSingleNode("/feeds/feed[@name='" + e.Values["name"].ToString() + "']") as XmlElement; if (checkFeed == null) { XmlElement oFeed = xdoc.CreateElement("feed"); XmlAttribute name = xdoc.CreateAttribute("name"); XmlAttribute url = xdoc.CreateAttribute("url"); name.Value = e.Values["name"].ToString(); url.Value = e.Values["url"].ToString(); oFeed.Attributes.Append(name); oFeed.Attributes.Append(url); FeedsList.AppendChild(oFeed); XmlDataSource4.Save(); e.Cancel = true; } Response.Redirect(Request.RawUrl); }
protected void ExamDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (tol > (dur * 0.2)) { ShowMessageBox("Tolerance should be less than or equal to 20% of the duration."); ExamDetailsView.FindControl("txtTolerance").Focus(); e.Cancel = true; } }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { SqlDataSource1.InsertParameters["moduleCode"].DefaultValue = ((TextBox)DetailsView1.Rows[0].Cells[1].FindControl("TextBox1")).Text; SqlDataSource1.InsertParameters["name"].DefaultValue = ((TextBox)DetailsView1.Rows[1].Cells[1].FindControl("TextBox2")).Text; SqlDataSource1.InsertParameters["GPA"].DefaultValue = ((RadioButtonList)DetailsView1.Rows[2].Cells[1].FindControl("RadioButtonList3")).SelectedItem.Text; SqlDataSource1.InsertParameters["credits"].DefaultValue = ((TextBox)DetailsView1.Rows[3].Cells[1].FindControl("TextBox3")).Text; SqlDataSource1.InsertParameters["compulary"].DefaultValue = ((RadioButtonList)DetailsView1.Rows[4].Cells[1].FindControl("RadioButtonList4")).SelectedItem.Text; SqlDataSource1.Insert(); }
protected void LeadDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["LeadSourceID"] = leadSourcesDropDownList.SelectedValue; e.Values["FirstName"] = contactsDropDownList.SelectedItem; e.Values["AccountID"] = accountsDropDownList.SelectedValue; e.Values["TeamID"] = teamsDropDownList.SelectedValue; e.Values["AssignedUserID"] = assignedToUsersDropDownList.SelectedValue; e.Values["LeadStatusID"] = leadStatusesDropDownList.SelectedValue; }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { /* Control file = DetailsView1.FindControl("FileUpload1"); FileUpload fileUp; fileUp = ((FileUpload)file); fileUp.SaveAs(fileUp.FileName); */ }
protected void PollAnswerInsert_ItemInserting(object sender, DetailsViewInsertEventArgs e) { PollChoiceInfo choice = new PollChoiceInfo {PollId = Convert.ToInt32(Request.QueryString["pid"])}; TextBox text = (TextBox) PollAnswerInsert.FindControl("NewPollAnswerDisplayText"); TextBox order = (TextBox)PollAnswerInsert.FindControl("NewPollAnswerSortOrder"); choice.DisplayText = text.Text; choice.Order = Convert.ToInt32(order.Text); Snitz.BLL.Polls.AddChoice(choice); Response.Redirect(Request.RawUrl); }
protected void ContactDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["AccountID"] = AccountDropDownList.SelectedValue; e.Values["TeamID"] = TeamDropDownList.SelectedValue; e.Values["ReportsTo"] = ReportToDropDownList.SelectedValue; e.Values["AssignedTo"] = AssaigendToDropDownList.SelectedValue; e.Values["LeadSourcesID"] = LeadSourcesDropDownList.SelectedValue; e.Values["CreatedTime"] = DateTime.Now; e.Values["ModifiedTime"] = DateTime.Now; e.Values["CompanyID"] =7; }
protected void QuestionDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { ApplyFilter(); //question owner Question_SqlDataSource.InsertParameters["createdBy"].DefaultValue = HttpContext.Current.User.Identity.Name.ToString(); //question image file FileUpload fUpload = (FileUpload)QuestionDetailsView.Rows[0].FindControl("imageFileUpload"); String txtPath = "~/QuestionFiles/" + fUpload.FileName; Question_SqlDataSource.InsertParameters["questionFilePath"].DefaultValue = txtPath; LblError.Text = ""; }
protected void dvwConsumation_ItemInserting(object sender, DetailsViewInsertEventArgs e) { //if bought on is not empty, make sure it is converted to US date (workaround for a bug in control) if (e.Values["TastedOn"] != null) { e.Values["TastedOn"] = GUIHelper.GetUSDate(e.Values["TastedOn"].ToString()); } //set created on and created by e.Values["CreatedOn"] = DateTime.Now; e.Values["CreatedBy"] = Membership.GetUser().UserName; }
protected void DetailsView2_OnItemInserting(object sender, DetailsViewInsertEventArgs e) { FileUpload fu = (FileUpload)DetailsView2.FindControl("uploadFoto"); if (fu.PostedFile.ContentLength != 0) { string path = Server.MapPath(@"\Foto"); path += "\\Temp.jpg"; fu.PostedFile.SaveAs(path); } //ClientScript.RegisterStartupScript( }
protected void CampaignDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["CampaignStatusID"] = CampaignDropDownList.SelectedValue; e.Values["CampaignTypeID"] = CampaignTypeDropDownList.SelectedValue; e.Values["CurrencyID"] = CurrencyDropDownList.SelectedValue; e.Values["AssignedUserID"] = AssignedUserDropDownList.SelectedValue; e.Values["TeamID"] = TeamDropDownList.SelectedValue; e.Values["CreatedTime"] = DateTime.Now; e.Values["ModifiedTime"] = DateTime.Now; e.Values["CompanyID"] = 8; }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (e.Values["FileName"] != null) { string fileName = e.Values["FileName"].ToString(); string newFileName = string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(fileName), Guid.NewGuid().ToString().Substring(0, 5), Path.GetExtension(fileName)); e.Values["GameImage"] = newFileName; SaveLogoFile(newFileName); } }
protected void opportunityDetailsDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { e.Values["AccountID"] = accountDropDownList.SelectedValue; e.Values["OpportunityTypeID"] = opportunityTypeDropDownList1.SelectedValue; e.Values["LeadSourceID"] = leadSourceDropDownList2.SelectedValue; e.Values["TeamID"] = teamsDropDownList3.SelectedValue; e.Values["AssignedUserID"] = assignedToDropDownList4.SelectedValue; e.Values["CurrencyID"] = currencyDropDownList5.SelectedValue; e.Values["SalesStageID"] = salesStageDropDownList6.SelectedValue; e.Values["CampaignID"] = CampaignNameDropDownList7.SelectedValue; e.Values["CompanyID"] = companyID; }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { RequisitionItem item = new RequisitionItem(); item.StationeryID = Convert.ToInt32(((DropDownList)DetailsView1.FindControl("StationeryDDL")).SelectedValue); item.QuantityRequested = Convert.ToInt32(((TextBox)DetailsView1.FindControl("QuantityTextBox")).Text); item.QuantityIssued = 0; item.Price = 0; Debug.WriteLine(item.StationeryID); Debug.WriteLine(item.QuantityRequested); }
/// <summary> /// Execute this code before a task item is inserted /// Convert dates to us dates (otherwise it does not work due to a ms bug) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void dtvTask_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (e.Values["DueDate"] != null) { e.Values["DueDate"] = GUIHelper.GetUSDate(e.Values["DueDate"].ToString()); } //TODO: shouldn't this be added in BL? e.Values["CreatedOn"] = GUIHelper.GetUSDate(DateTime.Now.ToString()); //TODO: shouldn't this be added in BL? e.Values["CreatedBy"] = Membership.GetUser().UserName; }
protected void accountsDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { // Int32 companyid = Convert.ToInt32(HttpContext.Current.Session["CompanyID"]); e.Values["AccountTypesID"] = accountTypeDDL.SelectedValue; e.Values["AssignedUserID"] = usersDDL.SelectedValue; e.Values["TeamID"] = teamDDL.SelectedValue; e.Values["IndustryID"] = industryDDL.SelectedValue; e.Values["ParentID"] = memberOfDDL.SelectedValue; // e.Values["CompanyID"] =Session[""] .SelectedValue; e.Values["CreatedTime"] = DateTime.Now; e.Values["ModifiedTime"] = DateTime.Now; }
protected void dvBookTheme_ItemInserting( object sender, DetailsViewInsertEventArgs e ) { Controls_MLTextBox mltbThemeName = dvBookTheme.FindControl( "mltbThemeName" ) as Controls_MLTextBox; if( mltbThemeName != null ) { e.Values[ "Name" ] = mltbThemeName.MultilingualText; if( string.IsNullOrEmpty( mltbThemeName.MultilingualText.ToString() ) ) { e.Cancel = true; lblErrorDescription.Text = (string) this.GetLocalResourceObject( "NoThemeName" ); return; } } }
public void LeadDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e) { int companyid = Convert.ToInt32(HttpContext.Current.Session["CompanyID"]); long userid = Convert.ToInt32(HttpContext.Current.Session["UserID"]); long contactID = Convert.ToInt64(Session["ContactID"]); long accountID = Convert.ToInt64(Session["AccountID"]); string firstName = Convert.ToString(Session["ContactfirstName"]); string lastName = Convert.ToString(Session["ContactLastName"]); e.Values["FirstName"] = firstName; e.Values["LastName"] = lastName; if (Convert.ToInt32(leadSourcesDropDownList.SelectedValue) == -1) { e.Values["LeadSourceID"] = null; } else { e.Values["LeadSourceID"] = leadSourcesDropDownList.SelectedValue; } e.Values["ContactID"] = contactID; if (accountID != 0) { e.Values["AccountID"] = accountID; } if (Convert.ToInt32(teamsDropDownList.SelectedValue) == -1) { e.Values["TeamID"] = null; } else { e.Values["TeamID"] = teamsDropDownList.SelectedValue; } if (Convert.ToInt32(assignedToUsersDropDownList.SelectedValue) == -1) { e.Values["AssignedUserID"] = null; } else { e.Values["AssignedUserID"] = assignedToUsersDropDownList.SelectedValue; } if (Convert.ToInt32(leadStatusesDropDownList.SelectedValue) == -1) { e.Values["LeadStatusID"] = null; } else { e.Values["LeadStatusID"] = leadStatusesDropDownList.SelectedValue; } if (Convert.ToInt32(PrimaryCountryDropDownList.SelectedValue) == -1) { e.Values["PrimaryCountry"] = null; } else { e.Values["PrimaryCountry"] = PrimaryCountryDropDownList.SelectedValue; } if (Convert.ToInt32(AltCountryDropDownList.SelectedValue) == -1) { e.Values["AlternateCountry"] = null; } else { e.Values["AlternateCountry"] = AltCountryDropDownList.SelectedValue; } e.Values["CompanyID"] = companyid; e.Values["CreatedBy"] = userid; }
protected void DetailsView1_ItemInserting(object sender, System.Web.UI.WebControls.DetailsViewInsertEventArgs e) { Trace.Warn("DetailsView1_ItemInserting"); // L'utilisateur n'a pas fait de choix c'est la valeur de la checkbox if (( bool )e.Values["QuestionFin"] == false) { e.Values["QuestionFin"] = null; // c'est plus joli } if (( bool )e.Values["QuestionObligatoire"] == false) { e.Values["QuestionObligatoire"] = null; } if (e.Values["PollQuestionID"] == null) { e.Values["PollQuestionID"] = Guid.NewGuid(); } e.Values["QuestionnaireID "] = SessionState.Questionnaire.QuestionnaireID; if (e.Values["Societe"] == null) { e.Values["Societe"] = "Societe ?"; } if (e.Values["Rank"] == null) { e.Values["Rank"] = QuestionRankMax + 1; } if (e.Values["Instruction"] != null) { if (Instruction.Valide(e.Values["Instruction"].ToString()) == Instruction.Type.Null) { e.Values["Instruction"] = null; } } if (e.Values["CreationDate"] == null) { e.Values["CreationDate"] = DateTime.Now; } if (e.Values["MembreGUID"] == null) { e.Values["MembreGUID"] = ( Guid )Membership.GetUser().ProviderUserKey; } }
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { //List<CultureInfo> x = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.Name.ToLower().Contains("uk")).ToList(); if (e.Values["FileName"] != null) { string fileName = e.Values["FileName"].ToString(); string newFileName = string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(fileName), Guid.NewGuid().ToString().Substring(0, 5), Path.GetExtension(fileName)); e.Values["FileName"] = newFileName; SaveLogoFile(newFileName); } DropDownList cultures = this.DetailsView1.FindControl("ddlCountries") as DropDownList; string cultureInfoName = cultures.SelectedValue; e.Values["CultureInfoName"] = cultureInfoName; }
//student插入判断 //插入判断 protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { StudentManager stu = new StudentManager(); if (e.Values["username"] == null || e.Values["passwd"] == null || e.Values["name"] == null || e.Values["major"] == null) { System.Web.UI.ScriptManager.RegisterClientScriptBlock(UpdatePanel1,this.GetType(), "msg1", "alert('插入失败!user表中字段不能为空');", true); e.Cancel = true; return; } if (stu.GetStudent(e.Values["username"].ToString()) != null) { ScriptManager.RegisterClientScriptBlock (UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!user表中usrname字段已存在');", true); e.Cancel = true; return; } }
protected void DetailsView2_ItemInserting(object sender, DetailsViewInsertEventArgs e) { try { SqlDataSource6.InsertParameters["semesterID"].DefaultValue = GridView1.SelectedValue.ToString(); SqlDataSource6.InsertParameters["moduleCode"].DefaultValue = ((DropDownList)DetailsView2.Rows[1].Cells[1].FindControl("DropDownList6")).SelectedValue; SqlDataSource6.InsertParameters["lecturerName"].DefaultValue = ((TextBox)DetailsView2.Rows[2].Cells[1].FindControl("TextBox1")).Text; SqlDataSource6.Insert(); Session["selectedSemester"] = GridView1.SelectedValue; } catch (Exception er) { ClientScript.RegisterStartupScript(this.GetType(),"", "alert('Select a semester!')", true); } }
/* protected void SelectareProdus(object sender, EventArgs e) { string denumire; string imagine; int idProdus=(int) this.ProduseGrid.SelectedDataKey.Value; SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Produse"].ConnectionString); connection.Open(); SqlCommand command = new SqlCommand(); string commandString = @"SELECT * from produse WHERE produs_id = @id"; command.CommandText = commandString; command.Connection = connection; command.Parameters.AddWithValue("@id", idProdus); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { denumire = dataReader["denumire"].ToString(); } connection.Close(); DataTable tabelProdus = new DataTable(); tabelProdus.Columns.Add("denumire"); //tabelProdus.Columns.Add("denumire"); //tabelProdus.Columns.Add("denumire"); //tabelProdus.Columns.Add("denumire"); DataRow produsPentruDetailsView = tabelProdus.NewRow(); //produsPentruDetailsView["denumire"] =; // produsPentruDetailsView["pret"] =; //tabelProdus.Rows.Add(produsPentruDetailsView); ProdusDetailsView.DataSource = tabelProdus; //DetailsView1.DataBind(); }*/ protected void InsertProdus(object sender, DetailsViewInsertEventArgs e) { SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Produse"].ConnectionString); conn.Open(); string sqlCmd = "INSERT INTO produse(denumire, categorie_id, pret, moneda_id, oferta ) VALUES(@denumire, @categorie, @pret, @moneda, @oferta)"; SqlCommand cmd = new SqlCommand(sqlCmd, conn); cmd.Parameters.AddWithValue("@denumire", e.Values["denumire"]); cmd.Parameters.AddWithValue("@categorie", e.Values["categorie_id"]); cmd.Parameters.AddWithValue("@pret", e.Values["pret"]); cmd.Parameters.AddWithValue("@moneda", e.Values["moneda_id"]); cmd.Parameters.AddWithValue("@oferta", Convert.ToInt32(e.Values["Oferta"])); cmd.ExecuteNonQuery(); conn.Close(); this.ProduseGrid.DataBind(); }
//INSERT novog zaposlenog protected void DetailsViewZaposleniDetalji_ItemInserting(object sender, DetailsViewInsertEventArgs e) { //izvlacenje ID-a sektora DropDownList lista = (DropDownList)DetailsViewZaposleniDetalji.FindControl("ddlSektor"); int sektorID = Convert.ToInt32(lista.SelectedValue); //Izvlacenje kontrola iz DeatailsViewZaposleniDetalji kontrole TextBox txtImePrezime = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtImePrezime"); TextBox txtAdresa = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtAdresa"); TextBox txtEmail = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtEmail"); TextBox txtBrojTelefona = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtBrojTelefona"); TextBox txtKorisnickoIme = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtKorisnickoIme"); TextBox txtSifra = (TextBox)DetailsViewZaposleniDetalji.FindControl("txtSifra"); CheckBox cbAktivan = (CheckBox)DetailsViewZaposleniDetalji.FindControl("cbAktivan"); //Parametri Dictionary<string, string> parametri = new Dictionary<string, string>(); parametri.Add("@ZaposleniID", ID.ToString()); parametri.Add("@SektorID", sektorID.ToString()); parametri.Add("@ImePrezime", txtImePrezime.Text); parametri.Add("@Adresa", txtAdresa.Text); parametri.Add("@Email", txtEmail.Text); parametri.Add("@BrojTelefona", txtBrojTelefona.Text); parametri.Add("@KorisnickoIme", txtKorisnickoIme.Text); parametri.Add("@Sifra", txtSifra.Text); parametri.Add("@Aktivan", cbAktivan.Checked.ToString()); bool rezultat = RadSaBazom.InsertUpdateDeleteSaParametrima("INSERT INTO Zaposleni VALUES(@SektorID, " + "@ImePrezime, @Adresa, @Email, @BrojTelefona, @KorisnickoIme, @Sifra, @Aktivan)", parametri); ///////////////////////////////////////////////////////////////////////////////////////// if (rezultat == false) { Response.Redirect("./Greska.aspx"); } //////////////////////////////////////////////////////////////////////////////////////// // Finisiranje INSERT komande Response.Redirect("./Zaposleni.aspx"); }
protected virtual new void OnItemInserting(DetailsViewInsertEventArgs e) { }
protected void dlStudentTravelEvents_ItemInserting(object sender, System.Web.UI.WebControls.DetailsViewInsertEventArgs e) { // Variable to accumulate the errors before displaying them string strMensajeError = ""; e.Cancel = false; // Takes the TextBox value and assign it to local variable //TextBox strMCode = (TextBox)dvEventDetails.FindControl("txtEventID"); DropDownList strEname = (DropDownList)dvStudentTravelEvent.FindControl("ddlEventID"); DropDownList strSname = (DropDownList)dvStudentTravelEvent.FindControl("ddlStudentID"); TextBox strExpenseAmount = (TextBox)dvStudentTravelEvent.FindControl("txtExpenseAmount"); TextBox strExpenseStatus = (TextBox)dvStudentTravelEvent.FindControl("txtExpenseStatus"); // Validate before insert // Validate - Missing Medicine code //if (strMCode.Text == null || strMCode.Text == "") //{ // strMensajeError += "Missing Medicine Code."; // e.Cancel = true; //} if (strSname.Text == null || strSname.Text == "" || strSname.Text == "0000") { strMensajeError += "Missing Event Name."; e.Cancel = true; } if (strExpenseAmount.Text == null || strExpenseAmount.Text == "") { strMensajeError += "Missing Expense Amount."; e.Cancel = true; } if (strEname.Text == null || strEname.Text == "" || strEname.Text == "0000") { strMensajeError += "Missing Event Name."; e.Cancel = true; } //// Validate - Medicine code length //if (strMCode.Text.Length != 5) //{ // strMensajeError += "Medicine Code shoud be 5 characters long"; // e.Cancel = true; //} // Validate - Medicine code length //string StartDate = strSDate.ToString(); //string EndDate = strEDate.ToString(); //DateTime parsedDate = DateTime.Parse(StartDate); //DateTime parsedDate1 = DateTime.Parse(StartDate); //if //{ // strMensajeError += "Medicine Code shoud be 5 characters long"; // e.Cancel = true; //} // If prevoius validation throws an error, return the error if (e.Cancel == true) { lblMessage.Text = "Insert Error! <br />" + strMensajeError.ToString() + "</div>"; StrssMessage = "Insert Error! <br />" + strMensajeError.ToString() + "</div>"; } else { // Assign values to columns before table insert considering // this data will NOT be available to input on the detail form // Record Status is A for new records e.Values["RECORD_STATUS"] = "A"; e.Values["Expense_Status"] = "P"; DateTime date = DateTime.Now; string ssUserName = Session["ssUsr"].ToString(); ((TextBox)dvStudentTravelEvent.FindControl("txtcreationdate")).Text = date.ToString(); ((TextBox)dvStudentTravelEvent.FindControl("txtcreatedby")).Text = ssUserName.ToString(); ((TextBox)dvStudentTravelEvent.FindControl("txtUpdatedby")).Text = ssUserName.ToString(); ((TextBox)dvStudentTravelEvent.FindControl("txtUpdatedate")).Text = date.ToString(); //// Establecer la informacion de la conexion //SqlConnection conn_string = new //SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connctrionstringdbUMTExpenses"].ConnectionString); //// Establecer el comando de SQL que se va a ejecutar //SqlCommand sql_comm = new SqlCommand("UPDATE UTM.Student SET Total_Amount_Received = sum(StudentTravelEvent.ExpenseAmount FROM UTM.Student INNER JOIN UTM.StudentTravelEvent ON UTM.Student.StudentID = UTM.StudentTravelEvent.StudentID WHERE(UTM.Student.StudentID = @StudentID)) ; ", conn_string); //// Asignar valor a los parametros //sql_comm.Parameters.AddWithValue("@EventID", strSname); //// Abrir la conexion //conn_string.Open(); //// Cerrar la conexion //conn_string.Close(); } }
// Mettre une valeur a Null c'est l'effacer protected void DetailsView1_ItemInserting(object sender, System.Web.UI.WebControls.DetailsViewInsertEventArgs e) { Trace.Warn("DetailsView1_ItemInserting"); // L'utilisateur n'a pas fait de choix ... false est la valeur de la checkbox par defaut il n'y a pas de null pour un bool ! if (( bool )e.Values["QuestionFin"] == false) { e.Values["QuestionFin"] = null; // c'est plus joli } if (( bool )e.Values["QuestionObligatoire"] == false) { e.Values["QuestionObligatoire"] = null; } if (( bool )e.Values["ChoixMultiple"] == false) { e.Values["ChoixMultiple"] = null; } int choixMin = 0; // BUG19062010 int choixMax = 0; try { choixMin = int.Parse(e.Values["ChoixMultipleMin"].ToString()); } catch { e.Values["ChoixMultipleMin"] = null; } try { choixMax = int.Parse(e.Values["ChoixMultipleMax"].ToString()); } catch { e.Values["ChoixMultipleMax"] = null; } if ((choixMin > choixMax) || (choixMin < 0) || (choixMax < 0)) { e.Values["ChoixMultipleMin"] = null; e.Values["ChoixMultipleMax"] = null; ValidationMessage.Text = "Erreur : Choix Min est supérieur à Choix Max"; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; ValidationMessage.Visible = true; } if (( bool )e.Values["MessageHaut"] == false) { e.Values["MessageHaut"] = null; } if (e.Values["PollQuestionID"] == null) { e.Values["PollQuestionID"] = Guid.NewGuid(); } e.Values["QuestionnaireID "] = SessionState.Questionnaire.QuestionnaireID; if (e.Values["Societe"] == null) { e.Values["Societe"] = "Societe ?"; } if (e.Values["Rank"] == null) { e.Values["Rank"] = QuestionRankMax + 1; } if (e.Values["Instruction"] != null) { if (Instruction.Valide(e.Values["Instruction"].ToString()) == Instruction.Type.Null) { e.Values["Instruction"] = null; } } if (e.Values["CreationDate"] == null) { e.Values["CreationDate"] = DateTime.Now; } if (e.Values["MembreGUID"] == null) { e.Values["MembreGUID"] = ( Guid )Membership.GetUser().ProviderUserKey; } }
protected void DetailsView1_ItemInserting(object sender, System.Web.UI.WebControls.DetailsViewInsertEventArgs e) { Trace.Warn("DetailsView1_ItemInserting"); if (e.Values["PollQuestionId"] == null) { e.Values["PollQuestionId"] = PollQuestionGUID; } if (e.Values["PollAnswerId"] == null) { e.Values["PollAnswerId"] = Guid.NewGuid(); } // Recuperer la valeur de DropDownListTypeReponse DropDownList ddlTypeReponse = ( DropDownList )DetailsView1.Rows[columnDropDownListTypeReponse].FindControl("DropDownListTypeReponse"); string valeur = ddlTypeReponse.SelectedItem.Text; e.Values["TypeReponse"] = valeur; if (TypeReponse.EstTextuelle((string)e.Values["TypeReponse"]) == false) { if (e.Values["Width"] != null) { e.Values["Width"] = null; ValidationMessage.Text += "La largeur ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } if (e.Values["Rows"] != null) { e.Values["Rows"] = null; ValidationMessage.Text += "Le nombre de lignes ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } if (( bool )e.Values["Obligatoire"] == true) { e.Values["Obligatoire"] = null; ValidationMessage.Text += "Obligatoire ici ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } else { if (e.Values["Width"] != null) { try { int i = int.Parse(e.Values["Width"].ToString()); if (i < int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMin)) { e.Values["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMin; } if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMax)) { e.Values["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMax; } } catch { e.Values["Width"] = null; ValidationMessage.Text += "Largeur est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } if (e.Values["Rows"] != null) { try { int i = int.Parse(e.Values["Rows"].ToString()); if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLigneMax)) { e.Values["Rows"] = Global.SettingsXml.ReponseTextuelleLigneMax; } } catch { e.Values["Rows"] = null; ValidationMessage.Text += "Lignes est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } } // BUG20100407 // Faire comme dans ButtonReponseTextuelleOk_Click if (e.Values["Answer"] == null && TypeReponse.EstTextuelle(( string )e.Values["TypeReponse"])) { e.Values["Answer"] = " "; // reponse textuelle vide } // Si elle est encore nulle c'est qu'elle n'est pas textuelle alors on met une chaine "Réponse ?" if (e.Values["Answer"] == null) { e.Values["Answer"] = "Réponse ?"; } //if ( string.IsNullOrEmpty( e.Values[ "Answer" ].ToString() ) ) //{ // e.Values[ "Answer" ] = "Réponse ?"; //} if (e.Values["Rank"] == null) { e.Values["Rank"] = ReponseRankMax + 1; } else { try { int i = int.Parse(e.Values["Rank"].ToString()); } catch { ValidationMessage.Text += "Rang est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = ReponseRankMax + 1; } } if (e.Values["Score"] != null) { try { int i = int.Parse(e.Values["Score"].ToString()); if (i <= 0) { ValidationMessage.Text += "Score est un entier positif<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = null; } } catch { ValidationMessage.Text += "Score est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = null; } } if (e.Values["Obligatoire"] != null) { if (( bool )e.Values["Obligatoire"] == false) { e.Values["Obligatoire"] = null; // effacer } } }
protected virtual new void OnItemInserting(DetailsViewInsertEventArgs e) { Contract.Requires(e != null); }