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

📄 addmeals.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;

public partial class AddMeals : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userName"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                AdminTableAdapters.Tbl_AdminUserTableAdapter admin = new AdminTableAdapters.Tbl_AdminUserTableAdapter();
                this.chklistuser.DataSource = admin.GetData();
                this.chklistuser.DataTextField = "AName";
                this.chklistuser.DataValueField = "AName";
                this.chklistuser.DataBind();
            }
        }
    }


    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        ///添加到采购信息表
        int proid;
        ProcurementTableAdapters.Tbl_ProcurementTableAdapter prota = new ProcurementTableAdapters.Tbl_ProcurementTableAdapter();
        prota.InsertQuery(Convert.ToDateTime(Request.Form["txbdate"]), Session["UserName"].ToString(),(float)Convert.ToDouble(this.txbmoney.Text),this.txbtext.Text);
        proid = Convert.ToInt32(prota.GetDataByTop1(Convert.ToDateTime(Request.Form["txbdate"]), Session["UserName"].ToString(), (float)Convert.ToDouble(this.txbmoney.Text)).Rows[0]["ProId"].ToString());

        ///添加到用餐人员表
        MealsStaffTableAdapters.Tbl_MealsStaffTableAdapter msta = new MealsStaffTableAdapters.Tbl_MealsStaffTableAdapter();
        int counts = 0;
        float money = (float)Convert.ToDouble(this.txbmoney.Text);
        float permoney,sessionpermoney;
        for (int i = 0; i < this.chklistuser.Items.Count; i++)
        {
            if (this.chklistuser.Items[i].Selected)
            {
                counts++;
            }
        }

        permoney = 0-money / counts;    //非采购者
        sessionpermoney = money - money / counts;   //采购者

        for (int i = 0; i < this.chklistuser.Items.Count; i++)
        {
            if (this.chklistuser.Items[i].Selected)
            {
                if (this.chklistuser.Items[i].Value != Session["UserName"].ToString())
                {///不是采购者本人
                    msta.InsertQuery(proid,this.chklistuser.Items[i].Value,permoney);
                }
                else
                {///是采购者本人
                    msta.InsertQuery(proid, this.chklistuser.Items[i].Value, sessionpermoney);
                }
            }
        }

        Response.Write("<script>confirm('信息录入成功!您还要继续录入信息吗?')?self.location='AddMeals.aspx':self.location='MealsList.aspx'</script>");
    }
}

⌨️ 快捷键说明

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