public IgnoreAccNumUserControl()
        {
            InitializeComponent();
            var ignoretxt = INIHelper.ReadString(IgnoreVIP, DirectoryManage.GetINIFullPath());

            textBox1.Text = ignoretxt;
        }
示例#2
0
        public ResposeMessage Excute(InputArgs request)
        {
            var data = request.Data.ToString();

            var jobject   = Json.ToJObject(data);
            var template  = jobject.TEMPLATE.ToString();
            var printMode = (FPrintMode)int.Parse(jobject.PRINTMODE.ToString());

            //指定打印模板目录
            var sysType = request.SysType.ToString();


            using (Report report = new Report())
            {
                string reportfileName = DirectoryManage.GetFrxFullPath(template, sysType);

                if (File.Exists(reportfileName))
                {
                    report.Load(reportfileName);
                }
                else
                {
                    //模板不存在时,自动设置为设计模式
                    printMode = FPrintMode.Design;
                    //模板文件不存在,则重新设置文件名
                    report.FileName = reportfileName;
                }

                var ds = BuildDS(jobject);

                if (printMode != FPrintMode.BatchPrint)
                {
                    report.RegisterData(ds);
                    //设置报表显示数据源选项
                    foreach (DataTable dt in ds.Tables)
                    {
                        report.GetDataSource(dt.TableName).Enabled = true;
                    }
                }


                switch (printMode)
                {
                case FPrintMode.Preview:
                case FPrintMode.Design:
                case FPrintMode.ExportPDF:
                    var mainform = TechSvrApplication.Instance.MainFrm;
                    mainform.Invoke(new MethodInvoker(() =>
                    {
                        mainform.TopMost = true;
                        if (mainform.WindowState == FormWindowState.Minimized)
                        {
                            mainform.WindowState = FormWindowState.Normal;
                        }
                        var originSize  = mainform.Size;
                        mainform.Width  = 2;
                        mainform.Height = 2;
                        mainform.BringToFront();
                        mainform.TopMost = false;
                        if (printMode == FPrintMode.Preview)
                        {
                            report.Show();
                        }
                        else if (printMode == FPrintMode.Design)
                        {
                            report.Design();
                        }
                        else if (printMode == FPrintMode.ExportPDF)
                        {
                            try
                            {
                                //导出PDF文件
                                report.Prepare();
                                using (SaveFileDialog sfd = new SaveFileDialog())
                                {
                                    sfd.Filter = @"PDF文件|*.pdf";
                                    sfd.ShowDialog();
                                    var pdfFileName = sfd.FileName;

                                    report.Export(new FastReport.Export.Pdf.PDFExport(), pdfFileName);
                                    //System.Diagnostics.Process.Start("Explorer.exe", pdfFileName);
                                }
                            }
                            catch (Exception)
                            {
                                mainform.Size        = originSize;
                                mainform.WindowState = FormWindowState.Minimized;
                                throw;
                            }
                        }
                        mainform.Size        = originSize;
                        mainform.WindowState = FormWindowState.Minimized;
                    }));
                    break;

                case FPrintMode.Print:
                    //不弹打印窗口 直接打印
                    report.PrintSettings.ShowDialog = false;
                    report.Print();
                    break;

                case FPrintMode.BatchPrint:
                    //批量打印
                    //查找打印模板
                    var ReportFileArr = ((DataTable)ds.Tables[0]).AsEnumerable()
                                        .Select(p => new
                    {
                        TEMPLATE = p.Field <string>(TEMPLATE_STR),
                        SYSTYPE  = p.Field <string>(SYSTYPE_STR),
                    }).Distinct().ToList();

                    //遍历打印模板
                    foreach (var ReportFile in ReportFileArr)
                    {
                        DataSet dsDataSource = new DataSet();

                        var dt1 = (DataTable)ds.Tables[0];
                        //获取打印模板对应的数据
                        var mainDataRows  = dt1.AsEnumerable().Where(p => p.Field <string>(TEMPLATE_STR) == ReportFile.TEMPLATE && p.Field <string>(SYSTYPE_STR) == ReportFile.SYSTYPE);
                        var mainDataTable = dt1.Clone();
                        mainDataTable.TableName = dt1.TableName;

                        var dt2             = (DataTable)ds.Tables[1];
                        var detailDataTable = dt2.Clone();
                        detailDataTable.TableName = dt2.TableName;

                        foreach (var dataRow in mainDataRows)
                        {
                            mainDataTable.Rows.Add(dataRow.ItemArray);
                            //获取主表对应的子表数据行
                            var detailDataRows = dt2.AsEnumerable().Where(p => p.Field <Int64>(APPLYNO_STR) == Int64.Parse(dataRow[APPLYNO_STR].ToString())).ToList();
                            foreach (var detailDataRow in detailDataRows)
                            {
                                detailDataTable.Rows.Add(detailDataRow.ItemArray);
                            }
                        }
                        dsDataSource.Tables.Add(mainDataTable);
                        dsDataSource.Tables.Add(detailDataTable);

                        report.RegisterData(dsDataSource);

                        string templatefileName = DirectoryManage.GetFrxFullPath(ReportFile.TEMPLATE, ReportFile.SYSTYPE);
                        report.Load(templatefileName);
                        report.PrintSettings.ShowDialog = false;
                        report.Print();
                    }
                    break;

                default:
                    break;
                }
            }
            return(new ResposeMessage
            {
                type = ResultType.SUCCESS.ToString(),
                messageCode = MessageCode.information.ToString(),
                message = "打印成功",
                data = ""
            });
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     INIHelper.WriteInteger(Constants.INI_MAXRecordCount, int.Parse(txtMaxRecordcount.Text.Trim()), DirectoryManage.GetINIFullPath());
     MessageBox.Show("保存成功");
 }
示例#4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     INIHelper.WriteString(Constants.INI_ServicePort, txtPort.Text.Trim(), DirectoryManage.GetINIFullPath());
     MessageBox.Show("端口已保存成功");
 }
示例#5
0
        public void Alert()
        {
            try
            {
                if (!isRunning)
                {
                    isRunning = true;

                    var AlertTimes = int.Parse(System.Configuration.ConfigurationManager.AppSettings["AlertTimes"]);
                    using (var db = new Model1())
                    {
                        SqlParameter[] sqlParms = new SqlParameter[1];
                        sqlParms[0] = new SqlParameter("@alerttimes", AlertTimes);
                        alertData   = db.Database.SqlQuery <SaleRecord>("exec QuerySaleRecrod @alerttimes", sqlParms).ToList();

                        var vipInfos  = db.t_rm_vip_info.ToList();
                        var ignoretxt = INIHelper.ReadString("IgnoreVIP", DirectoryManage.GetINIFullPath());


                        var ignoreList = ignoretxt.Split(',');

                        var mode = System.Configuration.ConfigurationManager.AppSettings["Mode"] == "debug";

                        if (mode)
                        {
                            MessageBox.Show("vip数量:" + vipInfos.Count.ToString());
                        }

                        foreach (var vipinfo in vipInfos)
                        {
                            try
                            {
                                //if (vipinfo.vip_start_date.HasValue && vipinfo.vip_start_date.Value.Month == DateTime.Now.Month)
                                //{//当月不反积分

                                //    if (mode)
                                //    {
                                //        MessageBox.Show("当月不反积分");
                                //    }
                                //    continue;
                                //}


                                if (db.t_rm_vip_acclist.Where(o => o.oper_des == "活动##送积分" && o.memo == "活动##送积分" && o.card_no == vipinfo.card_no).Count() > 15)
                                {
                                    if (mode)
                                    {
                                        MessageBox.Show("已经超过送积分次数 则跳过");
                                    }
                                    continue;
                                }


                                var accnum = int.Parse(System.Configuration.ConfigurationManager.AppSettings["VipAccnum"]);

                                var acclist = db.t_rm_vip_acclist.Where(o => o.oper_des == "活动##送积分" && o.memo == "活动##送积分" && o.card_no == vipinfo.card_no).ToList();
                                if (acclist.Count > 0)
                                {
                                    var date1 = acclist.OrderByDescending(o => o.ope_date).FirstOrDefault().ope_date.Value.AddDays(30);
                                    if (date1 >= DateTime.Now)
                                    {
                                        if (mode)
                                        {
                                            MessageBox.Show("距离上次送积分还不到30天 则跳过");
                                        }
                                        continue;
                                    }
                                }


                                if (ignoreList.Contains(vipinfo.card_no))
                                {
                                    if (mode)
                                    {
                                        MessageBox.Show("如果会员忽略列表里存在这个会员卡号,择跳过");
                                    }
                                    //如果会员忽略列表里存在这个会员卡号,择跳过
                                    continue;
                                }

                                if (mode)
                                {
                                    MessageBox.Show("vip数量:" + vipInfos.Count.ToString());
                                }
                                vipinfo.acc_num     = vipinfo.acc_num + accnum;
                                vipinfo.now_acc_num = vipinfo.now_acc_num + accnum;

                                db.t_rm_vip_acclist.Add(new t_rm_vip_acclist
                                {
                                    card_no    = vipinfo.card_no,
                                    card_id    = vipinfo.card_id,
                                    card_type  = vipinfo.card_type,
                                    branch_no  = "000",
                                    oper_type  = "2",
                                    oper_id    = "1001",
                                    ope_date   = DateTime.Now,
                                    flow_no    = "",
                                    consum_amt = 0,
                                    acc_num    = accnum,
                                    oper_des   = "活动##送积分",
                                    memo       = "活动##送积分"
                                });
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("错误:" + ex.ToString());
                            }
                        }

                        db.SaveChanges();


                        if (alertData.Count > 0)
                        {
                            MaintainenceAlertForm form = new MaintainenceAlertForm(alertData);
                            form.ShowDialog();
                        }

                        isRunning = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误:" + ex.ToString());
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     INIHelper.WriteString(IgnoreVIP, textBox1.Text.Trim(), DirectoryManage.GetINIFullPath());
     MessageBox.Show("保存成功");
 }