Ext.Net1.7 后台操作页面超时 并 实现进度条的问题



需要达到如图样式
protected void Page_Load(object sender, EventArgs e)
{

    }

    private static string TableName; //要修改的表名

    [DirectMethod(Timeout = 900000)]
    protected void btnOK_DirectClick(object sender, Ext.Net.DirectEventArgs e) 
    {
        UpHouse();
    }        
    [DirectMethod(Timeout=900000)]
    public void UpHouse()
    {
        try
        {
            TableName = this.txtTable.Text.Trim();
            DataTable dt = GetDataReader("select distinct HouseCode from " + TableName + " order by HouseCode"); //获取非重复的数据
            foreach (DataRow dr in dt.Rows)
            {
                string HouseCode = dr["HouseCode"].ToString();
                string strSql = "select Id,HouseCode,HouseNo from " + TableName + " where HouseCode = '" + HouseCode + "' order by HouseCode";
                DataTable dtr = GetDataReader(strSql);
                for (int i = 0; i < dtr.Rows.Count; i++)
                {
                    string HouseCode_new = dtr.Rows[i]["HouseCode"].ToString().Trim();
                    string HouseNo = dtr.Rows[i]["HouseNo"].ToString().Trim();
                    string HouseId = dtr.Rows[i]["Id"].ToString().Trim();
                    if (HouseCode_new != HouseNo)
                    {
                        string UdSql = "Update " + TableName + " set HouseNo = '" + HouseCode_new + "' where Id = " + HouseId;
                        UpdateDataReader(UdSql);
                        break;
                    }
                }
            }
            X.Msg.Alert("提示", "修改成功!").Show();
        }
        catch (Exception e)
        {
            X.Msg.Alert("提示", "修改失败!" + e.Message).Show();
        }
    }

    #region 数据处理
    public static string strConn = "Data source=localhost;database=HH;user id=sa;pwd=sa;";

    public static DataTable GetDataReader(string strSql)
    {
        using (SqlConnection connection = new SqlConnection(strConn))
        {
            DataTable dt = new DataTable();
            try
            {
                SqlDataAdapter command = new SqlDataAdapter(strSql, strConn);
                connection.Open();
                command.Fill(dt);
            }
            catch (Exception ex)
            {
                connection.Close();
                throw new Exception(ex.Message);
            }
            finally
            {
                connection.Close();
            }
            return dt;
        }
    }

    public static int UpdateDataReader(string strSql)
    {

        using (SqlConnection connection = new SqlConnection(strConn))
        {
            DataSet ds = new DataSet();
            try
            {
                SqlCommand command = new SqlCommand(strSql, connection);
                connection.Open();
                if (command.ExecuteNonQuery() > 0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            catch (Exception ex)
            {
                connection.Close();
                throw new Exception(ex.Message);
            }
            finally
            {
                connection.Close();
            }
        }
    }
    #endregion        
}

}

c#
0

2个回答

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpdateHouse.aspx.cs" Inherits="WebState.UpdateHouse" %>

<!DOCTYPE html>








Title="数据修改Test"
Width="400">








Failure="Ext.Msg.show({
title:'Error',
msg:'查询失败',
minWidth:200,
modal:true,
icon:Ext.Msg.ERROR,
buttons:Ext.Msg.OK
});">


/ext:Button

/ext:CompositeField

/ext:FormPanel

/ext:Window

0
<ext:ResourceManager ID="ResM" runat="server" DirectMethodNamespace="CompanyX" />
<ext:Window runat="server" ID="win1"
    Title="数据修改Test"
    Width="400">
    <Items>
        <ext:FormPanel ID="fPanel" runat="server" Layout="AnchorLayout" Width="400">
            <Items>
                <ext:CompositeField ID="comf" runat="server">
                    <Items>
                        <ext:TextField ID="txtTable" runat="server" FieldLabel="请输入要修改的表名" LabelWidth="120" />
                        <ext:Button ID="btnQuery" runat="server" Text="修改">
                            <DirectEvents>
                                <Click OnEvent="btnOK_DirectClick" Before="Ext.Msg.wait('正在修改数据,请稍候...','修改');"
                                    Failure="Ext.Msg.show({
                                                title:'Error',
                                                msg:'查询失败',
                                                minWidth:200,
                                                modal:true,
                                                icon:Ext.Msg.ERROR,
                                                buttons:Ext.Msg.OK
                                             });">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:CompositeField>
            </Items>
        </ext:FormPanel>
    </Items>
</ext:Window>
0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!