?? 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 + -