Пример #1
0
        /// <summary>
        /// 切换到打印预览
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {

                if (MainTab.SelectedIndex == 1)
                {

                    if (cbAuditPerson.SelectedItem == null || cbAuditPosition.SelectedItem == null)
                    {
                        MainTab.SelectedIndex = 0;
                        this.selectPrintSendInfopara = 1;
                        MessageBox.Show("请选择审批人姓名和职位");
                        return;
                    }

                    if (this.selectPrintSendInfopara == 1)
                    {
                        if (string.IsNullOrEmpty(this.txtSendNO.Text) && cbNotPrint.SelectedItem == null)
                        {
                            MessageBox.Show("请选择需要打印的签证名单");
                            MainTab.SelectedIndex = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                        foreach (var sendObj in sendCollection.Where(s => s.FSelectItem == true))
                        {
                            if (string.IsNullOrEmpty(sendObj.FQZID))
                            {
                                MessageBox.Show("请先设置签证号");
                                MainTab.SelectedIndex = 0;
                                this.selectPrintSendInfopara = 1;
                                return;
                            }
                        }
                    }
                    else
                    {
                        Customer cusModel = visaORM.Customer.OrderByDescending(c => c.FCreateDate).FirstOrDefault(c => c.FPassportNo == txtPassportNo.Text);
                        if (cusModel == null)
                        {
                            MessageBox.Show("找不到该签证");
                            MainTab.SelectedIndex = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                        if (cusModel.FSysSend == false)
                        {
                            MessageBox.Show("请先审批后才可以打印");
                            MainTab.SelectedIndex = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                    }

                    StringBuilder sb = new StringBuilder();

                    //if (gridMain.SelectedItem == null)
                    //{
                    //    MessageBox.Show("请选择需要打印的数据");
                    //    MainTab.SelectedIndex = 0;
                    //    return;
                    //}
                    //else
                    //{
                    //    cusModel = gridMain.SelectedItem as Customer;
                    //}

                    //  PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = (PrintSendInfoSP.sp_SelectPrintSendInfoDataTable)(report.DataSource);
                    // PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = ((PrintSendInfoSP)(report.DataSource)).sp_SelectPrintSendInfo;
                    int i = 1;

                    List<sp_SelectPrintSendInfo_Result> selectPrintSendInfo;
                    if (this.selectPrintSendInfopara == 1)
                    {
                        if (!string.IsNullOrEmpty(this.txtSendNO.Text))
                            report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, this.txtSendNO.Text);
                        else
                            report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, cbNotPrint.SelectedItem.ToString());
                        selectPrintSendInfo = sendCollection.Where(s => s.FSelectItem == true).ToList();
                    }
                    else
                    {
                        report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, txtPassportNo.Text);
                        selectPrintSendInfo = visaORM.sp_SelectPrintSendInfo(txtPassportNo.Text).ToList();
                        this.selectPrintSendInfopara = 1;
                    }

                    Data.PrintSendInfo_SP.sp_SelectPrintSendInfoDataTable table = ((Data.PrintSendInfo_SP)(report.DataSource)).sp_SelectPrintSendInfo;

                    List<Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow> RowList = new List<Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow>();
                    report.printSendInfo_SP1.Clear();

                    foreach (sp_SelectPrintSendInfo_Result r in selectPrintSendInfo)
                    {
                        //PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow = row;

                        //if (string.IsNullOrEmpty(r.FQZID))
                        //{
                        //    MessageBox.Show("请先生成签证号");
                        //    MainTab.SelectedIndex = 0;
                        //    this.selectPrintSendInfopara = 1;
                        //    return;
                        //}

                        var icao = new GenIcao();

                        string countryShortName = "CHN";
                        var CountryShortObj = from c in visaORM.Customer.Where(custom => custom.FID == r.QID)
                                              join co in visaORM.TCountry on c.FBirthNationlityPresent equals co.FCountry
                                              select co;
                        if (CountryShortObj != null)
                        {
                            TCountry CountryShort = CountryShortObj.FirstOrDefault();
                            if (CountryShort != null)
                                countryShortName = CountryShort.Fcountryshort;
                        }

                        icao.encodeVisa("V", "VNM", countryShortName, r.Name, r.Sex, Convert.ToDateTime(r.BirthDay).ToString("dd/MM/yyyy"), r.PID, r.FQZID, (Convert.ToDateTime(r.PDate)).ToString("dd/MM/yyyy"));
                        string icaoLine1 = icao.getUpperLine();
                        string icaoLine2 = icao.getLowerLine();
                        string VIDString = icaoLine1 + "\n" + icaoLine2;
                        string timesDetail = "";
                        if (r.FTimes == 1) timesDetail = @"Một lần/Single";
                        else timesDetail = @"Nhiều lần/Multiple";

                        table.Addsp_SelectPrintSendInfoRow(true, i, r.Name, Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), (DateTime)r.FBirthDay, r.Sex, r.FBirthNationlityEn, r.FBirthNationlityPresentEn, r.PID, r.Work, r.CQJDate, timesDetail, (int)r.Days, (int)r.FTimes, (bool)r.FSysPut, (bool)r.FSysSend, r.FQZID, r.FDSN, VIDString, r.FCreateCompany, r.PrintCount, Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.CType, Convert.ToDateTime(r.MDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.IDOrder, r.FSysMemo);
                        i++;

                        //sb.Clear();
                        //sb.Append("签证人:" + r.Name + "\r\n");
                        //sb.Append("记录时间:" + DateTime.Now + "\r\n");
                        //sb.Append("生日:" + Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("出境时间:" + Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("回归时间:" + Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("签证码:" + VIDString + "\r\n");
                        //Log.WriteLog.WriteOperateLog(sb.ToString());

                    }

                    //foreach (PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow2 in RowList)
                    //{
                    //    table.Addsp_SelectPrintSendInfoRow(tempRow2);
                    //}

                    //sb.Clear();
                    //sb.Append("记录时间:" + DateTime.Now + "\r\n");
                    //sb.Append("审批人:" + cbAuditPerson.SelectedItem.ToString() + "\r\n");
                    //sb.Append("审批职位:" + cbAuditPosition.SelectedItem.ToString() + "\r\n");
                    //Log.WriteLog.WriteOperateLog(sb.ToString());

                    report.xrLabelVID.Width = 950;

                    report.xrLabelMemo.Text = txtMemo.Text;
                    report.xrLabelUserName.Text = cbAuditPerson.SelectedItem.ToString();
                    report.xrLabelDuty.Text = cbAuditPosition.SelectedItem.ToString();
                    if (!string.IsNullOrEmpty(datePassportMakeDay.Text))
                        report.xrLabelMDate.Text = Convert.ToDateTime(datePassportMakeDay.Text).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US"));
                    else
                        report.xrLabelMDate.Text = "";
                    report.xrLabelVID.Visible = false; //设置签证码为不可见
                    //设置位置
                    SetControlPositionInReport(report, 1);
                    MainPreview.Model = new XtraReportPreviewModel(report);
                    report.CreateDocument();
                }

            }
            catch (System.Exception ex)
            {
                Log.WriteLog.WriteErorrLog(ex);
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        /// <summary>
        /// 切换到打印预览
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (MainTab.SelectedIndex == 1)
                {
                    if (cbAuditPerson.SelectedItem == null || cbAuditPosition.SelectedItem == null)
                    {
                        MainTab.SelectedIndex        = 0;
                        this.selectPrintSendInfopara = 1;
                        MessageBox.Show("请选择审批人姓名和职位");
                        return;
                    }

                    if (this.selectPrintSendInfopara == 1)
                    {
                        if (string.IsNullOrEmpty(this.txtSendNO.Text) && cbNotPrint.SelectedItem == null)
                        {
                            MessageBox.Show("请选择需要打印的签证名单");
                            MainTab.SelectedIndex        = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                        foreach (var sendObj in sendCollection.Where(s => s.FSelectItem == true))
                        {
                            if (string.IsNullOrEmpty(sendObj.FQZID))
                            {
                                MessageBox.Show("请先设置签证号");
                                MainTab.SelectedIndex        = 0;
                                this.selectPrintSendInfopara = 1;
                                return;
                            }
                        }
                    }
                    else
                    {
                        Customer cusModel = visaORM.Customer.OrderByDescending(c => c.FCreateDate).FirstOrDefault(c => c.FPassportNo == txtPassportNo.Text);
                        if (cusModel == null)
                        {
                            MessageBox.Show("找不到该签证");
                            MainTab.SelectedIndex        = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                        if (cusModel.FSysSend == false)
                        {
                            MessageBox.Show("请先审批后才可以打印");
                            MainTab.SelectedIndex        = 0;
                            this.selectPrintSendInfopara = 1;
                            return;
                        }
                    }

                    StringBuilder sb = new StringBuilder();

                    //if (gridMain.SelectedItem == null)
                    //{
                    //    MessageBox.Show("请选择需要打印的数据");
                    //    MainTab.SelectedIndex = 0;
                    //    return;
                    //}
                    //else
                    //{
                    //    cusModel = gridMain.SelectedItem as Customer;
                    //}

                    //  PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = (PrintSendInfoSP.sp_SelectPrintSendInfoDataTable)(report.DataSource);
                    // PrintSendInfoSP.sp_SelectPrintSendInfoDataTable table = ((PrintSendInfoSP)(report.DataSource)).sp_SelectPrintSendInfo;
                    int i = 1;

                    List <sp_SelectPrintSendInfo_Result> selectPrintSendInfo;
                    if (this.selectPrintSendInfopara == 1)
                    {
                        if (!string.IsNullOrEmpty(this.txtSendNO.Text))
                        {
                            report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, this.txtSendNO.Text);
                        }
                        else
                        {
                            report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, cbNotPrint.SelectedItem.ToString());
                        }
                        selectPrintSendInfo = sendCollection.Where(s => s.FSelectItem == true).ToList();
                    }
                    else
                    {
                        report.sp_SelectPrintSendInfoTableAdapter.Fill(report.printSendInfo_SP1.sp_SelectPrintSendInfo, txtPassportNo.Text);
                        selectPrintSendInfo          = visaORM.sp_SelectPrintSendInfo(txtPassportNo.Text).ToList();
                        this.selectPrintSendInfopara = 1;
                    }


                    Data.PrintSendInfo_SP.sp_SelectPrintSendInfoDataTable table = ((Data.PrintSendInfo_SP)(report.DataSource)).sp_SelectPrintSendInfo;

                    List <Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow> RowList = new List <Data.PrintSendInfo_SP.sp_SelectPrintSendInfoRow>();
                    report.printSendInfo_SP1.Clear();


                    foreach (sp_SelectPrintSendInfo_Result r in selectPrintSendInfo)
                    {
                        //PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow = row;

                        //if (string.IsNullOrEmpty(r.FQZID))
                        //{
                        //    MessageBox.Show("请先生成签证号");
                        //    MainTab.SelectedIndex = 0;
                        //    this.selectPrintSendInfopara = 1;
                        //    return;
                        //}

                        var icao = new GenIcao();

                        string countryShortName = "CHN";
                        var    CountryShortObj  = from c in visaORM.Customer.Where(custom => custom.FID == r.QID)
                                                  join co in visaORM.TCountry on c.FBirthNationlityPresent equals co.FCountry
                                                  select co;
                        if (CountryShortObj != null)
                        {
                            TCountry CountryShort = CountryShortObj.FirstOrDefault();
                            if (CountryShort != null)
                            {
                                countryShortName = CountryShort.Fcountryshort;
                            }
                        }


                        icao.encodeVisa("V", "VNM", countryShortName, r.Name, r.Sex, Convert.ToDateTime(r.BirthDay).ToString("dd/MM/yyyy"), r.PID, r.FQZID, (Convert.ToDateTime(r.PDate)).ToString("dd/MM/yyyy"));
                        string icaoLine1   = icao.getUpperLine();
                        string icaoLine2   = icao.getLowerLine();
                        string VIDString   = icaoLine1 + "\n" + icaoLine2;
                        string timesDetail = "";
                        if (r.FTimes == 1)
                        {
                            timesDetail = @"Một lần/Single";
                        }
                        else
                        {
                            timesDetail = @"Nhiều lần/Multiple";
                        }

                        table.Addsp_SelectPrintSendInfoRow(true, i, r.Name, Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), (DateTime)r.FBirthDay, r.Sex, r.FBirthNationlityEn, r.FBirthNationlityPresentEn, r.PID, r.Work, r.CQJDate, timesDetail, (int)r.Days, (int)r.FTimes, (bool)r.FSysPut, (bool)r.FSysSend, r.FQZID, r.FDSN, VIDString, r.FCreateCompany, r.PrintCount, Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.CType, Convert.ToDateTime(r.MDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")), r.IDOrder, r.FSysMemo);
                        i++;

                        //sb.Clear();
                        //sb.Append("签证人:" + r.Name + "\r\n");
                        //sb.Append("记录时间:" + DateTime.Now + "\r\n");
                        //sb.Append("生日:" + Convert.ToDateTime(r.BirthDay).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("出境时间:" + Convert.ToDateTime(r.DDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("回归时间:" + Convert.ToDateTime(r.PDate).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")) + "\r\n");
                        //sb.Append("签证码:" + VIDString + "\r\n");
                        //Log.WriteLog.WriteOperateLog(sb.ToString());
                    }

                    //foreach (PrintSendInfoSP.sp_SelectPrintSendInfoRow tempRow2 in RowList)
                    //{
                    //    table.Addsp_SelectPrintSendInfoRow(tempRow2);
                    //}


                    //sb.Clear();
                    //sb.Append("记录时间:" + DateTime.Now + "\r\n");
                    //sb.Append("审批人:" + cbAuditPerson.SelectedItem.ToString() + "\r\n");
                    //sb.Append("审批职位:" + cbAuditPosition.SelectedItem.ToString() + "\r\n");
                    //Log.WriteLog.WriteOperateLog(sb.ToString());


                    report.xrLabelVID.Width = 950;

                    report.xrLabelMemo.Text     = txtMemo.Text;
                    report.xrLabelUserName.Text = cbAuditPerson.SelectedItem.ToString();
                    report.xrLabelDuty.Text     = cbAuditPosition.SelectedItem.ToString();
                    if (!string.IsNullOrEmpty(datePassportMakeDay.Text))
                    {
                        report.xrLabelMDate.Text = Convert.ToDateTime(datePassportMakeDay.Text).ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US"));
                    }
                    else
                    {
                        report.xrLabelMDate.Text = "";
                    }
                    report.xrLabelVID.Visible = false; //设置签证码为不可见
                    //设置位置
                    SetControlPositionInReport(report, 1);
                    MainPreview.Model = new XtraReportPreviewModel(report);
                    report.CreateDocument();
                }
            }
            catch (System.Exception ex)
            {
                Log.WriteLog.WriteErorrLog(ex);
                MessageBox.Show(ex.ToString());
            }
        }