📄 gaspaymentform.aspx.cs
字号:
//文件名:GasPaymentForm.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_GasPaymentForm : System.Web.UI.Page
{
private static DataTable MyGasTable = new DataTable();
private static Double MyAmount = 0;
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("C3") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button3.OnClientClick = "return confirm('请检查水电气费收据信息是否正确,一旦保存就无法修改,是否继续?')";
}
protected void Button1_Click(object sender, EventArgs e)
{//新增水电气费收据信息
this.TextBox1.Text = System.Guid.NewGuid().ToString().ToUpper();
this.TextBox2.Text = DateTime.Now.ToShortDateString();
this.TextBox6.Text = Session["MyUserName"].ToString();
MyAmount = 0;
//创建无连接的数据表
DataColumn[] MyKey = new DataColumn[1];
MyGasTable = new DataTable("水电气费明细表");
DataColumn MyColumn = new DataColumn();
MyColumn.DataType = System.Type.GetType("System.Int16");
MyColumn.ColumnName = "序号";
MyGasTable.Columns.Add(MyColumn);
MyKey[0] = MyColumn;
MyGasTable.PrimaryKey = MyKey;
MyGasTable.Columns.Add("年份", System.Type.GetType("System.Int16"));
MyGasTable.Columns.Add("月份", System.Type.GetType("System.Int16"));
MyGasTable.Columns.Add("类型", System.Type.GetType("System.String"));
MyGasTable.Columns.Add("表号", System.Type.GetType("System.String"));
MyGasTable.Columns.Add("底数", System.Type.GetType("System.Double"));
MyGasTable.Columns.Add("止数", System.Type.GetType("System.Double"));
MyGasTable.Columns.Add("用量", System.Type.GetType("System.Double"));
MyGasTable.Columns.Add("单价", System.Type.GetType("System.Double"));
MyGasTable.Columns.Add("金额", System.Type.GetType("System.Double"));
MyGasTable.Rows.Clear();
this.GridView2.DataSource = MyGasTable;
this.GridView2.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{//增加水电气费明细项目
if ((this.TextBox1.Text.Length > 1) && (this.TextBox3.Text.Length > 1))
{
try
{
DataRow MyRow = MyGasTable.NewRow();
MyRow[0] = Convert.ToInt16(this.GridView1.SelectedRow.Cells[1].Text.ToString());
MyRow["年份"] = Convert.ToInt16(this.GridView1.SelectedRow.Cells[2].Text.ToString());
MyRow["月份"] = Convert.ToInt16(this.GridView1.SelectedRow.Cells[3].Text.ToString());
MyRow["类型"] = this.GridView1.SelectedRow.Cells[4].Text.ToString();
MyRow["表号"] = this.GridView1.SelectedRow.Cells[5].Text.ToString();
MyRow["底数"] = Convert.ToDouble(this.GridView1.SelectedRow.Cells[6].Text.ToString());
MyRow["止数"] = Convert.ToDouble(this.GridView1.SelectedRow.Cells[7].Text.ToString());
MyRow["用量"] = Convert.ToDouble(this.GridView1.SelectedRow.Cells[8].Text.ToString());
MyRow["单价"] = Convert.ToDouble(this.GridView1.SelectedRow.Cells[9].Text.ToString());
MyRow["金额"] = Convert.ToDouble(this.GridView1.SelectedRow.Cells[10].Text.ToString());
MyGasTable.Rows.Add(MyRow);
this.GridView2.DataSource = MyGasTable;
this.GridView2.DataBind();
MyAmount += Convert.ToDouble(this.GridView1.SelectedRow.Cells[10].Text.ToString());
this.TextBox4.Text = MyAmount.ToString();
}
catch (Exception MyException)
{
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{//打印水电气费收据
Server.Transfer("~/ChargeManage/GasPaymentPrint.aspx");
}
public DataTable MyPrintDataTable
{//设置要传递到打印页的数据
get
{
return MyGasTable;
}
}
public String MyPrint补充说明
{//设置要传递到打印页的数据
get
{
return this.TextBox8.Text;
}
}
public String MyPrint收据编号
{//设置要传递到打印页的数据
get
{
return this.TextBox1.Text;
}
}
public String MyPrint收款日期
{//设置要传递到打印页的数据
get
{
return this.TextBox2.Text;
}
}
public String MyPrint交款人员
{//设置要传递到打印页的数据
get
{
return this.TextBox3.Text;
}
}
public String MyPrint收款金额
{//设置要传递到打印页的数据
get
{
return this.TextBox4.Text;
}
}
public String MyPrint收款形式
{//设置要传递到打印页的数据
get
{
return this.TextBox5.Text;
}
}
public String MyPrint收款事由
{//设置要传递到打印页的数据
get
{
return this.DropDownList1.SelectedItem.Text+this.DropDownList2.SelectedItem.Text+this.TextBox7.Text;
}
}
public String MyPrint收款人员
{//设置要传递到打印页的数据
get
{
return this.TextBox6.Text;
}
}
protected void Button3_Click(object sender, EventArgs e)
{//保存水电气费收据
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyCommunityDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
string MySQL = "INSERT INTO 费用收据(收据编号,收款日期,交款人员,收款金额,收款形式,收款人员,收款事由,补充说明) VALUES('";
MySQL += this.TextBox1.Text + "','";
MySQL += this.TextBox2.Text + "','";
MySQL += this.TextBox3.Text + "',";
MySQL += this.TextBox4.Text + ",'";
MySQL += this.TextBox5.Text + "','";
MySQL += this.TextBox6.Text + "','";
MySQL += this.TextBox7.Text + "','";
MySQL += this.TextBox8.Text + "');";
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
foreach (DataRow MyRow in MyGasTable.Rows)
{
string My原编号 = MyRow[0].ToString();
string My收据编号 = this.TextBox1.Text;
MySQL = "UPDATE 水电气费 SET 费用状态='已交费',收据编号='" + My收据编号 + "' WHERE 自动编号=" + My原编号;
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
}
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
Server.Transfer("~/ChargeManage/GasPaymentForm.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -