Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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();
            }
        }
        /// <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;
            }
        }
Exemplo n.º 4
0
 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;
         }
     }
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var employeeId = Request.Params["Id"];

            if (employeeId == null)
            {
                Response.Redirect("Employees.aspx");
            }

            int parsedId = int.Parse(employeeId);

            NorthwindEntities context = new NorthwindEntities();
            var employee = new List <Employee>()
            {
                context.Employees.FirstOrDefault(x => x.EmployeeID == parsedId)
            };

            EmployeeDetailsView.DataSource = employee;
            EmployeeDetailsView.DataBind();

            EmployeeFormView.DataSource = employee;
            EmployeeFormView.DataBind();
        }
Exemplo n.º 7
0
        protected void AddFavoritesClicked(object sender, ImageClickEventArgs e)
        {
            var currentUserGuid = new Guid(Session["CurrentUser"].ToString());

            string[] commandArguents  = ((ImageButton)sender).CommandArgument.Split(';');
            bool     isFavorite       = bool.Parse(commandArguents[1]);
            var      favoriteUserGuid = new Guid(commandArguents[0]);

            SqlConnection connection  = DBHelper.GetConnection();
            string        commandText = isFavorite ? "RemoveFavorites" : "AddFavorites";
            var           cmd         = new SqlCommand(commandText, connection)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.Add("@ParentUserGuid", SqlDbType.UniqueIdentifier);
            cmd.Parameters["@ParentUserGuid"].Value = currentUserGuid;
            cmd.Parameters.Add("@FavoriteUserGuid", SqlDbType.UniqueIdentifier);
            cmd.Parameters["@FavoriteUserGuid"].Value = favoriteUserGuid;
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                EmployeeFormView.DataBind();
                //string popupScript = "<script language='javascript'>" +"showSuccessToast();" +"</script>";
                //Page.ClientScript.RegisterStartupScript(typeof(Page), "popupScript", popupScript);
            }
            catch (Exception ex)
            {
                ShellLogger.WriteLog("DB.log", "Ошибка добаления сотрудника в избранное", ex);
            }
            finally
            {
                connection.Close();
            }
        }
 /// <summary>
 /// Handles the SelectedIndexChanged event of the GridView
 /// Use it to change the mode of the Employee Details FormView to the ReadOnly mode.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void EmployeesGridView_SelectedIndexChanged(object sender, EventArgs e)
 {
     EmployeeFormView.ChangeMode(FormViewMode.ReadOnly);
 }
Exemplo n.º 9
0
        protected void DivisionDropDownList_OnSelectedIndexChanged3(object sender, EventArgs e)
        {
            var ddlist = (DropDownList)EmployeeFormView.FindControl("RegionList3");

            ddlist.DataBind();
        }