Esempio n. 1
0
        public ActionResult Edit(MediaGroupsEditModel model)
        {
            if (ModelState.IsValid)
            {
                short sysMessageId     = 0;
                byte  sysMessageTypeId = 0;
                model.SystemStatus = SystemStatus.Error;
                var mediaGroup = new MediaGroups
                {
                    SiteId         = model.SiteId,
                    MediaGroupId   = model.MediaGroupId,
                    MediaGroupName = model.MediaGroupName,
                    MediaGroupDesc = model.MediaGroupDesc,
                    ParentGroupId  = model.ParentGroupId,
                    CrUserId       = model.CrUserId,
                    CrDateTime     = model.CrDateTime
                };
                sysMessageTypeId = model.MediaGroupId > 0 ? mediaGroup.Update(0, _userId, ref sysMessageId) : mediaGroup.Insert(0, _userId, ref sysMessageId);

                if (sysMessageId > 0)
                {
                    var sysMessage = new SystemMessages().Get(sysMessageId);
                    if (sysMessageTypeId == CmsConstants.SystemMessageIdSuccess)
                    {
                        model.SystemStatus = SystemStatus.Success;
                    }
                    ModelState.AddModelError("SystemMessages", sysMessage.SystemMessageDesc);
                }
                else
                {
                    ModelState.AddModelError("SystemMessages", "Bạn vui lòng thử lại sau.");
                }
            }
            return(View(model));
        }
Esempio n. 2
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        byte SysMessageTypeId = 0;
        int  SysMessageId     = 0;

        System.Int16 EditId;
        MediaGroups  m_MediaGroups = new MediaGroups();

        if (Request.QueryString["id"] == null)
        {
            EditId = 0;
        }
        else
        {
            EditId = System.Int16.Parse(Request.QueryString["id"].ToString());
            m_MediaGroups.MediaGroupId = EditId;
            m_MediaGroups = m_MediaGroups.Get();
        }
        try
        {
            m_MediaGroups.CrUserId = ActUserId;

            if (txMediaGroupName.Text != "")
            {
                m_MediaGroups.MediaGroupName = txMediaGroupName.Text;
            }

            if (txMediaGroupDesc.Text != "")
            {
                m_MediaGroups.MediaGroupDesc = txMediaGroupDesc.Text;
            }

            m_MediaGroups.ParentGroupId = short.Parse(txParentGroupId.Text);

            m_MediaGroups.MediaGroupId = EditId;
            SysMessageTypeId           = m_MediaGroups.InsertOrUpdate(ConstantHelpers.Replicated, ActUserId, ref SysMessageId);

            StringBuilder       csText = new StringBuilder();
            Type                cstype = this.GetType();
            ClientScriptManager cs     = Page.ClientScript;
            csText.Clear();
            csText.Append("<script type=\"text/javascript\">");
            csText.Append("window.parent.jQuery('#divEdit').dialog('close');");
            csText.Append("</script>");
            cs = Page.ClientScript;
            cs.RegisterClientScriptBlock(this.GetType(), "system_message", csText.ToString());
        }
        catch (Exception ex)
        {
            sms.utils.LogFiles.LogError(((new System.Diagnostics.StackTrace()).GetFrames()[0]).GetMethod().Name + "\t" + ex.ToString());
            JSAlertHelpers.Alert(ex.Message, this);
        }
    }
Esempio n. 3
0
    protected void m_grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string message = "";

        try
        {
            MediaGroups m_MediaGroups = new MediaGroups();
            m_MediaGroups.MediaGroupId = System.Int16.Parse(m_grid.DataKeys[e.RowIndex].Value.ToString());
            m_MediaGroups.Delete();
        }
        catch (Exception ex)
        {
            sms.utils.Log.writeLog(ex.ToString(), ((new System.Diagnostics.StackTrace()).GetFrames()[0]).GetMethod().Name);
        }
        ShowGrid();
    }
Esempio n. 4
0
 public ActionResult Delete(short mediaGroupId = 0)
 {
     if (mediaGroupId > 0)
     {
         short sysMessageId = 0;
         var   mediaGroup = new MediaGroups {
             MediaGroupId = mediaGroupId
         }.Get();
         if (mediaGroup.MediaGroupId > 0)
         {
             new MediaGroups {
                 MediaGroupId = mediaGroupId
             }.Delete(0, 0, ref sysMessageId);
         }
     }
     return(Redirect("/MediaGroups/Index"));
 }
Esempio n. 5
0
 private void bindData()
 {
     System.Int16 EditId;
     if (Request.QueryString["id"] == null)
     {
         return;
     }
     else
     {
         EditId = System.Int16.Parse(Request.QueryString["id"].ToString());
         MediaGroups m_MediaGroups = new MediaGroups();
         m_MediaGroups.MediaGroupId = EditId;
         m_MediaGroups         = m_MediaGroups.Get();
         txMediaGroupName.Text = m_MediaGroups.MediaGroupName.ToString();
         txMediaGroupDesc.Text = m_MediaGroups.MediaGroupDesc.ToString();
         txParentGroupId.Text  = m_MediaGroups.ParentGroupId.ToString();
         txCrUserId.Text       = m_MediaGroups.CrUserId.ToString();
     }
 }
Esempio n. 6
0
        public ActionResult Edit(short mediaGroupId = 0)
        {
            var model = new MediaGroupsEditModel();

            if (mediaGroupId > 0)
            {
                var mediaGroup = new MediaGroups().Get(mediaGroupId);
                if (mediaGroup.MediaGroupId > 0)
                {
                    model.SiteId         = mediaGroup.SiteId;
                    model.MediaGroupId   = mediaGroup.MediaGroupId;
                    model.MediaGroupName = mediaGroup.MediaGroupName;
                    model.MediaGroupDesc = mediaGroup.MediaGroupDesc;
                    model.ParentGroupId  = mediaGroup.ParentGroupId;
                    model.CrUserId       = mediaGroup.CrUserId;
                    model.CrDateTime     = mediaGroup.CrDateTime;
                }
            }
            return(View(model));
        }
Esempio n. 7
0
    //--------------------------------------------------------------------------------

    private void ShowGrid()
    {
        try
        {
            MediaGroups m_MediaGroups = new MediaGroups();
            m_MediaGroups.MediaGroupName = txtSearch.Text;
            string             DateFrom      = txtDateFrom.Text;
            string             DateTo        = txtDateTo.Text;
            int                RowCount      = 0;
            List <MediaGroups> l_MediaGroups = m_MediaGroups.GetPage("", "", ddlOrderBy.SelectedValue, m_grid.PageSize, CustomPaging.PageIndex - 1, ref RowCount);

            m_grid.DataSource = l_MediaGroups;
            m_grid.DataBind();
            lblTong.Text           = RowCount.ToString();
            CustomPaging.TotalPage = (RowCount == 0) ? 1 : (RowCount % m_grid.PageSize == 0) ? RowCount / m_grid.PageSize : (RowCount - RowCount % m_grid.PageSize) / m_grid.PageSize + 1;
        }
        catch (Exception ex)
        {
            sms.utils.Log.writeLog(ex.ToString(), ((new System.Diagnostics.StackTrace()).GetFrames()[0]).GetMethod().Name);
        }
    }
Esempio n. 8
0
 protected void lbDelete_Click(object sender, EventArgs e)
 {
     try
     {
         MediaGroups m_MediaGroups = new MediaGroups();
         foreach (GridViewRow m_Row in m_grid.Rows)
         {
             CheckBox chkAction = (CheckBox)m_Row.FindControl("chkAction");
             if (chkAction != null)
             {
                 if (chkAction.Checked)
                 {
                     m_MediaGroups.MediaGroupId = System.Int16.Parse(m_grid.DataKeys[m_Row.RowIndex].Value.ToString());
                     m_MediaGroups.Delete();
                 }
             }
         }
         ShowGrid();
     }
     catch (Exception ex)
     {
         sms.utils.Log.writeLog(ex.ToString(), ((new System.Diagnostics.StackTrace()).GetFrames()[0]).GetMethod().Name);
     }
 }