📄 buytransferform.aspx.cs
字号:
//文件名:BuyTransferForm.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 BuyManage_BuyTransferForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("C5") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
this.Button2.OnClientClick = "return confirm('请检查采购商品结转货款信息是否正确,一旦保存就无法修改,是否继续?')";
}
protected void Button1_Click(object sender, EventArgs e)
{//新增采购商品货款结转单
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MySaleDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
string MySQL = "Select * From 采购信息 Where 采购单号='" + this.TextBox1.Text + "'";
SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
if (MyCommand.ExecuteScalar() != null)
{
this.Page.RegisterStartupScript("msgOnlyAlert", "<script>alert('商品采购货款结转单号已经存在!')</script>");
this.TextBox1.Text = "";
}
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
this.TextBox5.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{//保存采购商品货款结转单
if (this.TextBox1.Text == "" || this.TextBox5.Text == "")
return;
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MySaleDBConnectionString"].ConnectionString;
string MySQL = "INSERT INTO 采购信息(采购单号,客户名称,应付金额,实付金额,支付方式,经办人员,入库日期,补充说明)VALUES('";
MySQL += this.TextBox1.Text + "','";
MySQL += this.TextBox5.Text + "','";
MySQL += "0','";
MySQL += this.TextBox3.Text + "','";
MySQL += "其他','";
MySQL += this.TextBox4.Text + "','";
MySQL += this.TextBox2.Text + "','";
MySQL += this.TextBox7.Text + "');";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = MySQL;
MyCommand.ExecuteNonQuery();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
this.TextBox1.Text = "";
this.TextBox5.Text = "";
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{//显示客户的应付金额
this.TextBox5.Text = this.GridView1.SelectedRow.Cells[1].Text.ToString();
//获取应付货款总额
SqlConnection MyConnection = new SqlConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["MySaleDBConnectionString"].ConnectionString;
MyConnection.Open();
string MySQL = "Select SUM(应付账款) From 采购信息 WHERE 客户名称='" + this.GridView1.SelectedRow.Cells[1].Text.ToString() + "'";
SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
this.TextBox6.Text = MyCommand.ExecuteScalar().ToString();
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -