private void CshHzGrid(TrasenClasses.GeneralControls.DataGridEx xcjwDataGrid) { #region 添加汇总的列 List <ColumnDefine> columns = new List <ColumnDefine>(); columns.Add(PubClass.NewColumnDefine("序号", "序号", 35, true, 0)); columns.Add(PubClass.NewColumnDefine("剂型", "剂型", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("品名", "品名", 150, true, 0)); columns.Add(PubClass.NewColumnDefine("商品名", "商品名", 150, true, 0)); columns.Add(PubClass.NewColumnDefine("规格", "规格", 100, true, 0)); columns.Add(PubClass.NewColumnDefine("厂家", "厂家", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("单价", "单价", 65, true, 0)); //columns.Add(PubClass.NewColumnDefine("库存数", "库存数", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("领药数", "领药数", 65, true, 0)); columns.Add(PubClass.NewColumnDefine("缺药数", "缺药数", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("单位", "单位", 40, true, 0)); columns.Add(PubClass.NewColumnDefine("药库单位", "药库单位", 75, true, 0)); columns.Add(PubClass.NewColumnDefine("金额", "金额", 75, true, 0)); columns.Add(PubClass.NewColumnDefine("货号", "货号", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("cjid", "cjid", 0, true, 0)); columns.Add(PubClass.NewColumnDefine("dwbl", "dwbl", 0, true, 0)); //columns.Add(PubClass.NewColumnDefine("领药科室", "领药科室", 0, true, 0)); DataTable dtTmp = new DataTable(); dtTmp.TableName = "tbhz"; int index = 0; foreach (ColumnDefine cd in columns) { DataGridEnableTextBoxColumn colText = new DataGridEnableTextBoxColumn(index); colText.HeaderText = cd.HeaderText; colText.MappingName = cd.MappingName; colText.Width = cd.ColWidth; colText.NullText = ""; colText.ReadOnly = cd.ColReadOnly; colText.CheckCellEnabled += new TrasenClasses.GeneralControls.DataGridEnableTextBoxColumn.EnableCellEventHandler(myDataGrid2_CheckCellEnabled); xcjwDataGrid.TableStyles[0].GridColumnStyles.Add(colText); DataColumn datacol; if (cd.MappingName.Trim() == "ypsl" || cd.MappingName == "金额") { datacol = new DataColumn(cd.MappingName, Type.GetType("System.Decimal")); } else { datacol = new DataColumn(cd.MappingName); } dtTmp.Columns.Add(datacol); index++; } xcjwDataGrid.DataSource = dtTmp; xcjwDataGrid.TableStyles[0].MappingName = "tbhz"; #endregion }
private void Frmmxcx_Load(object sender, System.EventArgs e) { for (int i = 0; i <= panel2.Controls.Count - 1; i++) { if (panel2.Controls[i].GetType().ToString() == "TrasenClasses.GeneralControls.DataGridEx") { TrasenClasses.GeneralControls.DataGridEx mydatagrid = (TrasenClasses.GeneralControls.DataGridEx)panel2.Controls[i]; mydatagrid.MouseClick -= new MouseEventHandler(mydatagrid_MouseClick); //add by zouchihua 2012-3-10 mydatagrid.MouseClick += new MouseEventHandler(mydatagrid_MouseClick); //add by zouchihua 2012-3-10 //PublicStaticFun.ModifyDataGridStyle(mydatagrid,0); PubStaticFun.ModifyDataGridStyle(mydatagrid, 0); } } }
private void SelectAll(short _value) { for (int i = 0; i <= panel2.Controls.Count - 1; i++) { if (panel2.Controls[i].GetType().ToString() == "TrasenClasses.GeneralControls.DataGridEx") { TrasenClasses.GeneralControls.DataGridEx mydatagrid = (TrasenClasses.GeneralControls.DataGridEx)panel2.Controls[i]; DataTable mytb = (DataTable)mydatagrid.DataSource; for (int j = 0; j <= mytb.Rows.Count - 1; j++) { mytb.Rows[j]["选"] = (short)_value; } } } }
void mydatagrid_MouseClick(object sender, MouseEventArgs e) { if (butall.Visible == false) { return; } for (int i = 0; i <= panel2.Controls.Count - 1; i++) { if (panel2.Controls[i].GetType().ToString() == "TrasenClasses.GeneralControls.DataGridEx") { TrasenClasses.GeneralControls.DataGridEx mydatagrid = sender as TrasenClasses.GeneralControls.DataGridEx; DataTable mytb = (DataTable)mydatagrid.DataSource; int curIndex = mydatagrid.CurrentCell.RowNumber; #region bool shift = ((GetKeyState(VK_LSHIFT) & 0x80) != 0) || ((GetKeyState(VK_RSHIFT) & 0x80) != 0); if (shift) { if (ShiftBeginIndex == -1) { ShiftBeginIndex = curIndex; } else { ShiftEndIndex = curIndex; for (int ii = 0; ii < mytb.Rows.Count; ii++) { if (ShiftBeginIndex > ShiftEndIndex) { if (ii >= ShiftEndIndex && ii <= ShiftBeginIndex) { mytb.Rows[ii]["选"] = (short)1; } } else { if (ii >= ShiftBeginIndex && ii <= ShiftEndIndex) { mytb.Rows[ii]["选"] = (short)1; } } } ShiftBeginIndex = -1; ShiftEndIndex = -1; } return; } else { ShiftBeginIndex = -1; ShiftEndIndex = -1; } #endregion for (int j = 0; j <= mytb.Rows.Count - 1; j++) { if (j == curIndex) { if (mytb.Rows[j]["选"].ToString() == "1") { mytb.Rows[j]["选"] = (short)0; } else { mytb.Rows[j]["选"] = (short)1; } } try { decimal zsl = Convert.ToDecimal(Convertor.IsNull(mytb.Compute("sum(ypsl)", "选=true"), "0")); statusBar1.Text = "药品总用量:" + zsl.ToString(); mydatagrid.DataSource = mytb; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } }
/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.cardGrid = new TrasenClasses.GeneralControls.DataGridEx(); this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dropButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.cardGrid)).BeginInit(); this.SuspendLayout(); // // cardGrid // this.cardGrid.AllowSorting = false; this.cardGrid.BackgroundColor = System.Drawing.SystemColors.Window; this.cardGrid.CaptionVisible = false; this.cardGrid.CellSelectedBackColor = System.Drawing.Color.SkyBlue; this.cardGrid.DataMember = ""; this.cardGrid.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134))); this.cardGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.cardGrid.Location = new System.Drawing.Point(133, 0); this.cardGrid.Name = "cardGrid"; this.cardGrid.ReadOnly = true; this.cardGrid.RowHeaderWidth = 0; this.cardGrid.TabIndex = 1; this.cardGrid.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle1 }); this.cardGrid.Visible = false; this.cardGrid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cardGrid_KeyDown); this.cardGrid.myKeyDown += new TrasenClasses.GeneralControls.myDelegate(this.cardGrid_myKeyDown); this.cardGrid.Click += new System.EventHandler(this.cardGrid_Click); this.cardGrid.CurrentCellChanged += new System.EventHandler(this.cardGrid_CurrentCellChanged); // // dataGridTableStyle1 // this.dataGridTableStyle1.AllowSorting = false; this.dataGridTableStyle1.DataGrid = this.cardGrid; this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridTextBoxColumn1, this.dataGridTextBoxColumn2 }); this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridTableStyle1.MappingName = "ITEM_DB"; this.dataGridTableStyle1.ReadOnly = true; this.dataGridTableStyle1.RowHeaderWidth = 0; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "编码"; this.dataGridTextBoxColumn1.MappingName = ""; this.dataGridTextBoxColumn1.NullText = ""; this.dataGridTextBoxColumn1.Width = 60; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "名称"; this.dataGridTextBoxColumn2.MappingName = ""; this.dataGridTextBoxColumn2.NullText = ""; // // dropButton // this.dropButton.BackColor = System.Drawing.SystemColors.Control; this.dropButton.Cursor = System.Windows.Forms.Cursors.Default; this.dropButton.Location = new System.Drawing.Point(20, 0); this.dropButton.Name = "dropButton"; this.dropButton.Size = new System.Drawing.Size(20, 20); this.dropButton.TabIndex = 0; this.dropButton.Click += new System.EventHandler(this.dropButton_Click); // // ComboBoxEx // this.Controls.Add(this.dropButton); this.Controls.Add(this.cardGrid); ((System.ComponentModel.ISupportInitialize)(this.cardGrid)).EndInit(); this.ResumeLayout(false); }
/// <summary> /// 组合网格 /// </summary> public ComboGridSearch() { _mappingDataGrid = null; _tableStyleIndex = 0; InitializeComponent(); }
/// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.lblCaption = new TrasenClasses.GeneralControls.LabelEx(this.components); this.dtgrdBed = new TrasenClasses.GeneralControls.DataGridEx(); this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.btnAdd = new System.Windows.Forms.Button(); this.btnSave = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.txtNum = new System.Windows.Forms.TextBox(); this.showCard = new System.Windows.Forms.DataGrid(); this.dataGridTableStyle2 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn7 = new System.Windows.Forms.DataGridTextBoxColumn(); this.txtStartNo = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label3 = new System.Windows.Forms.Label(); this.txtFlag = new System.Windows.Forms.TextBox(); this.btnSameSet = new System.Windows.Forms.Button(); this.btnClear = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dtgrdBed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.showCard)).BeginInit(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // lblCaption // this.lblCaption.BackColor1 = System.Drawing.SystemColors.Desktop; this.lblCaption.BackColor2 = System.Drawing.Color.AliceBlue; this.lblCaption.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.lblCaption.Dock = System.Windows.Forms.DockStyle.Top; this.lblCaption.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblCaption.Location = new System.Drawing.Point(0, 0); this.lblCaption.Name = "lblCaption"; this.lblCaption.Size = new System.Drawing.Size(681, 21); this.lblCaption.TabIndex = 0; this.lblCaption.Text = "添加床位"; this.lblCaption.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // dtgrdBed // this.dtgrdBed.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; this.dtgrdBed.CaptionVisible = false; this.dtgrdBed.CellSelectedBackColor = System.Drawing.Color.SkyBlue; this.dtgrdBed.DataMember = ""; this.dtgrdBed.Dock = System.Windows.Forms.DockStyle.Top; this.dtgrdBed.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.dtgrdBed.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dtgrdBed.Location = new System.Drawing.Point(0, 21); this.dtgrdBed.Name = "dtgrdBed"; this.dtgrdBed.Size = new System.Drawing.Size(681, 337); this.dtgrdBed.TabIndex = 1; this.dtgrdBed.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle1 }); this.dtgrdBed.myKeyDown += new TrasenClasses.GeneralControls.myDelegate(this.dtgrdBed_myKeyDown); this.dtgrdBed.Click += new System.EventHandler(this.dtgrdBed_Click); // // dataGridTableStyle1 // this.dataGridTableStyle1.DataGrid = this.dtgrdBed; this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; // // btnAdd // this.btnAdd.Location = new System.Drawing.Point(270, 12); this.btnAdd.Name = "btnAdd"; this.btnAdd.Size = new System.Drawing.Size(52, 27); this.btnAdd.TabIndex = 2; this.btnAdd.Text = "增加"; this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); // // btnSave // this.btnSave.Location = new System.Drawing.Point(514, 368); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(77, 27); this.btnSave.TabIndex = 3; this.btnSave.Text = "保存(&S)"; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // btnClose // this.btnClose.Location = new System.Drawing.Point(601, 368); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(77, 27); this.btnClose.TabIndex = 4; this.btnClose.Text = "关闭(&X)"; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(8, 18); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(29, 12); this.label2.TabIndex = 5; this.label2.Text = "数量"; // // txtNum // this.txtNum.Location = new System.Drawing.Point(39, 15); this.txtNum.Name = "txtNum"; this.txtNum.Size = new System.Drawing.Size(41, 21); this.txtNum.TabIndex = 6; this.txtNum.Text = "1"; this.txtNum.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // showCard // this.showCard.AllowSorting = false; this.showCard.BackgroundColor = System.Drawing.Color.Azure; this.showCard.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.showCard.CaptionVisible = false; this.showCard.DataMember = ""; this.showCard.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.showCard.Location = new System.Drawing.Point(162, 122); this.showCard.Name = "showCard"; this.showCard.ReadOnly = true; this.showCard.RowHeaderWidth = 20; this.showCard.Size = new System.Drawing.Size(430, 168); this.showCard.TabIndex = 7; this.showCard.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { this.dataGridTableStyle2 }); this.showCard.Visible = false; // // dataGridTableStyle2 // this.dataGridTableStyle2.AllowSorting = false; this.dataGridTableStyle2.AlternatingBackColor = System.Drawing.Color.AliceBlue; this.dataGridTableStyle2.DataGrid = this.showCard; this.dataGridTableStyle2.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridTextBoxColumn1, this.dataGridTextBoxColumn2, this.dataGridTextBoxColumn3, this.dataGridTextBoxColumn4, this.dataGridTextBoxColumn5, this.dataGridTextBoxColumn6, this.dataGridTextBoxColumn7 }); this.dataGridTableStyle2.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.dataGridTableStyle2.ReadOnly = true; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "行号"; this.dataGridTextBoxColumn1.MappingName = "ROWNO"; this.dataGridTextBoxColumn1.NullText = ""; this.dataGridTextBoxColumn1.Width = 30; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "编号"; this.dataGridTextBoxColumn2.MappingName = "ITEMCODE"; this.dataGridTextBoxColumn2.NullText = ""; this.dataGridTextBoxColumn2.Width = 0; // // dataGridTextBoxColumn3 // this.dataGridTextBoxColumn3.Format = ""; this.dataGridTextBoxColumn3.FormatInfo = null; this.dataGridTextBoxColumn3.HeaderText = "名称"; this.dataGridTextBoxColumn3.MappingName = "ITEMNAME"; this.dataGridTextBoxColumn3.NullText = ""; this.dataGridTextBoxColumn3.Width = 150; // // dataGridTextBoxColumn4 // this.dataGridTextBoxColumn4.Format = ""; this.dataGridTextBoxColumn4.FormatInfo = null; this.dataGridTextBoxColumn4.HeaderText = "数字码"; this.dataGridTextBoxColumn4.MappingName = "D_CODE"; this.dataGridTextBoxColumn4.NullText = ""; this.dataGridTextBoxColumn4.Width = 75; // // dataGridTextBoxColumn5 // this.dataGridTextBoxColumn5.Format = ""; this.dataGridTextBoxColumn5.FormatInfo = null; this.dataGridTextBoxColumn5.HeaderText = "拼音码"; this.dataGridTextBoxColumn5.MappingName = "PY_CODE"; this.dataGridTextBoxColumn5.NullText = ""; this.dataGridTextBoxColumn5.Width = 75; // // dataGridTextBoxColumn6 // this.dataGridTextBoxColumn6.Format = ""; this.dataGridTextBoxColumn6.FormatInfo = null; this.dataGridTextBoxColumn6.HeaderText = "五笔码"; this.dataGridTextBoxColumn6.MappingName = "WB_CODE"; this.dataGridTextBoxColumn6.NullText = ""; this.dataGridTextBoxColumn6.Width = 75; // // dataGridTextBoxColumn7 // this.dataGridTextBoxColumn7.Format = ""; this.dataGridTextBoxColumn7.FormatInfo = null; this.dataGridTextBoxColumn7.HeaderText = "价格"; this.dataGridTextBoxColumn7.MappingName = "ITEMPRICE"; this.dataGridTextBoxColumn7.NullText = ""; this.dataGridTextBoxColumn7.Width = 75; // // txtStartNo // this.txtStartNo.Location = new System.Drawing.Point(151, 15); this.txtStartNo.Name = "txtStartNo"; this.txtStartNo.Size = new System.Drawing.Size(30, 21); this.txtStartNo.TabIndex = 8; this.txtStartNo.Text = "01"; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(84, 19); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 9; this.label1.Text = "本次起始号"; // // groupBox1 // this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.txtFlag); this.groupBox1.Controls.Add(this.btnAdd); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.txtNum); this.groupBox1.Controls.Add(this.txtStartNo); this.groupBox1.Location = new System.Drawing.Point(4, 359); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(333, 44); this.groupBox1.TabIndex = 10; this.groupBox1.TabStop = false; this.groupBox1.Text = "增加床位"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(185, 18); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(53, 12); this.label3.TabIndex = 11; this.label3.Text = "床头标注"; // // txtFlag // this.txtFlag.Location = new System.Drawing.Point(240, 15); this.txtFlag.Name = "txtFlag"; this.txtFlag.Size = new System.Drawing.Size(22, 21); this.txtFlag.TabIndex = 10; // // btnSameSet // this.btnSameSet.Location = new System.Drawing.Point(343, 368); this.btnSameSet.Name = "btnSameSet"; this.btnSameSet.Size = new System.Drawing.Size(88, 27); this.btnSameSet.TabIndex = 11; this.btnSameSet.Text = "应用相同设置"; this.btnSameSet.Click += new System.EventHandler(this.btnSameSet_Click); // // btnClear // this.btnClear.Location = new System.Drawing.Point(438, 368); this.btnClear.Name = "btnClear"; this.btnClear.Size = new System.Drawing.Size(70, 26); this.btnClear.TabIndex = 12; this.btnClear.Text = "重置"; this.btnClear.Click += new System.EventHandler(this.btnClear_Click); // // FrmAddBed // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(681, 406); this.Controls.Add(this.btnClear); this.Controls.Add(this.btnSameSet); this.Controls.Add(this.groupBox1); this.Controls.Add(this.showCard); this.Controls.Add(this.btnClose); this.Controls.Add(this.btnSave); this.Controls.Add(this.dtgrdBed); this.Controls.Add(this.lblCaption); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FrmAddBed"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "添加病床"; ((System.ComponentModel.ISupportInitialize)(this.dtgrdBed)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.showCard)).EndInit(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.ResumeLayout(false); }