Grid.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grid.aspx.cs" Inherits="Ext.Net.Study.Grid" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function Details(v) {
            var temp = '<a href="Edit.aspx?AutoId={0}" target="_blank">详细…</a>';
            return String.format(temp, v);
        };
        function CSRQ(v) {
                return String.format("{0}年{1}月{2}日",
                                    v.substr(0, 4),
                                    v.substr(4, 2),
                                    v.substr(6, 2));
        };
        function GridpanelCommand(command, record) {
            if (command == "Delete") {
                Ext.Msg.confirm("删除", "确定删除?" + record.data.AutoId + ":" + record.data.XM,
                function (result) {
                    if (result == "yes") {
                        Ext.net.DirectMethods.Delete(record.data.AutoId);
                    }
                });
            } else if (command == "Update") {
                Ext.net.DirectMethods.Update(record.data.AutoId);
            };
        };
        function BindStore() {
            Ext.net.DirectMethods.BindStore();
        };
    </script>
</head>
<body>
    <form >
        </AutoLoad>
    </ext:Window>
    </form>
</body>
</html>

Grid.aspx.cx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Ext.Net.Study
{
    public partial class Grid : System.Web.UI.Page
    {
        #region 增删改查

        /// <summary>
        /// 增加
        /// </summary>
        [DirectMethod(ShowMask = true)]
        public void Create()
        {
            this.Window1.Icon = Icon.TableAdd;
            this.Window1.Title = "增加";
            this.Window1.AutoLoad.Url = "Edit.aspx?Type=Create";
            this.Window1.Render();
            this.Window1.Show();
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="AutoId"></param>
        [DirectMethod(ShowMask = true)]
        public void Update(string AutoId)
        {
            this.Window1.Icon = Icon.TableEdit;
            this.Window1.Title = "修改";
            this.Window1.AutoLoad.Url = "Edit.aspx?Type=Update&AutoId=" + AutoId;
            this.Window1.Render();
            this.Window1.Show();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="AutoId"></param>
        [DirectMethod(ShowMask = true, Msg = "删除中…")]
        public void Delete(string AutoId)
        {
            Code.Common.DB.ExecuteNonQuery(CommandType.Text, "Delete From tb_Master Where AutoId=" + AutoId);
            this.Store1.RemoveRecord(AutoId);
            this.Store1.CommitChanges();
        }

        /// <summary>
        /// 查找
        /// </summary>
        [DirectMethod(ShowMask = true, Msg = "查找中…")]
        public void Retrieve(string ZJHM)
        {
            if (string.IsNullOrEmpty(ZJHM))
            {
                this.BindStore();
            }
            else
            {
                this.PagingToolbar1.PageSize = this.PagingToolbar1.PageSize;
                this.PagingToolbar1.PageIndex = this.PagingToolbar1.PageIndex;
                DataSet datasetTbMaster = Code.Common.DB.ExecuteDataSet(CommandType.Text,
               "Select * From tb_Master Where ZJHM Like '" + ZJHM + "%' Order By AutoId Desc ");
                this.Store1.DataSource = datasetTbMaster;
                this.Store1.DataBind();
            }
        }

        #endregion

        /// <summary>
        /// 绑定Store1
        /// </summary>
        [DirectMethod(ShowMask = true)]
        public void BindStore()
        {
            this.PagingToolbar1.PageSize = this.PagingToolbar1.PageSize;
            this.PagingToolbar1.PageIndex = this.PagingToolbar1.PageIndex;
            DataSet datasetTbMaster = Code.Common.DB.ExecuteDataSet(CommandType.Text,
                "Select * From tb_Master Order By AutoId Desc ");
            this.Store1.DataSource = datasetTbMaster;
            this.Store1.DataBind();
        }

        //---------------------------------

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BindStore();
            }
        }

        protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            this.PagingToolbar1.PageSize = this.PagingToolbar1.PageSize;
            this.BindStore();
        }

    }
}

Edit.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Ext.Net.Study.Edit" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form />
                                </Listeners>
                            </ext:Button>
                        </Buttons>
                    </ext:FormPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>

Edit.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Ext.Net.Study
{
    public partial class Edit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [DirectMethod(ShowMask = true)]
        public void Submit()
        {
            if (Request.QueryString["Type"].ToString() == "Create")
            {
                Code.Common.DB.ExecuteNonQuery(CommandType.Text,
                " Insert Into " +
                " tb_Master(CSRQ) " +
                " Values('" + this.TextField1.Text + "')");
                X.Js.ResourceManager.RegisterClientScriptBlock(DateTime.Now.ToString(),
                    "window.parent.BindStore();" +
                    "window.parent.Window1.hide();");
            }
            else if (Request.QueryString["Type"].ToString() == "Update")
            {
                Code.Common.DB.ExecuteNonQuery(CommandType.Text,
                " Update tb_Master" +
                " Set BMH='" + this.TextField1.Text + "' " +
                " Where AutoId=" + Request.QueryString["AutoId"].ToString());
                X.Js.ResourceManager.RegisterClientScriptBlock(DateTime.Now.ToString(),
                    "window.parent.BindStore();" +
                    "window.parent.Window1.hide();");
            }
        }
    }
}

相关文章:

  • 2021-11-25
  • 2021-06-14
  • 2021-09-13
  • 2021-06-30
  • 2021-07-23
  • 2022-12-23
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-09-17
  • 2021-10-04
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案