Пример #1
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();
            }
        }
Пример #2
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();
        }
Пример #3
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();
            }
        }