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

📄 back_sell.aspx.cs

📁 网上销售订单管理系统借助现代信息技术和管理理论
💻 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 Back_Sell : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HeardConfig();
        if (!IsPostBack)
        {
            PersonInfo.Return_SessionPerson();//判断管理员是否登陆
            IsPage_Bind();
        }
    }
    #region 页面初始化必需的内容 附加脚本
    public void HeardConfig()
    {
        Header.Title = "销售订单管理系统-销售退货登记";
        HeaderTextInfo.GetHeader(this, "<script language='javascript' type='text/javascript' src='Computation.js'></script>");
    }
    #endregion
    public void IsPage_Bind()
    {
        this.Label1.Text = QueryString.Get_SessionPerson;
        SqlConnection strcon = new SqlConnection(ConfigurationManager.ConnectionStrings["SellOrder_ConnectionString"].ConnectionString);
        strcon.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from 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 Company where id=" + CommodityIds + "", strcon);
        this.CId.Text = Convert.ToString(scdc.ExecuteScalar());
        this.CompanyId.Value = CommodityIds.ToString();
        //显示客户
        SqlDataAdapter sdac = new SqlDataAdapter("select * from Company where CompanyType='客户' order by id desc", strcon);
        sdac.Fill(ds, "tb_Company");
        this.ClientId.DataSource = ds.Tables["tb_Company"];
        this.ClientId.DataValueField = "id";
        this.ClientId.DataTextField = "CompanyName";
        this.ClientId.DataBind();

        this.StockDate.SelectedDate = DateTime.Now;
    }
    //当选择商品变动时内容变动时执行
    protected void CommodityId_TextChanged(object sender, EventArgs e)
    {
        SqlConnection strcon = new SqlConnection(ConfigurationManager.ConnectionStrings["SellOrder_ConnectionString"].ConnectionString);
        strcon.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from Commodity where id=" + this.CommodityId.SelectedValue + "", strcon);
        DataSet ds = new DataSet();
        sda.Fill(ds, "tb_Commodity");
        DataRowView rowview = ds.Tables["tb_Commodity"].DefaultView[0];
        string CommodityIds = Convert.ToString(rowview["CompanyId"]);

        SqlCommand scdc = new SqlCommand("select CompanyName from Company where id=" + CommodityIds + "", strcon);
        this.CId.Text = Convert.ToString(scdc.ExecuteScalar());
        this.CompanyId.Value = CommodityIds;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //取出各项数据
        string CommodityId = this.CommodityId.Text.ToString();
        string CompanyId = this.CompanyId.Value.ToString();
        int ClientId = Convert.ToInt32(this.ClientId.SelectedValue);//取出选定客户
        int Number = Math.Abs(Convert.ToInt32(this.Number.Text));
        decimal Pirce = Decimal.Round(Convert.ToDecimal(this.Pirce.Text.Trim()), 2);//单价,保留2位小数
        string StockDate = this.StockDate.SelectedDate.ToShortDateString();
        string SettlementType = this.SettlementType.Text.ToString();
        decimal Payment = Decimal.Round(Convert.ToDecimal(this.Payment.Text.Trim()), 2);//应付金额,保留2位小数
        decimal FactPayment = Decimal.Round(Convert.ToDecimal(this.FactPayment.Text.Trim()), 2);//实付金额,保留2位小数
        decimal NotPayment = Decimal.Round(Convert.ToDecimal(this.NotPayment.Text.Trim()), 2);//未付金额,保留2位小数
        string ManageMan = this.ManageMan.Text.ToString();
        string Username = QueryString.Get_SessionPerson;//操作的管理员
        string AddTime = Convert.ToString(DateTime.Now);
        string Type = "销售退货";
        //计算输入的金额是否正确
        if (Number * Pirce < Payment)
        {
            Response.Write("<script>alert('应付金额填写错误');history.back()</script>");
            Response.End();
        }
        string CmdTxt = "insert into Stock (CommodityId,CompanyId,Number,Pirce,StockDate,SettlementType,Payment,FactPayment,NotPayment,ManageMan,Username,AddTime,Type,ClientId)values('" + CommodityId + "','" + CompanyId + "','" + Number + "','" + Pirce + "','" + StockDate + "','" + SettlementType + "','" + Payment + "','" + FactPayment + "','" + NotPayment + "','" + ManageMan + "','" + Username + "','" + AddTime + "','" + Type + "','" + ClientId + "')";
        bool YesNo = new SqlDataBase().RunSql_Return_Bool(CmdTxt);//判断添加后返回结果,如果正确则返回的是1
        if (YesNo)
        { JScript.AlertAndRedirect("添加销售退货记录成功!", "Back_Sell.aspx"); }
        else
        { JScript.GoHistory("添加销售退货记录失败", -1); }
    }
}

⌨️ 快捷键说明

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