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

📄 stock_add.aspx.cs

📁 基于JSP+SQL Sever2000+Tomcat的网络服务器体系结构开发技术和对数据库技术的进一步了解以及对政府网站的调查研究
💻 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 Stock_Stock_return : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
	    this.Label1.Text = Convert.ToString(Session["username"]);
            if (Convert.ToString(Session["username"]) == "")
            {
                Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
            }
            SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
            strcon.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select * from tb_Commodity order by id desc",strcon);
            DataSet ds = new DataSet();
            sda.Fill(ds, "tb_Commodity");
            DataRowView rowview = ds.Tables["tb_Commodity"].DefaultView[0];
            int CommodityIds = Convert.ToInt32(rowview["CompanyId"]);

            this.CommodityId.DataSource = ds.Tables["tb_Commodity"];
            this.CommodityId.DataValueField = "id";
            this.CommodityId.DataTextField = "CommodityName";
            this.CommodityId.DataBind();
            SqlCommand scdc = new SqlCommand("select CompanyName from tb_Company where id=" + CommodityIds, strcon);
            this.CId.Text = Convert.ToString(scdc.ExecuteScalar());
            this.CompanyId.Value = CommodityIds.ToString();
            strcon.Close();

            this.StockDate.SelectedDate = DateTime.Now;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string CommodityId=this.CommodityId.Text.ToString();
        string CompanyId=this.CompanyId.Value.ToString();
        int Number = Math.Abs(Convert.ToInt32(this.Number.Text));
        int Pirce =  Math.Abs(Convert.ToInt32(this.Pirce.Text));
        string StockDate=this.StockDate.SelectedDate.ToShortDateString();
        string SettlementType=this.SettlementType.Text.ToString();
        int Payment = Math.Abs(Convert.ToInt32(Request["Payment"]));
        int FactPayment = Math.Abs(Convert.ToInt32(this.FactPayment.Text));
        int NotPayment = Math.Abs(Convert.ToInt32(Request["NotPayment"]));
        string ManageMan=this.ManageMan.Text.ToString();
        string Username = Convert.ToString(Session["username"]);
        string AddTime=Convert.ToString(DateTime.Now);
        string Type = "进货信息";
        //计算输入的金额是否正确
        if (Number * Pirce < Payment)
        {
            Response.Write("<script>alert('应付金额填写错误');history.back()</script>");
            Response.End();
        }
        SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        strcon.Open();
        SqlCommand scd = new SqlCommand("insert into tb_Stock (CommodityId,CompanyId,Number,Pirce,StockDate,SettlementType,Payment,FactPayment,NotPayment,ManageMan,Username,AddTime,Type)values('" + CommodityId + "','" + CompanyId + "','" + Number + "','" + Pirce + "','" + StockDate + "','" + SettlementType + "','" + Payment + "','" + FactPayment + "','" + NotPayment + "','" + ManageMan + "','" + Username + "','" + AddTime + "','" + Type + "')", strcon);
        scd.ExecuteNonQuery();
        strcon.Close();
        Response.Write("<script language=javascript>alert('添加成功');location='Stock_return.aspx'</script>");
    }

    protected void CommodityId_TextChanged(object sender, EventArgs e)
    {
        SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        strcon.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from tb_Commodity where id=" + Request["CommodityId"], strcon);
        DataSet ds = new DataSet();
        sda.Fill(ds, "tb_Commodity");
        DataRowView rowview = ds.Tables["tb_Commodity"].DefaultView[0];
        string CommodityIds = Convert.ToString(rowview["CompanyId"]);

        this.CommodityId.DataBind();
        SqlCommand scdc = new SqlCommand("select CompanyName from tb_Company where id=" + CommodityIds, strcon);
        this.CId.Text = Convert.ToString(scdc.ExecuteScalar());
        this.CompanyId.Value = CommodityIds;

    }
}

⌨️ 快捷键说明

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