manageregisterform.aspx.cs

来自「小区物业管理系统源代码,密码:123456,」· CS 代码 · 共 89 行

CS
89
字号
//文件名:ManageRegisterForm.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_ManageRegisterForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("C4") > 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 + "'";
        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 迁出信息)) AND (楼栋名称='" + this.DropDownList3.SelectedValue + "')";
            MyCommand.CommandText = MySQL;
            MyCommand.ExecuteNonQuery();
            MySQL = "UPDATE 物管费用 SET 登记标志='正在登记',计费年份=" + 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.ToString() + "' 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();
                MySQL = "UPDATE 物管费用 SET 计费单价=" + My计费单价 + " WHERE 计费年份=" + this.DropDownList1.SelectedValue + " AND 计费月份=" + this.DropDownList2.SelectedValue + " AND 楼栋名称='" + this.DropDownList3.SelectedValue + "' AND 业主编号='" + My业主编号 + "'";
                MyCommand.CommandText = MySQL;
                MyCommand.ExecuteNonQuery();
            }
        }
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.Response.Redirect("~/ChargeManage/ManageRegisterForm.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 + "'";
        SqlCommand MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.Response.Redirect("~/ChargeManage/ManageRegisterForm.aspx");
    }
}

⌨️ 快捷键说明

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