private void getData() { string kw = this.toolStripTextBox1.Text.Trim(); Business.Models.BaseQueryModel q = new Business.Models.BaseQueryModel { Keyword = kw }; var allSupplyUnits = this.PharmacyDatabaseService.GetSuplyUnitIdNamesByQueryModel(q, out msg).ToList(); this.dataGridView1.DataSource = allSupplyUnits; this.dataGridView1.Columns["Id"].Visible = false; this.dataGridView1.Columns["PinYin"].Visible = false; this.dataGridView1.Columns["IsValid"].Visible = false; if (allSupplyUnits.Count > 0) { this.dataGridView1.Focus(); } }
public System.Collections.Generic.IEnumerable <Business.Models.Model_IdName> GetUserIdNamesByQueryModel(Business.Models.BaseQueryModel q) { var all = this.RepositoryProvider.Db.Users.Where(r => r.Deleted == false); if (!string.IsNullOrEmpty(q.Keyword)) { all = all.Where(r => r.Employee.Name.Contains(q.Keyword) || r.Employee.Pinyin.Contains(q.Keyword)); } var re = all.Select(r => new Business.Models.Model_IdName { Id = r.Id, Name = r.Employee.Name, PinYin = r.Employee.Pinyin }); return(re.OrderBy(r => r.Name)); }
public Form_PurchaseOrderGenerator() { InitializeComponent(); this.CurrentListDetail.ListChanged += (s, e) => { this.InputTotalPriceToTextBox2(); }; #region 采购创建初始化 this.label10.Text = BugsBox.Pharmacy.AppClient.Common.AppClientContext.CurrentUser.Employee.Name; this.label11.Text = DateTime.Now.ToLongDateString(); var types = EnumToListHelper.ConverEnumToList(typeof(PurchaseDrugTypes)).Where(r => r.Name != PurchaseDrugTypes.食品.ToString()).ToList();//暂时不支持食品类 this.toolStripComboBox1.ComboBox.DisplayMember = "Name"; this.toolStripComboBox1.ComboBox.ValueMember = "Id"; this.toolStripComboBox1.ComboBox.DataSource = types; this.toolStripComboBox1.ComboBox.SelectedIndex = 0; this.toolStripComboBox1.SelectedIndexChanged += toolStripComboBox1_SelectedIndexChanged; this.Shown += (s, e) => { var tt = new ToolTip { ToolTipTitle = "提示!", AutoPopDelay = 5000, InitialDelay = 1000, ReshowDelay = 500, ShowAlways = false, ToolTipIcon = ToolTipIcon.Warning, IsBalloon = true, UseFading = true, UseAnimation = true, }; tt.SetToolTip(this.textBox1, "提示"); tt.Show("从这里开始,先选择一个供货单位!", this.textBox1, 5000); this.textBox1.Focus(); }; #endregion #region 从服务器端读入采购默认税率值 var sets = this.PharmacyDatabaseService.GetSalePriceControlRules(out msg); PurchaseOrderDefaultTaxRate = sets.PurchaseOrderDefaultTaxRate ?? new PurchaseOrderTaxRate { DefaultTaxRate = 17 }; #endregion #region 钮事件 this.toolStripButton1.Click += (s, e) => this.GetDrugInfo(); this.toolStripButton3.Click += (s, e) => this.Submit(); this.btnGeneratePurchaseRecords.Click += (s, e) => this.Submit(); this.toolStripButton6.Click += (s, e) => this.FromXls(); this.toolStripButton2.Click += (s, e) => this.DeleteDrugInfo(); this.FormClosing += (s, e) => { e.Cancel = MessageBox.Show("确定要关闭?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel; };//窗口关闭提示 this.toolStripButton5.Click += (s, e) => { using (Form_PurchaseOrder_Set frm = new Form_PurchaseOrder_Set()) { frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { this.PurchaseOrderDefaultTaxRate = frm.CurrentTaxRateModel; } }; };//默认税率值设置 #endregion #region 供货单位信息处理 this.textBox1.KeyPress += (s, e) => { if (e.KeyChar != 13) { return; } this.SearchSupplyUnit(); }; this.button1.Click += (s, e) => this.SearchSupplyUnit(); #endregion #region 用户信息处理 Business.Models.BaseQueryModel q2 = new Business.Models.BaseQueryModel { }; var allusers = this.PharmacyDatabaseService.GetUserIdNamesByQueryModel(q2, out msg).ToList(); this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; this.comboBox2.DataSource = allusers; #endregion #region 右键菜单 this.brm = new BaseRightMenu(this.dataGridView1); this.brm.InsertMenuItem("一键填写最近采购价格", this.GetLastUnitPrice); this.brm.InsertMenuItem("删除品种", this.DeleteDrugInfo); this.brm.InsertMenuItem("查看品种基本资料", this.OpenDrugInfo); this.brm.InsertMenuItem("税率一键填写", this.InsertTaxRate); #endregion #region Datagriview处理 this.dataGridView1.DataSource = this.CurrentListDetail; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToOrderColumns = true; this.dataGridView1.RowPostPaint += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView1, e); this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView1.ReadOnly = true; this.dataGridView1.DataError += (s, e) => { }; this.dataGridView1.Columns["DrugInfoId"].Visible = false; DataGridViewCellStyle dgvcs = new DataGridViewCellStyle { BackColor = Color.Yellow }; this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle = dgvcs; this.dataGridView1.Columns["Amount"].DefaultCellStyle = dgvcs; this.dataGridView1.Columns["TaxRate"].DefaultCellStyle = dgvcs; #region 设置datagridview只读性和可编辑 this.dataGridView1.CellEnter += (s, e) => { if (dataGridView1.Columns[e.ColumnIndex].Name == "UnitPrice" || dataGridView1.Columns[e.ColumnIndex].Name == "Amount" || dataGridView1.Columns[e.ColumnIndex].Name == "TaxRate") { this.dataGridView1.ReadOnly = false; } else { this.dataGridView1.ReadOnly = true; } }; #endregion #region 计算总额 this.dataGridView1.CellEndEdit += (s, e) => { this.textBox2.Text = decimal.Round(this.CurrentListDetail.Sum(r => r.UnitPrice * r.Amount), 4).ToString(); }; #endregion #endregion #region 绑定采购单CurrentPurchaseOrder实体 this.purchaseOrderBindingSource.Add(this.CurrentPurchaseOrder); #endregion #region 获取供应商基础信息 this.linkLabel1.Click += (s, e) => this.GetSupplyUnitInfo(); #endregion }
public System.Collections.Generic.IEnumerable <Business.Models.Model_IdName> GetSuplyUnitIdNamesByQueryModel(Business.Models.BaseQueryModel q) { var all = this.RepositoryProvider.Db.SupplyUnits.Where(r => r.Deleted == false); if (!string.IsNullOrEmpty(q.Keyword)) { all = all.Where(r => r.PinyinCode.Contains(q.Keyword) || r.Name.Contains(q.Keyword)); } var re = all.ToList().Select(r => new Business.Models.Model_IdName { Id = r.Id, Name = r.Name, PinYin = r.PinyinCode, IsValid = r.Valid }); return(re.OrderBy(r => r.Name)); }