using AIMSBLL; using AIMSModel; using DrawGraph; using System; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace AIMS.OremrUserControl { public partial class UCOperationGoodsBill : UserControl { public delegate void SelectTextBoxHadler(object uc, KeyEventArgs e); public event SelectTextBoxHadler SelectTextBoxEvent; public UCOperationGoodsBill() { InitializeComponent(); if (app == null) app = new ApplianceRecord(); } public UCOperationGoodsBill(ApplianceRecord Applic) { InitializeComponent(); if (Applic == null) Applic = new ApplianceRecord(); app = Applic; this.Id = app.Id; this.OperationRecordId = Convert.ToInt32(app.OperationRecordId); if (app.OpeFront != null) this.OpeFront = app.OpeFront; if (app.OpeDoing != null) this.OpeDoing = app.OpeDoing; if (app.CloseFront != null) this.CloseFront = app.CloseFront; if (app.CloseLast != null) this.CloseLast = app.CloseLast; //if (app.SkinCloseLast != null) // this.SkinCloseLast = app.SkinCloseLast; txtFront.TextChanged += txtFront_TextChanged; txtDoing.TextChanged += txtFront_TextChanged; } public ApplianceRecord app; private int? id;//清点单编号 private int operationRecordId;//手术记录编号 private int goodsId;//物品编号 private string goodsName;//器械名称 private string opeFront;//术前清点 private string opeDoing;//术中增加 private string closeFront;//关闭腔体前 private string closeLast;//关闭腔体后 //private string skinCloseLast;//缝皮腔体后 private string goodsNumber;//器械数量 private Color ucBackColor; public int? Id { get { return id; } set { id = value; } } public int OperationRecordId { get { return operationRecordId; } set { operationRecordId = value; } } public int GoodsId { get { return goodsId; } set { goodsId = value; } } public string GoodsName { get { goodsName = this.lblGoodsName.Text; return goodsName; } set { goodsName = value; this.lblGoodsName.Text = goodsName; } } public string GoodsNumber { get { // goodsNumber = this.txtPack.Text; //goodsNumber = this.txtDoing.Text; //goodsNumber = this.txtCloseFront.Text; //goodsNumber = this.txtCloseLast.Text; //goodsNumber = this.txtSkinCloseLast.Text; return goodsNumber; } set { goodsNumber = value; this.txtDoing.Text = "0"; if (goodsNumber != "") { this.txtFront.Text = goodsNumber; this.txtCloseFront.Text = goodsNumber; this.txtCloseLast.Text = goodsNumber; } } } public string OpeFront { get { if (this.txtFront.Text != "") opeFront = this.txtFront.Text; return opeFront; } set { opeFront = value; this.txtFront.Text = opeFront.ToString(); } } public string OpeDoing { get { if (this.txtDoing.Text != "") opeDoing = this.txtDoing.Text; return opeDoing; } set { opeDoing = value; this.txtDoing.Text = opeDoing.ToString(); } } public string CloseFront { get { if (this.txtCloseFront.Text != "") closeFront = this.txtCloseFront.Text; return closeFront; } set { closeFront = value; this.txtCloseFront.Text = closeFront.ToString(); } } public string CloseLast { get { if (this.txtCloseLast.Text != "") closeLast = this.txtCloseLast.Text; return closeLast; } set { closeLast = value; this.txtCloseLast.Text = closeLast.ToString(); } } //public string SkinCloseLast //{ // get // { // if (this.txtSkinCloseLast.Text != "") // skinCloseLast = this.txtSkinCloseLast.Text; // return skinCloseLast; // } // set // { // skinCloseLast = value; // this.txtSkinCloseLast.Text = skinCloseLast.ToString(); // } //} public Color UcBackColor { get { ucBackColor = this.BackColor; return ucBackColor; } set { ucBackColor = value; this.BackColor = ucBackColor; } } private string GetString(string str) { if (str == @"\") { return str; } else { char[] a = new char[] { '+', '-' }; str = str.TrimStart(a).TrimEnd(a); object result = new DataTable().Compute(str, null); return result.ToString(); } } private void CalcResult() { if (this.GoodsName == "") return; this.OpeFront = this.txtFront.Text; this.OpeDoing = this.txtDoing.Text; this.CloseFront = this.txtCloseFront.Text; this.CloseLast = this.txtCloseLast.Text; //this.SkinCloseLast = this.txtSkinCloseLast.Text; app.Id = this.Id; app.OperationRecordId = this.OperationRecordId; //if (this.GoodsId != 0) app.ApplianceId = this.GoodsId; else app.ApplianceId = null; app.ApplianceId = this.GoodsId; app.ApplianceName = this.GoodsName; app.OpeFront = this.OpeFront; app.OpeDoing = this.OpeDoing; app.CloseFront = this.CloseFront; app.CloseLast = this.CloseLast; // app.SkinCloseLast = this.SkinCloseLast; if (app.Id == null) { this.Id = BApplianceRecord.Insert(app); } else { BApplianceRecord.Update(app); } } private void txt_Leave(object sender, EventArgs e) { ((TextBox)sender).Text = GetString(((TextBox)sender).Text); //CalcResult(); } private void txt_Leave1(object sender, EventArgs e) { TextBox txb = ((TextBox)sender); txb.Text = GetString(txb.Text); //if (this.txtFront.Text != "" && this.txtDoing.Text != "") //{ // int Front = int.Parse(this.txtDoing.Text); // int Doing = int.Parse(this.txtDoing.Text); // if (txb.Text != (Front + Doing).ToString()) // { // txb.Text = ""; // MessageBox.Show("核对数量错误!请再次确认!", "系统提示"); // return; // } //} CalcResult(); } private void txtFront_TextChanged(object sender, EventArgs e) { try { string result = ""; if (txtFront.Text.Trim() != "" && txtFront.Text.Trim() != "\\") { int a = int.Parse(txtFront.Text); result = (a).ToString(); } if (txtDoing.Text.Trim() != "" && txtDoing.Text.Trim() != "\\") { int b = int.Parse(txtDoing.Text); result = (b).ToString(); } if (txtFront.Text.Trim() != "" && txtDoing.Text.Trim() != "" && txtDoing.Text.Trim() != "\\" && txtFront.Text.Trim() != "\\") { int a = int.Parse(txtFront.Text); int b = int.Parse(txtDoing.Text); result = (a + b).ToString(); } this.txtCloseFront.Text = result; this.txtCloseLast.Text = result; //this.txtSkinCloseLast.Text = result; } catch (Exception ) { // string TextValue = @"\"; //if (((TextBox)sender).Text != TextValue) //{ // this.txtCloseFront.Text = TextValue; // this.txtCloseLast.Text = TextValue; // //this.txtSkinCloseLast.Text = ""; //} } } private void UCOperationGoodsBill_Load(object sender, EventArgs e) { } private void TxtCloseFront_TextChanged(object sender, EventArgs e) { try { TextBox textBox = (TextBox)sender; string result = ""; if (txtFront.Text.Trim() != "" && txtFront.Text.Trim() != "\\") { int a = int.Parse(txtFront.Text); result = (a).ToString(); } if (txtDoing.Text.Trim() != "" && txtDoing.Text.Trim() != "\\") { int b = int.Parse(txtDoing.Text); result = (b).ToString(); } if (txtFront.Text.Trim() != "" && txtDoing.Text.Trim() != "" && txtDoing.Text.Trim() != "\\" && txtFront.Text.Trim() != "\\") { int a = int.Parse(txtFront.Text); int b = int.Parse(txtDoing.Text); result = (a + b).ToString(); } if (result != "" && textBox.Text != "" && textBox.Text != "\\") { int txtVal = int.Parse(textBox.Text); if (txtVal != int.Parse(result)) { MessageBox.Show("请核对数量!", "系统提示"); } } } catch (Exception) { } } private void txtFront_KeyDown(object sender, KeyEventArgs e) { SelectTextBoxEvent(sender, e); } } }