示例#1
0
        public void Export(GridControl gc)
        {
            string filename = MySaveFileDialog.Show();

            if (!string.IsNullOrEmpty(filename))
            {
                gc.ExportToXlsx(filename);
            }
        }
示例#2
0
        public void Init()
        {
            //单击查询按钮
            sbQuery.Click += (s, e) =>
            {
                SimpleButton sb = s as SimpleButton;
                DataTable    dt = new DrugTJManager().Get(lueDrug.EditValue == null?"":lueDrug.Text, deBegin.Text + " 00:00:00", deEnd.Text + " 23:59:59");
                gridControl1.DataSource = dt;
            };
            //单击更新按钮
            sbRefresh.Click += (s, e) =>
            {
                DataTable dt01      = ExcelHelper.ImportExceltoDt(@"C:\1.xls");
                DataTable dt02      = ExcelHelper.ImportExceltoDt(@"C:\2.xls");
                DateTime  minTime01 = Convert.ToDateTime(dt01.Compute("min([发药时间])", "true"));
                DateTime  minTime02 = Convert.ToDateTime(dt02.Compute("min([发/退药时间])", "true"));

                DateTime?maxTime01 = new FyByPatientManager().GetMaxTime();
                maxTime01 = maxTime01 == null ? DateTime.MinValue : maxTime01;
                DateTime?maxTime02 = new FyByDrugManager().GetMaxTime();
                maxTime02 = maxTime02 == null ? DateTime.MinValue : maxTime02;

                //if (minTime01 <= maxTime01 || minTime02 <= maxTime02)
                //{
                //    MessageBox.Show("为防止有数据遗漏,请重新导入数据");
                //    return;
                //}
                List <fybypatient> li01 = DataTableToModel.ToListModel <fybypatient>(dt01).Where(item => item.fytime > maxTime01).ToList();
                List <fybydrug>    li02 = DataTableToModel.ToListModel <fybydrug>(dt02).Where(item => item.fytime > maxTime02).ToList();
                int count01             = new FyByPatientManager().Insert(li01);
                int count02             = new FyByDrugManager().Insert(li02);
                MessageBox.Show($"成功更新表数据为{count01},{count02}");
                string maxT = new FyByPatientManager().GetMaxTime().ToString();
                xtraTabControl2.CustomHeaderButtons[0].Caption = $"更新时间为:{maxT}";
            };
            xtraTabControl1.CustomHeaderButtonClick += (s, e) =>
            {
                if (e.Button.Caption == "导出数据")
                {
                    //gridView1.ExportToXlsx(@"C:\Users\Administrator\Desktop\yytj.xlsx");
                    string filename = MySaveFileDialog.Show();
                    if (!string.IsNullOrEmpty(filename))
                    {
                        gridView1.ExportToXlsx(filename);
                    }
                }
                else if (e.Button.Caption == "展开")
                {
                    gridView1.ExpandAllGroups();
                    e.Button.Caption = "收缩";
                }
                else if (e.Button.Caption == "收缩")
                {
                    gridView1.CollapseAllGroups();
                    e.Button.Caption = "展开";
                }
            };
            gridView1.RowCellClick += (s, e) =>
            {
                DataRow dr        = gridView1.GetDataRow(e.RowHandle);
                string  doctor    = dr["doctor"].ToString();
                string  code      = dr["code"].ToString();
                string  drug      = dr["name"].ToString();
                string  spci      = dr["spci"].ToString();
                string  unitprice = dr["unitprice"].ToString();
                string  quantity  = dr["quantity"].ToString();
                xtraTabControl2.TabPages[0].Text = $"医生用药明细 [{code},{drug},{spci},{unitprice},{quantity}]";
                gridControl2.DataSource          = new FyByPatientManager().GetListByCondition(deBegin.Text + " 00:00:00", deEnd.Text + " 23:59:59", doctor, code).OrderBy(item => item.fytime);
            };
            DateTime?maxTime = new FyByPatientManager().GetMaxTime();

            maxTime = maxTime == null ? DateTime.MinValue : maxTime;
            string mt = maxTime.ToString();

            xtraTabControl2.CustomHeaderButtons[0].Caption = $"更新时间为:{mt}";
            deBegin.EditValue                = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            deEnd.EditValue                  = DateTime.Now;
            lueDrug.Properties.DataSource    = SqlHelper.ExecuteTable("select distinct name 名称,searchcode 搜索码 from drug");
            lueDrug.EditValue                = "";
            lueDrug.Properties.DisplayMember = "名称";
            lueDrug.Properties.ValueMember   = "名称";
        }
示例#3
0
        public ChufangControl()
        {
            InitializeComponent();
            FFVM = mvvmContext.GetViewModel <FyFormViewModel>();
            mvvmContext.SetBinding(this.deBegin, e => e.Text, "BeginTime");
            mvvmContext.SetBinding(this.deEnd, e => e.Text, "EndTime");
            mvvmContext.SetBinding(this.teDoctor, e => e.EditValue, "Doctor");
            mvvmContext.SetBinding(this.tePatient, e => e.EditValue, "Patient");
            mvvmContext.SetBinding(this.gridControl1, e => e.DataSource, "cfhead");
            mvvmContext.SetBinding(this.gridControl2, e => e.DataSource, "Dv");
            mvvmContext.SetBinding(this.gridControl3, e => e.DataSource, "CfDetailList");
            mvvmContext.SetBinding(this.gridControl4, e => e.DataSource, "HzByDoctor");
            mvvmContext.SetBinding(this.tsUnique, e => e.IsOn, "IsAll");
            mvvmContext.SetBinding(gridControl5, e => e.DataSource, "JSDT");
            // mvvmContext.SetBinding(this.xtraTabControl1.CustomHeaderButtons[0], e => e.Enabled, "IsEnable");
            mvvmContext.BindCommand <FyFormViewModel>(this.sbQuery, x => x.Query());
            // mvvmContext.SetBinding(this.cbeDate, e => e.Text, "SelectDate");
            mvvmContext.SetBinding(this.lblTotlprice, e => e.Text, "Huizong");

            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl1, "CustomHeaderButtonClick")
            .EventToCommand(x => x.Refresh(), args => args.Button.Caption == "同步数据");
            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl1, "CustomHeaderButtonClick")
            .EventToCommand(x => x.DeleteRow(), args => args.Button.Caption == "删除选中记录");
            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl1, "CustomHeaderButtonClick")
            .EventToCommand(x => x.Print(), args => args.Button.Caption == "打印处方封面");
            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl1, "CustomHeaderButtonClick")
            .EventToCommand(x => x.Export(this.gridControl1), cs => this.gridControl1, args => args.Button.Caption == "导出处方");
            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl1, "CustomHeaderButtonClick")
            .EventToCommand(x => x.Export(this.gridControl2), cs => this.gridControl2, args => args.Button.Caption == "导出汇总");
            mvvmContext.WithEvent <FyFormViewModel, RowClickEventArgs>(gridView1, "RowClick")
            .EventToCommand(x => x.ShowHistory(), args => args.Clicks == 2);
            mvvmContext.WithEvent <FyFormViewModel, CustomHeaderButtonEventArgs>(xtraTabControl2, "CustomHeaderButtonClick")
            .EventToCommand(x => x.ShowHistory(), args => args.Button.Caption == "查看历史处方");


            mvvmContext.WithEvent <FyFormViewModel, FocusedRowChangedEventArgs>(gridView1, "FocusedRowChanged")
            .EventToCommand(x => x.ChangeRow(gridView1), args => gridView1);
            groupControl3.CustomButtonClick += (s, e) =>
            {
                string caption = e.Button.Properties.Caption;
                if (caption == "删除选中记录")
                {
                    FFVM.DeleteRow();
                }
                else if (caption == "打印处方封面")
                {
                    FFVM.Print();
                }
                else if (caption == "导出处方")
                {
                    FFVM.Export(gridControl1);
                }
            };

            Init();

            this.toggleSwitch1_Toggled(this.tsAll, new EventArgs());
            // layoutControlItem1.Enabled = layoutControlItem2.Enabled = false;
            groupControl2.CustomButtonChecked += (s, e) =>
            {
                bandedGridView1.ExpandAllGroups();
            };
            groupControl2.CustomButtonUnchecked += (s, e) =>
            {
                bandedGridView1.CollapseAllGroups();
            };
            groupControl2.CustomButtonClick += (s, e) =>
            {
                if (e.Button.Properties.Caption == "导出数据")
                {
                    string filename = MySaveFileDialog.Show();
                    if (!string.IsNullOrEmpty(filename))
                    {
                        bandedGridView1.ExportToXlsx(filename);
                    }
                    ;
                }
            };
            popupMenu1.Manager.ItemClick += (s, e) =>
            {
                FFVM.SelectDate = e.Item.Caption;
            };


            dropDownButton1.DropDownControl          = this.popupMenu1;
            xtraTabControl3.CustomHeaderButtonClick += (s, e) =>
            {
                string caption = e.Button.Caption;
                if (caption == "精神药品")
                {
                    xtraTabPage6.Text = "精神药品";
                    FFVM.GetJS();
                }
                else if (caption == "麻醉药品")
                {
                    xtraTabPage6.Text = "麻醉药品";
                    FFVM.GetMZ();
                }
            };
        }