admin/jinhuo/Add.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_jinhuo_Add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet dsgongyingshang = SqlHelper.ExecuteforDataSet("select id,mingcheng from supplier");
            gongyingshang.DataSource = dsgongyingshang;
            gongyingshang.DataTextField = "mingcheng";
            gongyingshang.DataValueField = "id";
            gongyingshang.DataBind();

            DataSet shuiguo1 = SqlHelper.ExecuteforDataSet("select pid,pname from products");
            shuiguo.DataSource = shuiguo1;
            shuiguo.DataTextField = "pname";
            shuiguo.DataValueField = "pid";
            shuiguo.DataBind();
     
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string supplierID = gongyingshang.SelectedValue;//获取供应商ID
        string productID = shuiguo.SelectedValue;//获取ID
        int shuliang = 0;
        double jiage = 0.0;
        try
        {
            shuliang = int.Parse(this.txt_shuliang.Text);//验证进货数量格式
        }
        catch (Exception) 
        {
            MessageBox.Show(this, "数量格式不正确!");
            return;
        }
        try
        {
            jiage = double.Parse(this.txt_jiage.Text);
        }
        catch (Exception)
        {
            MessageBox.Show(this, "价格格式不正确!");//验证价格格式
            return;
        }
        double zonger = shuliang * jiage;
        //插入进货信息
        string strsql = " Insert into jinhuo(supplierID,productID,shuliang,jiage,zonger,shijian)values(";
        strsql += " " + supplierID + "," + productID + "," + shuliang + "," + jiage + "," + zonger + ",'"+DateTime.Now.ToString("yyyy-MM-dd")+"')";
        //增加库存信息
        strsql += " Update products set quan=quan+" + shuliang + " where pid=" + productID + "";
        SqlHelper.ExecuteNonQuery(strsql.ToString());

后面还有 3 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。