public FormSalePriceControlRules()
        {
            InitializeComponent();

            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

            SalePriceControlRulesModel m = this.PharmacyDatabaseService.GetSalePriceControlRules(out msg);

            if (m.RuleType == 0)
            {
                m = new SalePriceControlRulesModel
                {
                    RuleType    = 0,
                    Description = "在销售开票界面中,控制销售价不得低于采购价。客户端销售开票时,药品选择界面中定义的价格无效,以采购价显示当前药品的销售价,销售价格不得低于采购价格,否则无法开票销售。请注意,销售价格不得低于本公司对该品种定义的最低销售价格。",
                    RuleName    = Models.SalePriceControlEnum.低于采购价.ToString(),
                    SalesOrderPrintRuleValue = m.SalesOrderPrintRuleValue
                };
                this.label2.Text = m.Description;
            }

            var c = EnumToListHelper.ConverEnumToList(typeof(Models.SalePriceControlEnum));

            this.comboBox1.DisplayMember = "Name";
            this.comboBox1.ValueMember   = "Id";
            this.comboBox1.DataSource    = c.OrderBy(r => r.Id).ToList();
            this.comboBox1.SelectedIndex = m.RuleType;
            this.label2.Text             = m.Description;
            if (m.RuleType == (int)Models.SalePriceControlEnum.高于最高定价)
            {
                this.textBox1.Enabled = true;
                this.textBox1.Text    = m.RuleRate.ToString();
            }

            var p = EnumToListHelper.ConverEnumToList(typeof(EnumSalesOrderPrintRule));

            this.comboBox2.DisplayMember = "Name";
            this.comboBox2.ValueMember   = "Id";
            this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox2.DataSource    = p;
            this.comboBox2.SelectedValue = (int)m.SalesOrderPrintRuleValue;

            #region 控价规则选择
            this.comboBox1.SelectedIndexChanged += (s, e) =>
            {
                var idx = this.comboBox1.SelectedIndex;

                if (idx == 0)
                {
                    this.label2.Text = "在销售开票界面中,控制销售价不得低于采购价。客户端销售开票时,药品选择界面中定义的价格无效,以采购价显示当前药品的销售价,销售价格不得低于采购价格,否则无法开票销售。请注意,销售价格不得低于本公司对该品种定义的最低销售价格。";
                }
                if (idx == 1)
                {
                    this.label2.Text = "在销售开票界面中,以药品选择界面中定义的销售价显示当前价格,可低于采购价销售。请注意,销售价格不得低于本公司对于该品种定义的最低销售价格。";
                }
                if (idx == 2)
                {
                    this.label2.Text = "在销售开票界面,以采购价的N倍比例显示当前药品销售价格,可以在文本框中填写该比例。药品选择界面中定义的销售价格无效。本规则可低于采购价销售,但不能高于最高定价。请注意,销售价格不得低于本公司对于该品种定义的最低销售价格。";
                }
                this.textBox1.Enabled = idx == 2;
            };
            #endregion

            //保存
            #region 保存
            this.toolStripButton1.Click += (s, e) =>
            {
                var re = MessageBox.Show("确定需要保存销售价格控制规则吗?", "提示", MessageBoxButtons.OKCancel);
                if (re == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                m.RuleType    = this.comboBox1.SelectedIndex;
                m.RuleName    = ((Models.SalePriceControlEnum)(this.comboBox1.SelectedIndex)).ToString();
                m.Description = this.label2.Text;
                m.SalesOrderPrintRuleValue = (EnumSalesOrderPrintRule)this.comboBox2.SelectedValue;

                decimal rate = 1m;
                if (m.RuleType == (int)Models.SalePriceControlEnum.高于最高定价)
                {
                    if (string.IsNullOrEmpty(this.textBox1.Text.Trim()))
                    {
                        MessageBox.Show("该规则需要您填写比例!");
                        this.textBox1.Focus();
                        return;
                    }

                    if (!decimal.TryParse(this.textBox1.Text.Trim(), out rate))
                    {
                        MessageBox.Show("请输入比例!"); return;
                    }
                    m.RuleRate = rate;
                }


                if (this.PharmacyDatabaseService.SaveSalePriceControlRules(m, out msg))
                {
                    MessageBox.Show("销售价格控制规则保存成功!请注意设定品种价格或者最低价格等信息!");
                    this.PharmacyDatabaseService.WriteLog(BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id, "保存销售价格控制规则成功!");
                }
                else
                {
                    MessageBox.Show("信息保存失败,异常信息:\n" + msg);
                }
            };
            #endregion
        }
示例#2
0
        //新增构造函数
        public Form_SalesOrder()
        {
            InitializeComponent();

            this.invoicer.Text      = Pharmacy.AppClient.Common.AppClientContext.CurrentUser.Employee.Name;
            this.lblCreateDate.Text = DateTime.Now.Date.ToLongDateString();

            #region 列表处理
            this.dataGridView1.RowPostPaint += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView1, e);
            this.dataGridView1.CellClick    += dataGridView1_CellClick;

            this.dataGridView1.CellMouseDown += (s, e) =>       //选定列表中的药品id,给右键菜单使用
            {
                if (this.dataGridView1.Rows.Count <= 0)
                {
                    return;
                }
                var c = this.dataGridView1.CurrentRow.DataBoundItem as SalesOrderDetailModel;
                this.BaseRightMenu.DrugId = c.DrugInfoId;
            };

            this.BaseRightMenu = new UI.Forms.BaseForm.BasicInfoRightMenu(this.dataGridView1); //右键支持
            this.BaseRightMenu.InsertDrugBasicInfo();                                          //加入药品基本信息查询功能

            this.BaseRightMenu.InserMenu("删除该品种", () =>
            {
                if (this.dataGridView1.Rows.Count <= 0)
                {
                    return;
                }
                var c = MessageBox.Show("确定需要删除该品种吗", "提示", MessageBoxButtons.OKCancel);
                if (c == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                this.DeleteDrug();
            });
            #endregion

            #region  择客户单位
            this.textBox1.Focus();
            this.textBox1.KeyDown += (s, e) =>
            {
                if (e.KeyCode != Keys.Return)
                {
                    return;
                }
                using (Common.FormPurchaseSelector frm = new Common.FormPurchaseSelector(this.textBox1.Text.Trim()))
                {
                    var re = frm.ShowDialog();
                    if (re == System.Windows.Forms.DialogResult.OK)
                    {
                        this.CurrentPurchaseUnit  = frm.Result;
                        this.txtPurchaseName.Text = this.CurrentPurchaseUnit.Name;

                        this.BaseRightMenu.InsertPurchaseUnitBasicInfo();           //加入右键查询该客户的基本信息查询界面

                        #region 当前客户单位的采购员
                        var c = this.PharmacyDatabaseService.GetPurchaseUnitBuyersByPurchaseUnitId(this.CurrentPurchaseUnit.Id, out msg).OrderBy(r => r.Name).ToList();

                        c.Add(new PurchaseUnitBuyer {
                            Id   = Guid.Empty,
                            Name = "请选择"
                        });
                        this.cmbPurchaseUnitBuyer.DisplayMember = "Name";
                        this.cmbPurchaseUnitBuyer.ValueMember   = "Id";
                        this.cmbPurchaseUnitBuyer.DataSource    = c;
                        if (c.Count > 0)
                        {
                            this.cmbPurchaseUnitBuyer.SelectedIndex = 0;
                            this.CurrentPurchaseUnitBuyer           = c.First();
                        }
                        #endregion
                    }
                }
            };
            #endregion

            #region 客户采购员选择
            this.cmbPurchaseUnitBuyer.SelectedIndexChanged += (s, e) =>
            {
                this.CurrentPurchaseUnitBuyer = this.cmbPurchaseUnitBuyer.SelectedItem as PurchaseUnitBuyer;
            };
            #endregion

            #region 提货方式
            var pickupGoodTypeList = EnumToListHelper.ConverEnumToList(typeof(PickUpGoodType));
            this.cmbPickUpGoods.DisplayMember = "Name";
            this.cmbPickUpGoods.ValueMember   = "Id";
            this.cmbPickUpGoods.DataSource    = pickupGoodTypeList;
            this.cmbPickUpGoods.SelectedValue = (int)this.CurrentPickUpGoodType;
            #endregion

            #region 品种类型选择下拉列表
            var drugTypeList = EnumToListHelper.ConverEnumToList(typeof(SalesDrugType));
            this.comboBox1.DisplayMember         = "Name";
            this.comboBox1.ValueMember           = "Id";
            this.comboBox1.DataSource            = drugTypeList;
            this.comboBox1.SelectedIndex         = 0;
            this.comboBox1.SelectedIndexChanged += (s, e) =>
            {
                this.CurrentSalesDrugType       = (SalesDrugType)this.comboBox1.SelectedIndex;
                this.toolStripStatusLabel2.Text = ((MyLibs.EnumTypeList) this.comboBox1.SelectedItem).Name;
            };

            #endregion

            #region 销售人员名单绑定列表
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "BugsBox.Pharmacy.AppClient.SalePriceType.xml");
            System.Xml.XmlNodeList xmlNode = xmlDocument.SelectNodes("/SalePriceType/priceType");

            xmlNode = xmlDocument.SelectNodes("/SalePriceType/salerRoleName");
            string salerRoleName = xmlNode[0].Attributes[0].Value.ToString();
            var    SalerNames    = this.PharmacyDatabaseService.GetUserByPosition(salerRoleName, string.Empty, string.Empty).OrderBy(r => r.Employee.Name).ToList();//根据角色获取用户
            var    UE            = (from i in SalerNames
                                    select new SalerNames
            {
                Id = i.Id,
                EName = i.Employee.Name
            }).ToList();
            //插入一条“请选择”
            UE.Insert(0, new SalerNames
            {
                Id    = Guid.Empty,
                EName = "请选择销售员"
            });

            this.cmbSalesMan.ValueMember   = "Id";
            this.cmbSalesMan.DisplayMember = "EName";
            this.cmbSalesMan.DataSource    = UE;
            this.cmbSalesMan.SelectedIndex = 0;
            #endregion
        }
示例#3
0
        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 Form_PurchaseOrderImpt()
        {
            InitializeComponent();

            #region 绑定类型
            var ordertypes = EnumToListHelper.ConverEnumToList(typeof(PurchaseDrugTypes)).Where(r => r.Name != "食品").ToList();

            this.toolStripComboBox1.ComboBox.DisplayMember = "Name";
            this.toolStripComboBox1.ComboBox.ValueMember   = "Id";
            this.toolStripComboBox1.ComboBox.DataSource    = ordertypes;
            #endregion

            #region DataGridView初始化
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.dataGridView1.RowPostPaint       += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView1, e);
            this.dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.dataGridView2.RowPostPaint       += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView2, e);
            #endregion

            #region 右键菜单
            BugsBox.Pharmacy.UI.Common.BaseRightMenu brm = new BugsBox.Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1);
            #endregion

            #region 清理表格数据
            Action ClearData = () =>
            {
                this.ListDetails.Clear();
                this.dataGridView1.DataSource = null;
                this.ListDetailsWaitingImpt.Clear();
                this.dataGridView2.DataSource = null;
            };
            #endregion

            #region 打开EXCEL文件
            this.toolStripButton1.Click += (s, e) =>
            {
                OpenFileDialog ofd = new OpenFileDialog
                {
                    Filter = "XLS文件|*.xls|XLSX文件|*.xlsx",
                };

                var re = ofd.ShowDialog();
                if (re != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
                NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(fs);
                int sheetCount = book.NumberOfSheets;

                NPOI.SS.UserModel.ISheet sheet = book.GetSheetAt(0);
                #region 简单验证一下excel表格
                if (sheet == null)
                {
                    MessageBox.Show("模板文件出错,请检查!"); return;
                }

                NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
                if (row == null)
                {
                    MessageBox.Show("模板文件出错,请检查!"); return;
                }

                int firstCellNum = row.FirstCellNum;
                int lastCellNum  = row.LastCellNum;
                if (firstCellNum == lastCellNum)
                {
                    MessageBox.Show("模板文件出错,请检查!"); return;
                }
                #endregion

                ClearData();
                for (int i = 1; i < sheet.LastRowNum + 1; i++)
                {
                    var sheetrow = sheet.GetRow(i);
                    Business.Models.PurchaseOrderImpt m = new Business.Models.PurchaseOrderImpt();
                    m.ProductGeneralName = sheet.GetRow(i).Cells[0].StringCellValue;
                    m.DosageName         = sheet.GetRow(i).Cells[1].StringCellValue;
                    m.SpecificName       = sheet.GetRow(i).Cells[2].StringCellValue;
                    m.MeasurementName    = sheet.GetRow(i).Cells[3].StringCellValue;
                    m.FactoryName        = sheet.GetRow(i).Cells[4].StringCellValue;
                    m.Origin             = sheet.GetRow(i).Cells[5].StringCellValue;
                    m.Amount             = decimal.Parse(sheet.GetRow(i).Cells[6].NumericCellValue.ToString());
                    m.UnitPrice          = decimal.Parse(sheet.GetRow(i).Cells[7].NumericCellValue.ToString());
                    m.TaxRate            = decimal.Parse(sheet.GetRow(i).Cells[8].NumericCellValue.ToString());

                    this.ListDetails.Add(m);
                }
                this.dataGridView1.DataSource = this.ListDetails;
                this.dataGridView1.Columns["DruginfoId"].Visible = false;
            };

            #endregion

            #region 生成模板文件
            this.toolStripButton4.Click += (s, e) =>
            {
                DownlodExcel();
                MessageBox.Show("导出成功!");
            };
            #endregion

            #region  务器端验证
            this.toolStripButton2.Click += (s, e) =>
            {
                if (this.dataGridView1.Rows.Count <= 0)
                {
                    return;
                }

                var result = this.PharmacyDatabaseService.CheckForPurchaseOrderDetails(this.ListDetails, out msg).ToList();

                if (result.Any(r => r.DrugInfoId == Guid.Empty))
                {
                    MessageBox.Show("有一个或多个记录没有验证成功,请检查品名,剂型,规格等基本信息!您可以修改后再尝试验证!");
                }

                this.ListDetails = result.Where(r => r.DrugInfoId == Guid.Empty).ToList();
                this.dataGridView1.DataSource = ListDetails;

                this.ListDetailsWaitingImpt   = result.Where(r => r.DrugInfoId != Guid.Empty).ToList();
                this.dataGridView2.DataSource = this.ListDetailsWaitingImpt;
                this.dataGridView2.Columns["DrugInfoId"].Visible = false;
                this.dataGridView2.Refresh();
            };
            #endregion

            #region 导入按钮click
            this.toolStripButton3.Click += (s, e) =>
            {
                if (this.ListDetailsWaitingImpt.Count <= 0)
                {
                    return;
                }

                if (this.OnPurchaseOrderImpt != null)
                {
                    PurchaseOrderImptEventArgs args = new PurchaseOrderImptEventArgs
                    {
                        ImptList = this.ListDetailsWaitingImpt
                    };
                    this.OnPurchaseOrderImpt(args);
                }
            };
            #endregion
        }
        public FormSalePriceControlRules()
        {
            InitializeComponent();

            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

            SalePriceControlRulesModel m = this.PharmacyDatabaseService.GetSalePriceControlRules(out msg);

            this.comboBox3.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox4.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox5.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox6.DropDownStyle = ComboBoxStyle.DropDownList;
            if (m.RuleType == 0)
            {
                m.RuleType    = 0;
                m.Description = "在销售开票界面中,控制销售价不得低于采购价。客户端销售开票时,药品选择界面中定义的价格无效,以采购价显示当前药品的销售价,销售价格不得低于采购价格,否则无法开票销售。请注意,销售价格不得低于本公司对该品种定义的最低销售价格。";
                m.RuleName    = Models.SalePriceControlEnum.低于采购价.ToString();


                this.label2.Text = m.Description;
            }

            var c = EnumToListHelper.ConverEnumToList(typeof(Models.SalePriceControlEnum));

            this.comboBox1.DisplayMember = "Name";
            this.comboBox1.ValueMember   = "Id";
            this.comboBox1.DataSource    = c.OrderBy(r => r.Id).ToList();
            this.comboBox1.SelectedIndex = m.RuleType;
            this.label2.Text             = m.Description;
            if (m.RuleType == (int)Models.SalePriceControlEnum.高于最高定价)
            {
                this.textBox1.Enabled = true;
                this.textBox1.Text    = m.RuleRate.ToString();
            }

            var p = EnumToListHelper.ConverEnumToList(typeof(EnumSalesOrderPrintRule));

            this.comboBox2.DisplayMember = "Name";
            this.comboBox2.ValueMember   = "Id";
            this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox2.DataSource    = p;
            this.comboBox2.SelectedValue = (int)m.SalesOrderPrintRuleValue;

            #region 控价规则选择
            this.comboBox1.SelectedIndexChanged += (s, e) =>
            {
                var idx = this.comboBox1.SelectedIndex;

                if (idx == 0)
                {
                    this.label2.Text = "在销售开票界面中,控制销售价不得低于采购价。客户端销售开票时,药品选择界面中定义的价格无效,以采购价显示当前药品的销售价,销售价格不得低于采购价格,否则无法开票销售。请注意,销售价格不得低于本公司对该品种定义的最低销售价格。";
                }
                if (idx == 1)
                {
                    this.label2.Text = "在销售开票界面中,以药品选择界面中定义的销售价显示当前价格,可低于采购价销售。请注意,销售价格不得低于本公司对于该品种定义的最低销售价格。";
                }
                if (idx == 2)
                {
                    this.label2.Text = "在销售开票界面,以采购价的N倍比例显示当前药品销售价格,可以在文本框中填写该比例。药品选择界面中定义的销售价格无效。本规则可低于采购价销售,但不能高于最高定价。请注意,销售价格不得低于本公司对于该品种定义的最低销售价格。";
                }
                this.textBox1.Enabled = idx == 2;
            };
            #endregion

            //保存
            #region 保存
            this.toolStripButton1.Click += (s, e) =>
            {
                var re = MessageBox.Show("确定需要保存销售价格控制规则吗?", "提示", MessageBoxButtons.OKCancel);
                if (re == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                m.RuleType    = this.comboBox1.SelectedIndex;
                m.RuleName    = ((Models.SalePriceControlEnum)(this.comboBox1.SelectedIndex)).ToString();
                m.Description = this.label2.Text;
                m.SalesOrderPrintRuleValue = (EnumSalesOrderPrintRule)this.comboBox2.SelectedValue;

                decimal rate = 1m;
                if (m.RuleType == (int)Models.SalePriceControlEnum.高于最高定价)
                {
                    if (string.IsNullOrEmpty(this.textBox1.Text.Trim()))
                    {
                        MessageBox.Show("该规则需要您填写比例!");
                        this.textBox1.Focus();
                        return;
                    }

                    if (!decimal.TryParse(this.textBox1.Text.Trim(), out rate))
                    {
                        MessageBox.Show("请输入比例!"); return;
                    }
                    m.RuleRate = rate;
                }

                m.SaleChecker = new Business.Models.SaleChecker
                {
                    OrdinaryChecker              = (Guid)this.comboBox3.SelectedValue,
                    SpacialDrugFirstChecker      = (Guid)this.comboBox4.SelectedValue,
                    SpacialDrugSecondChecker     = (Guid)this.comboBox5.SelectedValue,
                    OrdinaryCheckerName          = this.comboBox3.Text,
                    SpecialDrugFirstCheckerName  = this.comboBox4.Text,
                    SpacialDrugSecondCheckerName = this.comboBox5.Text
                };

                m.EnumSalesOrderSortWhenPrintValue = (EnumSalesOrderSortWhenPrint)this.comboBox7.SelectedIndex;

                if (this.comboBox6.SelectedValue == null)
                {
                    MessageBox.Show("请选择一个仓库保管员!"); return;
                }

                m.InventoryKeeperId   = (Guid)this.comboBox6.SelectedValue;
                m.InventoryKeeperName = this.comboBox6.Text;

                if (this.PharmacyDatabaseService.SaveSalePriceControlRules(m, out msg))
                {
                    MessageBox.Show("销售价格控制规则保存成功!请注意设定品种价格或者最低价格等信息!");
                    this.PharmacyDatabaseService.WriteLog(BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id, "保存销售价格控制规则成功!");
                }
                else
                {
                    MessageBox.Show("信息保存失败,异常信息:\n" + msg);
                }
            };
            #endregion

            List <Business.Models.Model_IdName> ListChecker = null;          //所有复核员

            List <Business.Models.Model_IdName> ListInventoryKeepers = null; //所有复核员


            this.Load += (s, e) =>
            {
                #region 绑定复核员
                ListChecker = this.PharmacyDatabaseService.GetSalesCheckers(string.Empty, out msg).ToList();
                this.comboBox3.DisplayMember = "Name";
                this.comboBox3.ValueMember   = "Id";
                this.comboBox3.DataSource    = ListChecker;

                List <Business.Models.Model_IdName> ListCheckerSpe1 = new List <Model_IdName>();
                foreach (var i in ListChecker)
                {
                    ListCheckerSpe1.Add(new Business.Models.Model_IdName
                    {
                        Id   = i.Id,
                        Name = i.Name
                    });
                }
                this.comboBox4.DisplayMember = "Name";
                this.comboBox4.ValueMember   = "Id";
                this.comboBox4.DataSource    = ListCheckerSpe1;

                List <Business.Models.Model_IdName> ListCheckerSpe2 = new List <Model_IdName>();
                foreach (var i in ListChecker)
                {
                    ListCheckerSpe2.Add(new Business.Models.Model_IdName
                    {
                        Id   = i.Id,
                        Name = i.Name
                    });
                }
                this.comboBox5.DisplayMember = "Name";
                this.comboBox5.ValueMember   = "Id";
                this.comboBox5.DataSource    = ListCheckerSpe2;

                if (m.SaleChecker != null)
                {
                    this.comboBox3.SelectedValue = m.SaleChecker.OrdinaryChecker;
                    this.comboBox4.SelectedValue = m.SaleChecker.SpacialDrugFirstChecker;
                    this.comboBox5.SelectedValue = m.SaleChecker.SpacialDrugSecondChecker;
                }

                #endregion

                #region 仓库保管员
                ListInventoryKeepers = this.PharmacyDatabaseService.GetInventoryKeepers(string.Empty, out msg).ToList();

                this.comboBox6.DisplayMember = "Name";
                this.comboBox6.ValueMember   = "Id";
                this.comboBox6.DataSource    = ListInventoryKeepers;

                if (m.InventoryKeeperId != Guid.Empty)
                {
                    this.comboBox6.SelectedValue = m.InventoryKeeperId;
                }
                #endregion

                #region 销售打印排序控制
                var u = EnumToListHelper.ConverEnumToList(typeof(EnumSalesOrderSortWhenPrint));
                this.comboBox7.ValueMember   = "Id";
                this.comboBox7.DisplayMember = "Name";
                this.comboBox7.DataSource    = u.ToList();
                this.comboBox7.SelectedValue = (int)m.EnumSalesOrderSortWhenPrintValue;
                this.comboBox7.DropDownStyle = ComboBoxStyle.DropDownList;

                #endregion
            };
        }