Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Kiểm tra Login hay chưa
            //if (String.IsNullOrWhiteSpace(Page.User.Identity.Name)) return;
            if (String.IsNullOrWhiteSpace(this.Page.User.Identity.Name))
            {
                return;
            }

            //Kiểm tra nếu Login và có quyền được duyệt, xóa comment thì sẽ được thực hiện

            if (Request.QueryString["Id"] != null && Request.QueryString["action"] != null && Request.QueryString["action"].ToString().ToLower().Equals("delete"))
            {
                ID = Request.QueryString["Id"];
                SupportOnline_Helper.DeleteSupportOnline(ID);
                return;
            }

            if (Request.QueryString["Id"] != null && Request.QueryString["post"] == null)
            {
                ID = Request.QueryString["Id"];

                btnSave.OnClientClick   = String.Format("Save({0}, {1})", ID, "false");
                btnDelete.OnClientClick = String.Format("return Delete({0})", ID);

                var cmdItem = SupportOnline_Helper.SelectOneSupportOnline(ID);
                if (cmdItem != null && cmdItem.Rows.Count > 0)
                {
                    txtName.Text      = cmdItem.Rows[0]["FullName"].ToString();
                    txtYahoo.Text     = cmdItem.Rows[0]["Yahoo"].ToString();
                    txtSkype.Text     = cmdItem.Rows[0]["Skype"].ToString();
                    txtSTT.Text       = cmdItem.Rows[0]["STT"].ToString();
                    txtMobile.Text    = cmdItem.Rows[0]["Mobile"].ToString();
                    txtGroupName.Text = cmdItem.Rows[0]["GroupName"].ToString();
                }
                return;
            }

            if (Request.Form.Count > 0)
            {
                int Id = Convert.ToInt32(Request.QueryString["Id"]);
                //int stt=0;
                //try
                //{
                //    stt = int.Parse(Request.Form["txtSTT"]);
                //}
                //catch (Exception)
                //{
                //}
                if (Id != 0)
                {
                    SupportOnline_Helper.UpdateSupportOnline(Id, Request.Form["txtName"], Request.Form["txtYahoo"], Request.Form["txtSkype"], Request.Form["txtMobile"], Request.Form["txtGroupName"], Convert.ToInt32(Request.Form["txtSTT"]));
                }
                else
                {
                    SupportOnline_Helper.InsertSupportOnline(Request.Form["txtName"], Request.Form["txtYahoo"], Request.Form["txtSkype"], Request.Form["txtMobile"], Request.Form["txtGroupName"], Convert.ToInt32(Request.Form["txtSTT"]));
                }
            }
        }
Ejemplo n.º 2
0
        protected void grvCategories_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "AddNew")
            {
                GridViewRow editRow = grdListSupport.FooterRow;

                SupportOnline_Helper.InsertSupportOnline((editRow.FindControl("txt_NewFullName") as HtmlInputText).Value,
                                                         (editRow.FindControl("txt_NewYahoo") as HtmlInputText).Value,
                                                         (editRow.FindControl("txt_NewSkype") as HtmlInputText).Value,
                                                         (editRow.FindControl("txt_NewMobile") as HtmlInputText).Value, "", 1);

                grdListSupport.ShowFooter = false;
                BindData();
            }
        }