Esempio n. 1
0
        //插入一条记录
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            //创建一个Model
            Model.CMS_FriendLink mfl = new Model.CMS_FriendLink();
            if (lbIns.Text == "编辑")
            {
                mfl.Id = Id;
            }
            mfl.IsPic   = false;
            mfl.Title   = tbTitle.Text;
            mfl.Sort    = Convert.ToInt32(tbSort.Text);
            mfl.SiteUrl = tbSiteUrl.Text;

            //插入记录
            Maticsoft.BLL.CMS_FriendLink bfl = new Maticsoft.BLL.CMS_FriendLink();

            //分情况讨论
            if (lbIns.Text == "添加")
            {
                bfl.Add(mfl);
            }
            else if (lbIns.Text == "编辑")
            {
                bfl.Update(mfl);
            }
            btAbandon_Click(sender, e);
            btAbandon.Visible = false;

            Flush();
        }
Esempio n. 2
0
        //更新一条记录
        protected void GVinfo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    theRow = 0;  //保存行号
            string theCol = ""; //保存列位置信息

            theRow = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            theCol = e.CommandName.ToString();
            Id     = Convert.ToInt32(GVinfo.DataKeys[theRow].Value);
            Maticsoft.Model.CMS_FriendLink mfl = new Maticsoft.Model.CMS_FriendLink();
            Maticsoft.BLL.CMS_FriendLink   bfl = new Maticsoft.BLL.CMS_FriendLink();

            switch (e.CommandName)
            {
            case "MyEdit":
            {
                lbIns.Text        = "编辑";
                mfl               = bfl.GetModel(Id);
                tbTitle.Text      = mfl.Title;
                tbSort.Text       = Convert.ToString(mfl.Sort);
                tbSiteUrl.Text    = mfl.SiteUrl;
                btAbandon.Visible = true;
                break;
            }

            case "MyUp":
            {
                DAL.CMS_FriendLink.SetSort(Id, false);
                Flush();
                break;
            }

            case "MyDown":
            {
                DAL.CMS_FriendLink.SetSort(Id, true);
                Flush();
                break;
            }

            case "MyDel":
            {
                bfl.Delete(Id);
                btAbandon_Click(sender, e);        //如果在编辑或添加完的状态下,点了删除
                Flush();
                break;
            }
            }
        }