Exemplo n.º 1
0
        private void TextKeyUp(object sender, KeyEventArgs e)        //KeyEventArgs
        {
            int     nkey    = Convert.ToInt32(e.KeyCode);
            Control control = (Control)sender;

            if (control.Text.Trim() == "")
            {
                control.Text = ""; control.Tag = "0";
            }

            if ((nkey >= 65 && nkey <= 90) || (nkey >= 48 && nkey <= 57) || (nkey >= 96 && nkey <= 105) || nkey == 8 || nkey == 32 || nkey == 46 || (nkey == 13 && (Convert.ToString(control.Tag) == "0" || Convert.ToString(control.Tag) == "")))
            {
            }
            else
            {
                return;
            }

            try
            {
                string[] GrdMappingName;
                int[]    GrdWidth;
                string[] sfield;
                string   ssql = "";
                DataRow  row;

                Point point = new Point(this.Location.X + control.Location.X, this.Location.Y + control.Location.Y + control.Height * 3);
                switch (control.TabIndex)
                {
                case 0:
                    if (control.Text.Trim() == "")
                    {
                        return;
                    }
                    GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "单位", "货号" };
                    GrdWidth       = new int[] { 0, 0, 30, 150, 100, 40, 60 };
                    sfield         = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" };
                    ssql           = "select a.ggid,cjid,0 rowno,s_ypspm,s_ypgg,s_ypdw,shh from yp_ypcjd a,yp_ypbm b " +
                                     " where a.ggid=b.ggid and a.bdelete=0 and n_ypzlx in(2,4,6) ";                   //and a.n_ypzlx in(select ypzlx from yp_gllx where deptid="+InstanceForm.BCurrentDept.DeptId+")  ";
                    TrasenFrame.Forms.Fshowcard f2 = new TrasenFrame.Forms.Fshowcard(GrdMappingName, GrdWidth, sfield, Constant.CustomFilterType, control.Text.Trim(), ssql);
                    f2.Location = point;
                    f2.Width    = 700;
                    f2.Height   = 300;
                    f2.Text     = "选择自制药品";
                    f2.ShowDialog(this);
                    row = f2.dataRow;
                    if (row != null)
                    {
                        this.txtzzypmc.Text = row["s_ypspm"].ToString();
                        this.txtzzypmc.Tag  = row["cjid"].ToString().Trim();
                        this.SelectNextControl((Control)sender, true, false, true, true);
                    }
                    break;

                case 2:
                    if (control.Text.Trim() == "")
                    {
                        return;
                    }
                    GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "单位", "货号" };
                    GrdWidth       = new int[] { 0, 0, 30, 150, 100, 40, 60 };
                    sfield         = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" };
                    ssql           = "select a.ggid,cjid,0 rowno,s_ypspm,s_ypgg,s_ypdw,shh from yp_ypcjd a,yp_ypbm b " +
                                     " where a.ggid=b.ggid and a.bdelete=0 and a.n_ypzlx in(select ypzlx from yp_gllx where deptid=" + InstanceForm.BCurrentDept.DeptId + ")  ";
                    TrasenFrame.Forms.Fshowcard f3 = new TrasenFrame.Forms.Fshowcard(GrdMappingName, GrdWidth, sfield, Constant.CustomFilterType, control.Text.Trim(), ssql);
                    f3.Location = point;
                    f3.Width    = 700;
                    f3.Height   = 300;
                    f3.Text     = "选择原料";
                    f3.ShowDialog(this);
                    row = f3.dataRow;
                    if (row != null)
                    {
                        this.txtylmc.Text = row["s_ypspm"].ToString();
                        this.txtylmc.Tag  = row["cjid"].ToString().Trim();
                        DataTable tb = Yp.SelectYpcl(InstanceForm.BCurrentDept.DeptId, Convert.ToInt32(row["cjid"]), InstanceForm.BDatabase);
                        if (tb.Rows.Count == 0)
                        {
                            lbldw.Text = row["S_YPDW"].ToString().Trim();
                            lbldw.Tag  = "1";
                        }
                        else
                        {
                            lbldw.Text = Yp.SeekYpdw(Convert.ToInt32(tb.Rows[0]["zxdw"]), InstanceForm.BDatabase);
                            lbldw.Tag  = tb.Rows[0]["dwbl"].ToString();
                        }

                        this.SelectNextControl((Control)sender, true, false, true, true);
                    }
                    break;
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show("发生错误" + err.Message);
            }
        }