public Form_PurchaseOrder_Set() { InitializeComponent(); var sets = this.PharmacyDatabaseService.GetSalePriceControlRules(out message); this.CurrentTaxRateModel = sets.PurchaseOrderDefaultTaxRate ?? new PurchaseOrderTaxRate { DefaultTaxRate = decimal.Parse("0.16") }; this.purchaseOrderTaxRateBindingSource.Add(this.CurrentTaxRateModel); this.button1.Click += (s, e) => { var re = MessageBox.Show("确定要保存设置吗?", "提示", MessageBoxButtons.OKCancel); if (re == System.Windows.Forms.DialogResult.Cancel) { return; } sets.PurchaseOrderDefaultTaxRate = this.CurrentTaxRateModel; var b = this.PharmacyDatabaseService.SaveSalePriceControlRules(sets, out message); if (b) { MessageBox.Show("保存成功!"); this.DialogResult = DialogResult.OK; } }; this.button2.Click += (s, e) => { this.DialogResult = DialogResult.Cancel; this.Close(); }; }
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 }