Exemplo n.º 1
0
        private void FrmFYConfirm_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            //科室
            DataTable deptTb = InstanceForm.BDatabase.GetDataTable(@"select * from (
                select t1.DEPT_ID,t1.NAME from JC_DEPT_DRUGSTORE t inner join
                JC_DEPT_PROPERTY t1 on t.DRUGSTORE_ID=t1.DEPT_ID where t.DELETE_BIT=0 and t1.DELETED=0)v group by v.DEPT_ID,v.NAME");

            if (deptTb == null)
            {
                MessageBox.Show("错误,未能取得药房信息!", "提示");
            }
            DataRow rowKs = deptTb.NewRow();

            rowKs["DEPT_ID"] = -1;
            rowKs["NAME"]    = "请选择";
            deptTb.Rows.Add(rowKs);
            comboBox1.DataSource    = deptTb;
            comboBox1.DisplayMember = "NAME";
            comboBox1.ValueMember   = "DEPT_ID";
            comboBox1.SelectedValue = -1;

            enable_load();

            this.dataGridView1.DataSource = ZcyBill.getDtFy();
        }
Exemplo n.º 2
0
        public void enable_load()
        {
            this.dataGridView1.DataSource = ZcyBill.getDtFy();
            if (ZcyBill.Isfy("02") == 2)
            {
                this.buttConfirmTL.Enabled = false;
                this.buttCancelTL.Enabled  = true;
            }
            else
            {
                this.buttCancelTL.Enabled  = false;
                this.buttConfirmTL.Enabled = true;
            }

            if (ZcyBill.Isfy("01") == 2)
            {
                this.buttConfirmBY.Enabled = false;
                this.buttCancelBY.Enabled  = true;
            }
            else
            {
                this.buttCancelBY.Enabled  = false;
                this.buttConfirmBY.Enabled = true;
            }
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                decimal j = 0;

                DataTable tb = (DataTable)this.dataGridView1.DataSource;
                this.BindingContext[tb].EndCurrentEdit();
                DataRow[] _rows = tb.Select("选择=1");
                if (_rows.Length == 0)
                {
                    MessageBox.Show("没有选择任何行");
                    return;
                }
                DataTable XyfHy = null;//向药房hauan药
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    if (tb.Rows[i]["还药数量"].ToString() == "" || tb.Rows[i]["选择"].ToString() == "0")
                    {
                        continue;
                    }
                    if (int.Parse(tb.Rows[i]["还药数量"].ToString()) > 0)
                    {
                        //获得表结果
                        DataSet dset = ZcyBill.GetFsypxx(int.Parse(tb.Rows[i]["cjid"].ToString()), InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId
                                                         , InstanceForm.BCurrentDept.WardId, int.Parse(cmbzxks.SelectedValue.ToString()),
                                                         (long)(0), long.Parse("1"), ref j);
                        if (XyfHy == null)
                        {
                            XyfHy = dset.Tables[1].Clone();
                        }
                        if (dset.Tables[1].Rows.Count > 0)
                        {
                            //每次都是一条记录
                            dset.Tables[1].Rows[0]["单位"]      = tb.Rows[i]["单位"];
                            dset.Tables[1].Rows[0]["DWBL"]    = tb.Rows[i]["DWBL"];
                            dset.Tables[1].Rows[0]["dwbl"]    = tb.Rows[i]["xdwbl"];//现在的单位比例
                            dset.Tables[1].Rows[0]["zxdw"]    = tb.Rows[i]["xzxdw"];
                            dset.Tables[1].Rows[0]["单价"]      = tb.Rows[i]["lsj"];
                            dset.Tables[1].Rows[0]["zcykcid"] = tb.Rows[i]["id"].ToString();
                            dset.Tables[1].Rows[0]["数量"]      = tb.Rows[i]["还药数量"].ToString();
                        }
                        XyfHy.Merge(dset.Tables[1]);
                    }
                }
                ZcyBill.Scjydj(XyfHy, 4, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId
                               , int.Parse(this.cmbzxks.SelectedValue.ToString()));
                this.FrmZcyGl_Load(null, null);
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void button5_Click(object sender, EventArgs e)
        {
            this.dataGridView2.Visible = true;
            int       deptly = InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId;
            int       shzt   = checkBox1.Checked?1:0;
            int       ywlx   = this.radioButton1.Checked?3:4;
            string    time1  = this.dateTimePicker1.Value.ToShortDateString();
            string    time2  = this.dateTimePicker2.Value.AddDays(1).ToShortDateString();
            DataTable tb     = ZcyBill.SelecDj(shzt, ywlx, time1, time2, int.Parse(this.cmbzxks.SelectedValue.ToString()), deptly);

            this.dataGridView2.AutoGenerateColumns = true;
            this.dataGridView2.DataSource          = tb;
            this.dataGridView2.Columns[this.dataGridView2.Columns.Count - 1].Visible = false;
            this.dataGridView2.Columns[this.dataGridView2.Columns.Count - 2].Visible = false;
        }
Exemplo n.º 5
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (this.dataGridView2.CurrentCell == null)
            {
                return;
            }
            int     curindex = this.dataGridView2.CurrentCell.RowIndex;
            string  id       = this.dataGridView2.Rows[curindex].Cells["id"].Value.ToString();
            int     ywlx     = this.radioButton1.Checked ? 3 : 4;
            string  kcid     = this.dataGridView2.Rows[curindex].Cells["kcid"].Value.ToString();
            decimal sl       = decimal.Parse(this.dataGridView2.Rows[curindex].Cells["数量"].Value.ToString());
            int     ydwbl    = int.Parse(this.dataGridView2.Rows[curindex].Cells["单位比例"].Value.ToString());

            ZcyBill.QxDj(id, ywlx, kcid, sl, ydwbl);
            button5_Click(null, null);
        }
Exemplo n.º 6
0
 private void buttCancelBY_Click(object sender, EventArgs e)
 {
     if (GetYZ())
     {
         int i = ZcyBill.UpdateFYConfig(0, "01", Convert.ToInt32(this.comboBox1.SelectedValue));
         if (i == 0)
         {
             MessageBox.Show("没有找到'" + comboBox1.GetItemText(comboBox1.Items[comboBox1.SelectedIndex]) + "'取消失败");
         }
         else
         {
             ZcyBill.InsertFYConfiglog("01", Convert.ToInt32(this.comboBox1.SelectedValue), this.buttCancelBY.Text.Trim());
             enable_load();
         }
     }
 }
Exemplo n.º 7
0
 private void buttConfirmBY_Click(object sender, EventArgs e)
 {
     if (GetYZ())
     {
         if (ZcyBill.Isfy("01") == 0)
         {
             ZcyBill.InsertFYConfig(1, "01", Convert.ToInt32(this.comboBox1.SelectedValue));
         }
         else if (ZcyBill.Isfy("01") == 1 || ZcyBill.Isfy("01") == 2)
         {
             ZcyBill.UpdateFYConfigDept(1, "01", Convert.ToInt32(this.comboBox1.SelectedValue));
         }
         ZcyBill.InsertFYConfiglog("01", Convert.ToInt32(this.comboBox1.SelectedValue), this.buttConfirmBY.Text.Trim());
         enable_load();
     }
 }
Exemplo n.º 8
0
 private void button10_Click(object sender, EventArgs e)
 {
     try
     {
         this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
         DataTable tb = (DataTable)this.dataGridView1.DataSource;
         for (int i = 0; i < tb.Rows.Count; i++)
         {
             tb.Rows[i]["zcjs"] = tb.Rows[i]["暂存基数"];
         }
         tb.Rows[tb.Rows.Count - 1].AcceptChanges();
         ZcyBill.Databaseupdate("select * from Zy_ZcyKcmx where 1=2", (DataTable)this.dataGridView1.DataSource);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 9
0
        public FrmZcyGl()
        {
            InitializeComponent();
            this.cmbzxks.ValueMember = "";
            string    sSql = "";
            DataTable yfTb = ZcyBill.Getzxks();

            if (yfTb == null || yfTb.Rows.Count == 0)
            {
                return;
            }
            cmbzxks.DisplayMember = "KSMC";
            cmbzxks.ValueMember   = "DEPTID";
            cmbzxks.DataSource    = yfTb;
            this.dataGridView1.AutoGenerateColumns = false;
            this.cmbzxks.SelectedValueChanged     += new EventHandler(cmbzxks_SelectedValueChanged);
            this.checkBox1.CheckedChanged         += new EventHandler(checkBox1_CheckedChanged);
            this.radioButton1.CheckedChanged      += new EventHandler(radioButton1_CheckedChanged);
        }
Exemplo n.º 10
0
        public void FrmZcyGl_Load(object sender, EventArgs e)
        {
            this.dataGridView1.DataSource = ZcyBill.GetZcyCk(InstanceForm.BCurrentDept.WardDeptId, int.Parse(this.cmbzxks.SelectedValue.ToString()));
            DataTable tb = (DataTable)this.dataGridView1.DataSource;
            //增加一行合计
            DataRow r    = tb.NewRow();
            decimal hjje = 0;

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                hjje += decimal.Parse(tb.Rows[i]["金额"].ToString());
            }
            r["药品品名"] = "合计";
            r["金额"]   = hjje;
            tb.Rows.Add(r);
            this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Yellow;
            this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.Font      = new  System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue;
            this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].ReadOnly = true;
        }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime date1 = DateTime.Parse(this.dateTimePicker1.Value.ToShortDateString() + "  00:00:00");
            DateTime date2 = DateTime.Parse(this.dateTimePicker2.Value.AddDays(1).ToShortDateString() + "  00:00:00");

            if (暂存药品上传 == wizard1.SelectedPage)
            {
                DataTable tmpable;
                DataTable Yptable = null;

                DataTable tbyf = (DataTable)this.cmbZxyf.DataSource;
                if (this.cmbZxyf.SelectedValue.ToString() == "-1")
                {
                    for (int i = 1; i < tbyf.Rows.Count; i++)
                    {
                        tmpable = ZcyBill.ZYHS_YPFY_SELECT(9, 0, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId, InstanceForm.BCurrentDept.WardId, Guid.Empty, 0, Convert.ToInt32(tbyf.Rows[i]["DEPTID"].ToString())
                                                           , date1, date2);

                        if (Yptable == null)
                        {
                            Yptable = tmpable.Clone();
                        }
                        for (int j = 0; j < tmpable.Rows.Count; j++)
                        {
                            Yptable.ImportRow(tmpable.Rows[j]);
                        }
                        tmpable = ZcyBill.ZYHS_YPFY_SELECT(9, 1, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId, InstanceForm.BCurrentDept.WardId, Guid.Empty, 0, Convert.ToInt32(tbyf.Rows[i]["DEPTID"].ToString())
                                                           , date1, date2);
                        for (int j = 0; j < tmpable.Rows.Count; j++)
                        {
                            Yptable.ImportRow(tmpable.Rows[j]);
                        }
                    }
                }
                else
                {
                    tmpable = ZcyBill.ZYHS_YPFY_SELECT(9, 0, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId, InstanceForm.BCurrentDept.WardId, Guid.Empty, 0, Convert.ToInt32(this.cmbZxyf.SelectedValue.ToString())
                                                       , date1, date2);

                    if (Yptable == null)
                    {
                        Yptable = tmpable.Clone();
                    }
                    for (int j = 0; j < tmpable.Rows.Count; j++)
                    {
                        Yptable.ImportRow(tmpable.Rows[j]);
                    }
                    tmpable = ZcyBill.ZYHS_YPFY_SELECT(9, 1, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId, InstanceForm.BCurrentDept.WardId, Guid.Empty, 0, Convert.ToInt32(this.cmbZxyf.SelectedValue.ToString())
                                                       , date1, date2);
                    for (int j = 0; j < tmpable.Rows.Count; j++)
                    {
                        Yptable.ImportRow(tmpable.Rows[j]);
                    }
                }

                FunBase.AddRowtNo(Yptable);
                this.dataGridView1.DataSource = Yptable;
                for (int j = 14; j < this.dataGridView1.Columns.Count; j++)
                {
                    this.dataGridView1.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable;
                    if (j >= 14)
                    {
                        this.dataGridView1.Columns[j].Visible = false;
                    }
                    else
                    {
                        this.dataGridView1.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable;
                    }
                }
                this.dataGridView1.Columns["数量"].DefaultCellStyle.BackColor = Color.WhiteSmoke;
                this.dataGridView1.Columns["数量"].DefaultCellStyle.ForeColor = Color.Blue;
                this.dataGridView1.ReadOnly = true;
                //增加一行合计
                DataRow r    = Yptable.NewRow();
                decimal hjje = 0;
                for (int i = 0; i < Yptable.Rows.Count; i++)
                {
                    hjje += decimal.Parse(Yptable.Rows[i]["金额"].ToString());
                }
                r["类型"] = "合计";
                r["金额"] = hjje;
                Yptable.Rows.Add(r);
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Yellow;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.Font      = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].ReadOnly = true;
            }
            else
            {
                int ls = 9990;
                this.dataGridView2.DataSource = ZcyBill.Getzcysjjl(date1, date2, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId);
                for (int j = 0; j < this.dataGridView2.Columns.Count; j++)
                {
                    this.dataGridView2.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable;
                    if (this.dataGridView2.Columns[j].Name.Trim() == "cjid")
                    {
                        ls = j;
                    }
                    if (j >= ls)
                    {
                        this.dataGridView2.Columns[j].Visible = false;
                    }
                }
            }
        }
Exemplo n.º 12
0
 public FrmXzyp(int zxksid)
 {
     InitializeComponent();
     tbyp    = ZcyBill.Getyptb(zxksid, InstanceForm.BCurrentDept.WardDeptId.ToString());
     _zxksid = zxksid;
 }
Exemplo n.º 13
0
        private void button2_Click(object sender, EventArgs e)
        {
            Cursor.Current = PubStaticFun.WaitCursor();
            DataTable myTb = (DataTable)this.dataGridView1.DataSource;

            if (myTb == null || myTb != null && myTb.Rows.Count < 1)
            {
                MessageBox.Show(this, "没有数据,不能打印", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            rds.Tables["MedYPMXD"].Clear();

            DataRow dr;
            int     flag = 0;

            for (int j = 0; j < myTb.Rows.Count; j++)
            {
                if (myTb.Rows[j]["selected"].ToString() == "1")
                {
                    flag++;
                    dr                 = rds.Tables["MedYPMXD"].NewRow();
                    dr["选"]            = false;
                    dr["床号"]           = myTb.Rows[j]["BED_NO"].ToString();
                    dr["住院号"]          = myTb.Rows[j]["INPATIENT_NO"].ToString();
                    dr["姓名"]           = myTb.Rows[j]["NAME"].ToString();
                    dr["日期"]           = Convert.ToDateTime(myTb.Rows[j]["presc_date"]).Month.ToString() + "-" + Convert.ToDateTime(myTb.Rows[j]["presc_date"]).Day.ToString();
                    dr["编号"]           = myTb.Rows[j]["SUBCODE"].ToString();
                    dr["名称"]           = myTb.Rows[j]["S_YPSPM"].ToString();
                    dr["规格"]           = myTb.Rows[j]["S_YPGG"].ToString();
                    dr["数量"]           = Convert.ToDouble(myTb.Rows[j]["NUM"]);
                    dr["单位"]           = myTb.Rows[j]["UNIT"].ToString();
                    dr["剂型"]           = myTb.Rows[j]["YPJX"].ToString();//剂型
                    dr["单价"]           = Convert.ToDouble(myTb.Rows[j]["RETAIL_PRICE"]);
                    dr["金额"]           = Convert.ToDouble(myTb.Rows[j]["ACVALUE"]);
                    dr["麻毒否"]          = myTb.Rows[j]["MZYP"].ToString();
                    dr["贵重否"]          = myTb.Rows[j]["GZYP"].ToString();
                    dr["id"]           = j.ToString();
                    dr["baby_id"]      = myTb.Rows[j]["baby_id"].ToString();
                    dr["INPATIENT_ID"] = myTb.Rows[j]["INPATIENT_ID"].ToString();
                    dr["fee_id"]       = myTb.Rows[j]["fee_id"].ToString();
                    dr["xmid"]         = myTb.Rows[j]["xmid"].ToString();
                    dr["TLFL"]         = myTb.Rows[j]["TLFL"].ToString();
                    rds.Tables["MedYPMXD"].Rows.Add(dr);

                    if (this.rb_y.Checked)
                    {
                        ZcyBill.InsertYPQDQRLOG(new Guid(myTb.Rows[j]["INPATIENT_ID"].ToString()), new Guid(myTb.Rows[j]["fee_id"].ToString()));
                    }
                    else if (this.rb_n.Checked)
                    {
                        DataRow drr = InstanceForm.BDatabase.GetDataRow("select pcount from ZY_YPQDQRLOG where id='" + new Guid(myTb.Rows[j]["log_id"].ToString()) + "'");
                        if (drr != null)
                        {
                            int pcount = Convert.ToInt32(drr["pcount"].ToString());
                            pcount++;
                            ZcyBill.UpdateYPQDQRLOG(new Guid(myTb.Rows[j]["log_id"].ToString()), pcount);
                        }
                    }
                }
            }
            Cursor.Current = Cursors.Default;

            FrmReportView frmReport = null;

            ParameterEx[] _parameters = new ParameterEx[2];

            _parameters[0].Text  = "tTitle";
            _parameters[0].Value = "发药确认卡";
            _parameters[1].Text  = "tUser";
            _parameters[1].Value = "打印者:" + InstanceForm.BCurrentUser.Name;

            if (flag > 0)
            {
                frmReport = new FrmReportView(rds, Constant.ApplicationDirectory + "\\report\\ZYHS_发药确认卡.rpt", _parameters);
                frmReport.Show();
            }
            Bingdate();
        }
Exemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable tb = (DataTable)this.dataGridView1.DataSource;
                this.BindingContext[tb].EndCurrentEdit();
                DataRow[] _rows = tb.Select("选择=1");
                if (_rows.Length == 0)
                {
                    MessageBox.Show("没有选择任何行");
                    return;
                }
                decimal   j     = 0;
                DataTable fyyf  = null;; //发送到药房
                DataTable Xyfjy = null;  //向药房借药
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    if (Xyfjy != null)
                    {
                        Xyfjy.Clear();
                    }
                    if (Xyfjy != null)
                    {
                        fyyf.Clear();
                    }
                    if (tb.Rows[i]["请求数量"].ToString() == "" || tb.Rows[i]["选择"].ToString() == "0")
                    {
                        continue;
                    }
                    if (int.Parse(tb.Rows[i]["请求数量"].ToString()) > 0)
                    {
                        DataSet dset = ZcyBill.GetFsypxx(int.Parse(tb.Rows[i]["cjid"].ToString()), InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId
                                                         , InstanceForm.BCurrentDept.WardId, int.Parse(cmbzxks.SelectedValue.ToString()),
                                                         (long)(decimal.Parse(tb.Rows[i]["暂存数量"].ToString())), long.Parse(tb.Rows[i]["请求数量"].ToString()), ref j);
                        if (fyyf == null)
                        {
                            fyyf = dset.Tables[0].Clone();
                        }
                        if (dset.Tables[1].Rows.Count > 0)
                        {
                            //每次都是一条记录
                            dset.Tables[1].Rows[0]["单位"]      = tb.Rows[i]["单位"];
                            dset.Tables[1].Rows[0]["DWBL"]    = tb.Rows[i]["DWBL"];
                            dset.Tables[1].Rows[0]["dwbl"]    = tb.Rows[i]["xdwbl"];//现在的单位比例
                            dset.Tables[1].Rows[0]["zxdw"]    = tb.Rows[i]["xzxdw"];
                            dset.Tables[1].Rows[0]["单价"]      = tb.Rows[i]["lsj"];
                            dset.Tables[1].Rows[0]["zcykcid"] = tb.Rows[i]["id"].ToString();
                        }
                        if (Xyfjy == null)
                        {
                            Xyfjy = dset.Tables[1].Clone();
                        }
                        fyyf.Merge(dset.Tables[0]);
                        Xyfjy.Merge(dset.Tables[1]);

                        ZcyBill.Scjydj(Xyfjy, 3, InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId
                                       , int.Parse(this.cmbzxks.SelectedValue.ToString()));
                        baseFun.SendYPzcgl(fyyf, FrmMdiMain.CurrentDept.WardId, FrmMdiMain.CurrentUser.EmployeeId, DateManager.ServerDateTimeByDBType(FrmMdiMain.Database), Convert.ToInt64(cmbzxks.SelectedValue.ToString()), 0, FrmMdiMain.Jgbm);
                    }
                }
                this.FrmZcyGl_Load(null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 15
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // return;
            DataTable tb = (DataTable)this.dataGridView1.DataSource;

            if (e.RowIndex < 0)
            {
                return;
            }
            if (this.dataGridView1.Columns[e.ColumnIndex].Name == "还药数量")
            {
                decimal zcsl = 0;
                try
                {
                    if (this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value.ToString() == "")
                    {
                        return;
                    }
                    zcsl = decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value.ToString());
                    if (zcsl <= 0)
                    {
                        throw new Exception("ddd");
                    }
                }
                catch
                {
                    //this.dataGridView1.EndEdit();

                    this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value = DBNull.Value;
                    this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                    MessageBox.Show(" 请输入大于零的整数");
                    return;
                }
                //医院不需要控制
                //if (decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["暂存数量"].Value.ToString()) >= 0)
                //{

                //    MessageBox.Show("只有暂存数量小于0时,才可以还药");

                //    this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value = DBNull.Value;
                //    this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                //  //  this.dataGridView1.EndEdit();
                //    return;
                //}
                //else
                //    if (Math.Abs(decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["暂存数量"].Value.ToString())) <
                //       decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value.ToString())
                //        )
                //    {

                //        MessageBox.Show("您输入的数字过大,最多只能输入" + Math.Abs(decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["暂存数量"].Value.ToString())));

                //        this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value = DBNull.Value;
                //        this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                //      //  this.dataGridView1.EndEdit();
                //        return;
                //    }
            }
            if (this.dataGridView1.Columns[e.ColumnIndex].Name == "借药数量")
            {
                decimal zcsl = 0;
                try
                {
                    if (this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value.ToString() == "")
                    {
                        return;
                    }
                    zcsl = decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value.ToString());
                    if (zcsl <= 0)
                    {
                        throw new Exception("ddd");
                    }
                }
                catch
                {
                    //this.dataGridView1.EndEdit();

                    this.dataGridView1.Rows[e.RowIndex].Cells["还药数量"].Value = DBNull.Value;
                    this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                    MessageBox.Show(" 请输入大于零的整数");
                    return;
                }
            }
            if (this.dataGridView1.Columns[e.ColumnIndex].Name == "请求数量")
            {
                decimal zcsl = 0;
                try
                {
                    if (this.dataGridView1.Rows[e.RowIndex].Cells["请求数量"].Value.ToString() == "")
                    {
                        return;
                    }
                    zcsl = decimal.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["请求数量"].Value.ToString());
                    //if (zcsl <= 0)
                    //    throw new Exception("ddd");
                    if (zcsl < 0)//请求数量小于0时,表示是发送负数的
                    {
                    }
                    decimal j = 0;
                    //如果暂存数量大于等于请求数量,就取实际的数量
                    //if ((long)(decimal.Parse(tb.Rows[e.RowIndex]["暂存数量"].ToString())) >= long.Parse(tb.Rows[e.RowIndex]["请求数量"].ToString())
                    //    && (long)(decimal.Parse(tb.Rows[e.RowIndex]["暂存数量"].ToString())) >= 0)
                    {
                        DataSet dset = ZcyBill.GetFsypxx_new(int.Parse(tb.Rows[e.RowIndex]["cjid"].ToString()), InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId
                                                             , InstanceForm.BCurrentDept.WardId, int.Parse(cmbzxks.SelectedValue.ToString()),
                                                             (long)(decimal.Parse(tb.Rows[e.RowIndex]["暂存数量"].ToString())), long.Parse(tb.Rows[e.RowIndex]["请求数量"].ToString()), ref j);
                        this.dataGridView1.CellValueChanged -= new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
                        this.dataGridView1.Rows[e.RowIndex].Cells["请求数量"].Value = j;

                        this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                        this.dataGridView1.EndEdit();
                        this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged);
                    }
                }
                catch
                {
                    MessageBox.Show(" 请输入大于零的整数");
                    this.dataGridView1.Rows[e.RowIndex].Cells["请求数量"].Value = DBNull.Value;
                    this.BindingContext[(DataTable)this.dataGridView1.DataSource].EndCurrentEdit();
                    return;
                }
            }
        }