📄 yaodian.aspx.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 ConsumptionSys_yaodian : System.Web.UI.Page
{
private string id;
private Double drugprice;
//private string drugstoreid;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label2.Text = "10";
if (Request.QueryString["id"] == null)
{
if (Session["id"]==null)
{
Response.Redirect("~/error.aspx");
}
else
{
id = Session["id"].ToString();
string sql = "select * from adminuser where adminid=" + id;
DataTable user = GenericDataAccess.ExecuteSelectCommand(sql, Page);
Label1.Text = user.Rows[0]["adminname"].ToString();
}
}
else
{
id =Request.QueryString["id"];
string sql = "select * from adminuser where adminid=" + id;
DataTable user = GenericDataAccess.ExecuteSelectCommand(sql, Page);
Label1.Text = user.Rows[0]["adminname"].ToString();
}
}
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
Double money = Convert.ToDouble(Label2.Text) * Convert.ToDouble(TextBox4.Text);
Label3.Text = money.ToString();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = "select drugprice from drug where drugname='" + DropDownList1.SelectedValue.ToString() + "'";
DataTable price = GenericDataAccess.ExecuteSelectCommand(sql, Page);
drugprice = Convert.ToDouble(price.Rows[0]["drugprice"]);
Label2.Text = drugprice.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Double money = Convert.ToDouble(Label2.Text) * Convert.ToDouble(TextBox4.Text);
Label3.Text = money.ToString();
if (checkconsumer(TextBox5.Text, TextBox2.Text))
{
string drugname = DropDownList1.SelectedValue.ToString();
string perid = TextBox5.Text;
//drugstoreid =Request.QueryString["id"];
DateTime drugtime = DateTime.Today;
double drugpermoney = Convert.ToDouble(Label2.Text);
int drugnum = Convert.ToInt32(TextBox4.Text);
//double hosmoney;
//if (DropDownList2.SelectedValue == "普通门诊")
//{ hosmoney = 2; }
//else
//{ hosmoney = 10; }
bill a = new bill();
string drugstoreid= a.adminidtodrugstoreid(Session["id"].ToString(), Page).Rows[0]["drugstoreid"].ToString();
double totlemoney = drugpermoney * drugnum;
string sql = "insert into consume(personid,drugstoreid,trugtime,drugnum,drugname,totalmoney,permedmoney)values(" + perid + "," + drugstoreid + ",'" + drugtime + "'," + drugnum + ",'" + drugname + "'," + totlemoney + "," + drugpermoney + ")";
GenericDataAccess.ExecuteNonQuery(sql, Page);
Response.Write("<script language=javascript>alert('添加成功')</script>");
DropDownList1.SelectedIndex = 1;
Label2.Text = "";
TextBox4.Text = "";
Label3.Text = "";
}
}
protected bool checkconsumer(string id, string psd)
{
string sqlid =id;
string sql = "select * from person where personid=" + sqlid + " and perpsw='" + psd + "'";
DataTable a = GenericDataAccess.ExecuteSelectCommand(sql, Page);
if (a.Rows.Count != 0) return true;
else return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -