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

📄 审核入库界面.aspx.cs

📁 本系统时物资管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 物资管理___陈_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            this.DropDownListhegepanduan.Items.Add("合格");
            this.DropDownListhegepanduan.Items.Add("不合格");
        }
        

        //设置数据库连接串
        string myConnStr
               = "data source= . ;  database=物资管理系统;Trusted_Connection=SSPI ";

        //设置要执行的SQL命令
        //提取当前增加的进货单的编号并设置到控件
        SqlConnection myConn = new SqlConnection(myConnStr);
        string sql = "select max(采购单编号) from 物资采购信息表";
        SqlCommand myComm = new SqlCommand(sql, myConn);
        myConn.Open();
      
       
        //设置要执行的SQL命令
        //提取当前采购的原料物资名称并设置到控件
        sql = "select  入库单编号 from 原料入库信息表 ";
        myComm = new SqlCommand(sql, myConn);
        SqlDataReader myReader = myComm.ExecuteReader();
        if (!IsPostBack)
        {
            this.DropDownListyuanliaoshenhe.Items.Add("");
            while (myReader.Read())
                this.DropDownListyuanliaoshenhe.Items.Add(myReader.GetValue(0).ToString());
        }
        myReader.Close();
        //设置要执行的SQL命令
        //提取当前供应商并设置到控件
        sql = "select 成品编号 from 成品入库信息表  ";
        myComm = new SqlCommand(sql, myConn);
        myReader = myComm.ExecuteReader();
        if (!IsPostBack)
        {
            this.DropDownListchengpinshenhe.Items.Add("");
            while (myReader.Read())
              this.DropDownListchengpinshenhe.Items.Add(myReader.GetValue(0).ToString());
        }
        myReader.Close();
        myConn.Close(); 
     
 

    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("物资入库界面.aspx");
    }

    protected void Buttonbaocun_Click(object sender, EventArgs e)
    {
        if (this.TextBoxrukudanbianhao.Text == "" || this.TextBox2.Text == "" || this.TextBox1.Text == "" || this.TextBoxrukuriqi.Text == "" || this.TextBoxjingshouren.Text == "")
        {
            this.Response.Write("<script language=javascript>alert('请确定审核信息填写齐全!')</script>");
        }
        if (this.DropDownListhegepanduan.Text == "合格" && this.TextBoxrukudanbianhao.Text != "" && this.TextBox2.Text != "" && this.TextBox1.Text != "" && this.TextBoxrukuriqi.Text != "" && this.TextBoxjingshouren.Text != "")
        {
             string myConnStr = "data source=.;database=物资管理系统;trusted_connection=SSPI";
                SqlConnection myConn = new SqlConnection(myConnStr);

            if (this.DropDownListyuanliaoshenhe.Text != "")
            {
                SqlCommand myComm;
                string gonghuoshang="";
                string wuzidanjia="";
                string gonghuodidian="";
                myConn.Open();
                string sql = "select max(物资编号) from 物资信息表";
                 myComm = new SqlCommand(sql, myConn);               
                int maxNum = Convert.ToInt32(myComm.ExecuteScalar()) + 1;
                string maxnum = Convert.ToString(maxNum);

                string sql1 = "select 供货商,物资单价 from 物资采购信息表 where 采购单编号='" + this.DropDownListyuanliaoshenhe.Text+"'";
                myComm = new SqlCommand(sql1, myConn);
                SqlDataReader myReader1= myComm.ExecuteReader();
                DataTable d = new DataTable();

                d.Columns.Add("供货商", typeof(string));
                d.Columns.Add("物资单价", typeof(string));
               DataRow dr = d.NewRow();
               if (myReader1.Read())
               {
                   
                   dr[0] = myReader1.GetValue(0).ToString();
                   dr[1] = myReader1.GetValue(1).ToString();
                   gonghuoshang = Convert.ToString(dr[0]);
                    wuzidanjia=Convert.ToString (dr[1]);
               }
               myReader1.Close();

                sql1 = "select 供货地点 from 供货商表 where 供货商='" + gonghuoshang + "'";
                myComm = new SqlCommand(sql1, myConn);
                SqlDataReader myReader2 = myComm.ExecuteReader();
                DataTable dt = new DataTable();
                dt.Columns.Add("供货地点", typeof(string));
                dr = dt.NewRow();
               if (myReader2.Read())
               {
                  
                   dr[0] = myReader2.GetValue(0).ToString();
                    gonghuodidian = Convert.ToString(dr[0]);
               }
              myReader2.Close();
                string sql3 = "insert into 物资信息表(物资编号,物资名称,物资数量,生产地点,仓库名称,单价,备注) values('" +maxnum + "','" + this.TextBox2.Text + "','" + TextBox1.Text
                    + "','" + gonghuodidian + "',' 原料仓库 '," + wuzidanjia + ",' 原料 ');";
                myComm = new SqlCommand(sql3, myConn);        
                myComm.ExecuteNonQuery();
              
                string sql4 = "select * from 物资信息表";
                myComm = new SqlCommand(sql4, myConn);
                SqlDataReader myReader = myComm.ExecuteReader();
              
                    dt = new DataTable();
                dt.Columns.Add("物资编号", typeof(string));
                dt.Columns.Add("物资名称", typeof(string));
                dt.Columns.Add("物资数量", typeof(string));
                dt.Columns.Add("生产地点", typeof(string));
                dt.Columns.Add("仓库名称", typeof(string));
                dt.Columns.Add("单 价", typeof(string));
                dt.Columns.Add("备 注", typeof(string));

                while (myReader.Read())
                {
                     dr = dt.NewRow();
                    dr[0] = myReader.GetValue(0).ToString();
                    dr[1] = myReader.GetValue(1).ToString();
                    dr[2] = myReader.GetValue(2).ToString();
                    dr[3] = myReader.GetValue(3).ToString();
                    dr[4] = myReader.GetValue(4).ToString();
                    dr[5] = myReader.GetValue(5).ToString();
                    dr[6] = myReader.GetValue(6).ToString();
                    dt.Rows.Add(dr);
                }
                myReader.Close();
                this.GridView2.DataSource = new DataView(dt);
                this.GridView2.DataBind();
                myConn.Close();

                //提示用户操作成功
                this.Response.Write("<script language=javascript>alert('通过审核!且物资信息表相应修改成功!')</script>");
                
            }
          else if (this.DropDownListchengpinshenhe.Text != "")
              {               
                SqlCommand myComm;
                string gonghuodidian="";
                string wuzidanjia="";
                 myConn.Open();

                string sql = "select max(物资编号) from 物资信息表";
                 myComm = new SqlCommand(sql, myConn);               
                int maxNum = Convert.ToInt32(myComm.ExecuteScalar()) + 1;
                string maxnum = Convert.ToString(maxNum);

                string sql1 = "select 生产地点,成品单价 from 成品入库信息表 where 成品编号='" + this.DropDownListchengpinshenhe.Text+"'";
                myComm = new SqlCommand(sql1, myConn);
                SqlDataReader myReader1= myComm.ExecuteReader();
                DataTable d = new DataTable();

                d.Columns.Add("生产地点", typeof(string));
                d.Columns.Add("成品单价", typeof(string));
               DataRow dr = d.NewRow();
               if (myReader1.Read())
               {
                   
                   dr[0] = myReader1.GetValue(0).ToString();
                   dr[1] = myReader1.GetValue(1).ToString();

⌨️ 快捷键说明

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