毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 管理论文 >> 正文

自来水售水系统分析与设计 第8页

更新时间:2014-6-28:  来源:毕业论文

自来水售水系统分析与设计 第8页
             图4-1 用户报停水表模块
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Ustop : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void BtnSDemand_Click(object sender, EventArgs e)
    {
        string connstr = WebConfigurationManager.ConnectionStrings["waterConnectionString"].ConnectionString;
        SqlConnection sqlconn = new SqlConnection(connstr);
        sqlconn.Open();
        SqlCommand sqlcmd = sqlconn.CreateCommand();
        sqlcmd.CommandType = CommandType.Text;
        sqlcmd.CommandText = "select UserName,Addr,MeterSta,MeterCode from tbMeterUser where UserCode='" + this.TxtUCode.Text.Trim() + "'";    
        SqlDataReader sqldr = sqlcmd.ExecuteReader();      
        while (sqldr.Read())
        {
            TxtUName.Text = sqldr[0].ToString();
            TxtAddr.Text = sqldr[1].ToString();
            TxtMSta.Text = sqldr[2].ToString();
            TxtMCode.Text = sqldr[3].ToString();
        }
        sqldr.Close();     
    }

    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
    protected void BtnStop_Click(object sender, EventArgs e)
    {
        string usercode = TxtUCode.Text.Trim();
        string str1 = "Insert Into tdUserStop(UserCode,Addr,MeterCode,MeterSta,StopDate,SOperator,StopRea) Values(@UserCode,@Addr,@MeterCode,@MeterSta,@StopDate,@SOperator,@StopRea)";
        string str2 = "UPDATE tbMeterUser SET MeterSta='报停' WHRE Code='" + usercode + "'";
        string str3 = "UPDATE tbMeter SET MeterSta='报停' WHRE Code='" + usercode + "'";
        string connstr = WebConfigurationManager.ConnectionStrings["waterConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(connstr);
        try
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand(str1, conn);
            cmd.Parameters.AddWithValue("@UserCode", TxtUCode.Text);
            cmd.Parameters.AddWithValue("@Addr", TxtAddr.Text);
            cmd.Parameters.AddWithValue("@MeterCode", TxtMCode.Text);
            cmd.Parameters.AddWithValue("@MeterSta", TxtMSta.Text);
            cmd.Parameters.AddWithValue("@StopDate", TxtSDate.Text);
            cmd.Parameters.AddWithValue("@SOperator", TxtSOper.Text);
            cmd.Parameters.AddWithValue("@StopRea", TxtSRea.Text);
            cmd.ExecuteNonQuery();
            Response.Write("<script>alert('success!');</script>");
        }
        catch (Exception ex)
        {
            lblPrompt.Text = ex.Message;
        }
    }
    protected void TxtMSta_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TxtSOper_TextChanged(object sender, EventArgs e)
    {

    }
}
说明:代码里面包括系统的后台数据库的连接,自来水用户具体资料的条件输入查询,然后进行报停业务的操作和存储,以及退出当前界面的功能,同时还有显示报停成功的功能。
水量统计代码设计


             图4-2 水量统计模块
public partial class WaterStat : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        try
        {
            string str1 = "select usercode,sum(ActualWater) MonthActWater from tdwater where 1=1 ";
            if (txtTheMonth.Text.Trim().Length != 0)
            {
                str1 += " and TheMonth='" + txtTheMonth.Text.Trim().ToString() + "'";
            }
            str1 += "group by UserCode order by usercode ";
            string connstr = WebConfigurationManager.ConnectionStrings["waterConnectionString"].ConnectionString;
            SqlConnection conn = new SqlConnection(connstr);
            DataSet ds = new DataSet();         
            SqlDataAdapter da = new SqlDataAdapter(str1, conn);
            SqlCommandBuilder cmd = new SqlCommandBuilder(da);
            da.Fill(ds);
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
    protected void btnStat_Click(object sender, EventArgs e)
    {
        BindData();
    }
    protected void btnExit_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
    protected void btnSum_Click(object sender, EventArgs e)
    {
        try
        {
            string str1 = "select sum(ActualWater) MonthActWater from tdwater where 1=1 ";
            if (txtTheMonth.Text.Trim().Length != 0)
            {
                str1 += " and TheMonth='" + txtTheMonth.Text.Trim().ToString() + "'";
            }
            string connstr = WebConfigurationManager.ConnectionStrings["waterConnectionString"].ConnectionString;
            SqlConnection conn = new SqlConnection(connstr);
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(str1, conn);
            SqlCommandBuilder cmd = new SqlCommandBuilder(da);
            da.Fill(ds);
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
            DataRow Row = ds.Tables[0].Rows[0];
            lblCount.Text = Row["MonthActWater"].ToString();
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
}
说明:代码里面包括用户用水量的分月查询并显示在对应的文本框,然后再对现实的水量进行计算,统计相应的月份用户用水的总量。
管理员名称修改模块代码设计

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

自来水售水系统分析与设计 第8页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。