예제 #1
0
 private void TaskPrintingDlg_VisibleChanged(object sender, EventArgs e)
 {
     try
     {
         if (Visible == true)
         {
             Result = null;
             CheckBtnPrint();
         }
     }
     catch (Exception ex)
     {
         Common.Log(ex);
     }
 }
예제 #2
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            try
            {
                //StoreReport(cbReportType.Text);
                cbReportType_SelectedIndexChanged(null, null);

                Result = new PrintDoc();
                Result.Docs.Add(new PrintTextDoc(tbHeaderText.Text));
                PrintTableDoc tbl = new PrintTableDoc(Common.MLS.Get(MLSConst, "Пробы"));
                Result.Docs.Add(tbl);
                Result.Docs.Add(new PrintTextDoc(tbFooterText.Text));

                int el_count = Task.Data.GetElementCount();
                int pr_count = Task.Data.GetProbCount();
                int col_count = el_count, row_count = 0;
                for (int pr = 0; pr < pr_count; pr++)
                {
                    if (chlProbList.GetItemChecked(pr) == false)
                    {
                        continue;
                    }
                    row_count++;
                    if (chbPrintAllMeasuring.Checked)
                    {
                        row_count += Task.Data.GetProbHeader(pr).MeasuredSpectrs.Count;
                    }
                }
                if (chbPrintAllMeasuringDate.Checked)
                {
                    tbl.SetupSize(col_count + 1, row_count);
                }
                else
                {
                    tbl.SetupSize(col_count, row_count);
                }
                int    row = 0;
                double sko, real_sko, con, good_sko;
                bool   is_first = true;
                for (int pr = 0; pr < pr_count; pr++)
                {
                    if (chlProbList.GetItemChecked(pr) == false)
                    {
                        continue;
                    }
                    MethodSimpleProb mpr = Task.Data.GetProbHeader(pr);
                    tbl.SetupRowHeader(row, mpr.Name);
                    for (int el = 0; el < el_count; el++)
                    {
                        if (is_first)
                        {
                            MethodSimpleElement mse = Task.Data.GetElHeader(el);
                            tbl.SetupColHeader(el, mse.Element.Name);
                        }
                        MethodSimpleCell msc = Task.Data.GetCell(el, pr);
                        con = msc.CalcRealCon(out sko, out real_sko);
                        string tmp        = "" + serv.GetGoodValue(con, 2);
                        bool   plus_minus = false;
                        if (real_sko > 0)
                        {
                            if (chbPrintEverSko.Checked)
                            {
                                double tmpp;
                                if (sko > real_sko && real_sko > 0)
                                {
                                    tmpp = real_sko;
                                }
                                else
                                {
                                    tmpp = sko;
                                }
                                tmpp       = 100 * tmpp / con;
                                tmp       += (char)0xB1 + serv.GetGoodValue(tmpp, 1) + "%";
                                plus_minus = true;
                            }
                            if (chbPrintEverAbsError.Checked)
                            {
                                if (plus_minus == false)
                                {
                                    tmp += (char)0xB1;
                                }
                                if (real_sko > 0)
                                {
                                    tmp += serv.GetGoodValue(real_sko, 2);
                                }
                                else
                                {
                                    tmp += serv.GetGoodValue(sko, 2);
                                }
                            }
                        }
                        tbl.SetupData(el, row, tmp);
                    }
                    is_first = false;
                    row++;
                    if (chbPrintAllMeasuring.Checked)
                    {
                        for (int sp = 0; sp < mpr.MeasuredSpectrs.Count; sp++)
                        {
                            if (chbPrintAllMeasuringDate.Checked &&
                                mpr.MeasuredSpectrs[sp].Sp != null)
                            {
                                tbl.SetupData(col_count, row, mpr.MeasuredSpectrs[sp].Sp.CreatedDate.ToString());
                            }
                            tbl.SetupRowHeader(row, " ");
                            for (int el = 0; el < el_count; el++)
                            {
                                MethodSimpleCell    msc = Task.Data.GetCell(el, pr);
                                MethodSimpleElement mse = Task.Data.GetElHeader(el);
                                string cel_text         = "";
                                for (int f = 0; f < mse.Formula.Count; f++)
                                {
                                    MethodSimpleCellFormulaResult mscfr = msc.GetData(sp, mse.Formula[f].FormulaIndex);
                                    if (mscfr == null || mscfr.ReCalcCon == null || mscfr.Enabled == false)
                                    {
                                        continue;
                                    }
                                    con = mscfr.GetEver(out sko, out good_sko);
                                    //sko = mscfr.GetSKO();
                                    if (sko > good_sko)
                                    {
                                        sko = good_sko;
                                    }
                                    string tmp = "" + serv.GetGoodValue(con, 2);
                                    if (sko > 0)
                                    {
                                        bool plus_minus = false;
                                        if (chbPrintAllMeasuringSko.Checked)
                                        {
                                            double tmpp;
                                            tmpp       = sko;
                                            tmpp       = 100 * tmpp / con;
                                            tmp       += (char)0xB1 + serv.GetGoodValue(tmpp, 1) + "%";
                                            plus_minus = true;
                                        }
                                        if (chbPrintAllMeasuringAbsError.Checked)
                                        {
                                            if (plus_minus == false)
                                            {
                                                tmp += (char)0xB1;
                                            }
                                            tmp += serv.GetGoodValue(sko, 2);
                                        }
                                    }
                                    cel_text += tmp + " ";
                                }
                                tbl.SetupData(el, row, cel_text);
                            }
                            row++;
                        }
                    }
                }

                /*tbl.SetupSize(10, 50);
                 * for (int c = 0; c < 10; c++)
                 * {
                 *  tbl.SetupColHeader(c, "" + c);
                 *  for (int r = 0; r < 50; r++)
                 *  {
                 *      tbl.SetupRowHeader(r, "" + r);
                 *      tbl.SetupData(c, r, "____" + c + "_" + r+"____");
                 *  }
                 * }*/
            }
            catch (Exception ex)
            {
                Result = null;
                Common.Log(ex);
            }
            Visible = false;
        }