protected void AddNewSelfPhone(object sender, EventArgs e) { var PhoneTypeDDL = (DropDownList)EmployeeFormView.FindControl("DropDownList2"); var regionList2 = (DropDownList)EmployeeFormView.FindControl("RegionList3"); var SpecificStaffDDL = (DropDownList)EmployeeFormView.FindControl("SpecificStaffDDL"); var txtContactName = (TextBox)EmployeeFormView.FindControl("TextBox1"); var locationId = new Guid(regionList2.SelectedValue); var phoneTypeId = new Guid(PhoneTypeDDL.SelectedValue); var specificStaffId = new Guid(SpecificStaffDDL.SelectedValue); string phone = txtContactName.Text; string commandText = "insert into SpecificStaffPlace(Id,SpecificStaffId,LocationId,PhoneTypeId,PhoneNumber) values ('" + Guid.NewGuid() + "','" + specificStaffId + "','" + locationId + "','" + phoneTypeId + "','" + phone + "')"; SqlConnection connection = DBHelper.GetConnection(); var cmd = new SqlCommand(commandText, connection) { CommandType = CommandType.Text }; try { connection.Open(); cmd.ExecuteNonQuery(); EmployeeFormView.DataBind(); } catch (Exception ex) { ShellLogger.WriteLog("DB.log", "Ошибка добавления стационарного номера", ex); } finally { connection.Close(); } }
protected void UpdateSelfPhone(object sender, GridViewUpdateEventArgs e) { var GridView1 = (GridView)EmployeeFormView.FindControl("GridView2"); var SpecificStaffPlaceId = (Guid)e.Keys[0]; string currentPhoneNumber = ((TextBox)GridView1.Rows[e.RowIndex] .FindControl("txtCompanyName1")).Text; string currentPhoneType = ((DropDownList)GridView1.Rows[e.RowIndex] .FindControl("PhoneTypeDropDownList5")).SelectedValue; string commandText = "update SpecificStaffPlace set PhoneTypeId='" + currentPhoneType + "',PhoneNumber='" + currentPhoneNumber + "' where Id='" + SpecificStaffPlaceId + "'"; SqlConnection connection = DBHelper.GetConnection(); var cmd = new SqlCommand(commandText, connection) { CommandType = CommandType.Text }; try { connection.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { ShellLogger.WriteLog("DB.log", "Ошибка обновления стационарного номера", ex); } finally { connection.Close(); } }
/// <summary> /// Gets the bytes uploaded by the FileUpload control and set them to the Photo property of the /// passed in Employee entity. /// </summary> /// <param name="entity"> entity envolved in the Insert or Update action</param> private void SetPicture(IEntityCore entity) { FileUpload fileUpload = (FileUpload)EmployeeFormView.FindControl("FileUpload1"); if (fileUpload.PostedFile != null && !string.IsNullOrEmpty(fileUpload.PostedFile.FileName) && fileUpload.PostedFile.InputStream != null) { ((EmployeeEntity)entity).Photo = fileUpload.FileBytes; } }
protected void EmployeeFormView_ItemCreated(object sender, EventArgs e) { //EmployeeFormView.FindControl("Edit").Visible = false; if (!DBHelper.CheckIfUserIsAdministrator(new Guid(Session["CurrentUser"].ToString()))) { if (EmployeeFormView.CurrentMode == FormViewMode.ReadOnly) { EmployeeFormView.FindControl("Edit").Visible = false; } } }
protected void UpdatePhone(object sender, GridViewUpdateEventArgs e) { var GridView1 = (GridView)EmployeeFormView.FindControl("UserPhonesGridView"); var EmployeePlaceId = (Guid)e.Keys[0]; string currentStreet = ((TextBox)GridView1.Rows[e.RowIndex] .FindControl("StreetTextBox")).Text; string currentEdifice = ((TextBox)GridView1.Rows[e.RowIndex] .FindControl("EdificeTextBox")).Text; string currentRegion = ((DropDownList)GridView1.Rows[e.RowIndex] .FindControl("RegionList")).SelectedValue; string phone = ((TextBox)GridView1.Rows[e.RowIndex] .FindControl("txtCompanyName1")).Text; string phoneType = ((DropDownList)GridView1.Rows[e.RowIndex] .FindControl("PhoneTypeDropDownList")).SelectedValue; UpdateEmployeeAddress(EmployeePlaceId, new Guid(currentRegion), currentStreet, currentEdifice, phone, new Guid(phoneType)); }
protected void DivisionDropDownList_OnSelectedIndexChanged3(object sender, EventArgs e) { var ddlist = (DropDownList)EmployeeFormView.FindControl("RegionList3"); ddlist.DataBind(); }