예제 #1
0
    protected void Updade_Click(object sender, EventArgs e)
    {
        TimeOfDay _st = null;
        foreach (GridViewRow I in gv_Themes.Rows)
        {
            Label _id = (Label)I.FindControl("lbl_Id");
            if (_id != null)
            {

                TextBox _sort = (TextBox)I.FindControl("txt_Sort");
                if (Regex.IsMatch(_sort.Text, @"\d+", RegexOptions.IgnoreCase))
                {
                    _st = new TimeOfDay(this.ConnectionString);
                    _st.LitePopulate(_id.Text, false);
                    _st.Sort = Convert.ToInt32(_sort.Text);
                    _st.Save();
                }

            }
        }
        BindData();
    }
예제 #2
0
    protected void Save_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            TimeOfDay _time = new TimeOfDay(this.ConnectionString);
            if (ViewState["Id"] != null)
            {
                _time.LitePopulate(ViewState["Id"], false);
            }

            _time.Description = txt_Desc.Text;
            _time.Status = Convert.ToInt32(dd_Status.SelectedValue);

            String _imgType = "";
            if (fu_File.HasFile)
            {
                _imgType = fu_File.FileName.Split('.')[1];
                _time.ImgType = _imgType;
            }
            if (_time.Save())
            {
                if (fu_File.HasFile)
                {
                    String _path = Server.MapPath(String.Format(ConfigurationManager.AppSettings["TimeOfDayImagesPath"], _time.ID.ToString(), _imgType));
                    fu_File.SaveAs(_path);
                }
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'Timeofdays.aspx';", true);
                PortalCacheFactory.RefreshTimeOfDay();
            }
            else
            {
                lbl_Error.Text = "An unexpected error has occurred. Please try again.";
                lbl_Error.Visible = true;
            }
        }
    }