⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gasregisterform.aspx.cs

📁 小区物业管理系统源代码,密码:123456,
💻 CS
字号:
//文件名:GasRegisterForm.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;
public partial class ChargeManage_GasRegisterForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("C1") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        string MyRegInfo = "登记水电气费数据意味着本月正在登记的数据将无法再修改,是否继续?";
        this.Button2.OnClientClick = "return confirm('" + MyRegInfo + "')";
        string MyAddInfo = "现在将新增指定月份水电气费数据,是否继续?";
        this.Button1.OnClientClick = "return confirm('" + MyAddInfo + "')";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//新增水电气费
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyCommunityDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MySQL="Select Count(*) From 水电气费 WHERE 计费年份="+this.DropDownList1.SelectedValue +" AND 计费月份="+this.DropDownList2.SelectedValue+" AND 费用类型='"+this.DropDownList3.SelectedValue+"' AND 楼栋名称='"+this.DropDownList4.SelectedValue+"'";
        SqlCommand MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = MySQL;
        string MyCount = MyCommand.ExecuteScalar().ToString();
        if (Convert.ToInt16(MyCount)==0)
        {
            //插入新月份的费用业主基本信息
            MySQL = "INSERT INTO 水电气费 (楼栋名称,业主编号,业主姓名) SELECT 楼栋名称,业主编号,业主姓名 FROM 业主信息 WHERE (业主编号 NOT IN (SELECT 业主编号 FROM dbo.迁出信息)) AND (楼栋名称='" + this.DropDownList4.SelectedValue + "')";
            MyCommand.CommandText = MySQL;
            MyCommand.ExecuteNonQuery();
            MySQL = "UPDATE 水电气费 SET 登记标志='正在登记',费用类型='" + this.DropDownList3.SelectedValue + "',计费年份=" + this.DropDownList1.SelectedValue + ",计费月份=" + this.DropDownList2.SelectedValue + " WHERE 登记标志 IS NULL";
            MyCommand.CommandText = MySQL;
            MyCommand.ExecuteNonQuery();
            int MyLastMonth = Convert.ToInt16(this.DropDownList2.SelectedValue) - 1;
            int MyLastYear = Convert.ToInt16(this.DropDownList1.SelectedValue);
            if (MyLastMonth == 0)
            {
                MyLastMonth = 12;
                MyLastYear = Convert.ToInt16(this.DropDownList1.SelectedValue) - 1;
            }
            //将上月止数作为新月份底数
            MySQL = "Select 楼栋名称,业主编号,业主姓名,计费年份,计费月份,费用类型,表编号,表底数,表止数,计费单价 FROM 水电气费 WHERE 计费年份=" + MyLastYear.ToString() + " AND 计费月份=" + MyLastMonth.ToString() + " AND 费用类型='" + this.DropDownList3.SelectedValue + "' AND 楼栋名称='" + this.DropDownList4.SelectedValue + "' AND 登记标志='完成登记'";
            DataTable MyComputeTable = new DataTable();
            SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
            MyAdatper.Fill(MyComputeTable);
            foreach (DataRow MyRow in MyComputeTable.Rows)
            {
                string My楼栋名称 = MyRow[0].ToString();
                string My业主编号 = MyRow[1].ToString();
                string My业主姓名 = MyRow[2].ToString();
                string My计费年份 = MyRow[3].ToString();
                string My计费月份 = MyRow[4].ToString();
                string My费用类型 = MyRow[5].ToString();
                string My表编号 = MyRow[6].ToString();
                string My表底数 = MyRow[7].ToString();
                string My表止数 = MyRow[8].ToString();
                string My计费单价 = MyRow[9].ToString();
                MySQL = "UPDATE 水电气费 SET 表编号='" + My表编号 + "',表底数=" + My表止数 + ",计费单价=" + My计费单价 + " WHERE 计费年份=" + this.DropDownList1.SelectedValue + " AND 计费月份=" + this.DropDownList2.SelectedValue  + " AND 费用类型='" + this.DropDownList3.SelectedValue + "' AND 楼栋名称='" + this.DropDownList4.SelectedValue + "' AND 业主编号='" + My业主编号 + "'";
                MyCommand.CommandText = MySQL;
                MyCommand.ExecuteNonQuery();
            }
        }
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.Response.Redirect("~/ChargeManage/GasRegisterForm.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//登记业主水电气费
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyCommunityDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MySQL = "UPDATE 水电气费 SET 登记标志='完成登记',费用状态='未交费' WHERE 计费年份=" + this.DropDownList1.SelectedValue + " AND 计费月份=" + this.DropDownList2.SelectedValue + " AND 费用类型='" + this.DropDownList3.SelectedValue + "' AND 楼栋名称='" + this.DropDownList4.SelectedValue + "'";
        SqlCommand MyCommand = MyConnection.CreateCommand();   
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.Response.Redirect("~/ChargeManage/GasRegisterForm.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -