Exemple #1
0
 public void initDanHao()
 {
     mixDanHao.LoadDataByWhere("main.samplestate = @samplestate and main.wllx=@wllx and main.cardid='' and main.matpk in (SELECT   MATNCID  FROM  QC_Material WHERE WLLX = '煤') ", Xg.Lab.Sample.SampleState.组批完成, "火运");
     foreach (var item in mixDanHao)
     {
         item.StoreCode = QC_Sample_Mix.ShortStoreCode(item.StoreCode);
     }
     gridControl2.DataSource = mixDanHao;
 }
Exemple #2
0
        private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            List <ZupiData> printData = new List <ZupiData>();

            foreach (var mix in hjmixs)
            {
                List <string> vehnos = new List <string>();
                DbEntityTable <QC_Sample_Veh> vehs = new DbEntityTable <QC_Sample_Veh>();
                vehs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID", mix.Sample_Mix_ID);
                foreach (var item in vehs)
                {
                    vehnos.Add(QC_Sample_Mix.ShortStoreCode(item.CardID));
                }

                if (vehnos.Count > 0)
                {
                    ZupiData zd = new ZupiData();
                    zd.Head      = QC_Sample_Mix.ShortStoreCode(mix.CardID);
                    zd.ZupiItems = vehnos;
                    printData.Add(zd);
                    ZupiData pbzd = new ZupiData();
                    pbzd.Head      = QC_Sample_Mix.ShortStoreCode("PB" + mix.CardID.Remove(0, 2));
                    pbzd.ZupiItems = vehnos;
                    printData.Add(pbzd);
                }
            }
            int totalPage = 1;

            foreach (var item in printData)
            {
                item.BeginPage = totalPage;
                totalPage     += item.NeadPage;
            }

            int printPage = totalPage - curZupiPrintPage;

            foreach (var item in printData)
            {
                if (printPage >= item.BeginPage && printPage < item.EndPage)
                {
                    item.Print(e.Graphics, printPage);
                    break;
                }
            }

            if (curZupiPrintPage < totalPage - 1)
            {
                curZupiPrintPage++;
                e.HasMorePages = true;
            }
            else
            {
                curZupiPrintPage = 1;
                e.HasMorePages   = false;
            }
        }
Exemple #3
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     rjmixs.LoadDataByWhere("main.SAMPLESTATE=@SAMPLESTATE and main.WLLX='熔剂'", SampleState.组批完成);
     comboBox1.Items.Clear();
     foreach (var item in rjmixs)
     {
         comboBox1.Items.Add(QC_Sample_Mix.ShortStoreCode(item.CardID));
     }
     zyMixSamples.LoadZyAllData(workpointCode);
     LabTabs();
 }
Exemple #4
0
 private void WP_Zhiyangdan_Load(object sender, EventArgs e)
 {
     zyMixSamples.LoadZyAllData(workpointCode);
     this.qCSampleMixZhiYangBindingSource.DataSource = zyMixSamples;
     this.qCSampleLabBindingSource1.DataSource       = labTable;
     LabTabs();
     rjmixs.LoadDataByWhere("main.SAMPLESTATE=@SAMPLESTATE and main.WLLX='熔剂'", SampleState.组批完成);
     comboBox1.Items.Clear();
     foreach (var item in rjmixs)
     {
         comboBox1.Items.Add(QC_Sample_Mix.ShortStoreCode(item.CardID));
     }
 }
Exemple #5
0
        private void koushuikouza_Load(object sender, EventArgs e)
        {
            vehs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID", samplemixid);
            mixs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID or main.MainSampleMixId=@MainSampleMixId", samplemixid, samplemixid);
            foreach (var item in mixs)
            {
                item.Memo = textBox1.Text;
            }
            mixs.Save();

            this.qCSampleVehBindingSource.DataSource = vehs;
            labelzydh.Text = QC_Sample_Mix.ShortStoreCode(zydanhao);
        }
Exemple #6
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            QC_Sample_Mix mix = this.qCSampleMixBindingSource.Current as QC_Sample_Mix;

            if (mix == null)
            {
                MessageBox.Show("请选择任务单");
            }
            else
            {
                string qydh  = QC_Sample_Mix.ShortStoreCode(mix.CardID);
                string head  = qydh;
                string body  = mix.MatName;
                string body1 = mix.SupplierName;
                mix.WCDY = true;
                mix.Save();

                Rectangle rect      = new Rectangle(9, 3, 112, 94);
                Font      f1        = new System.Drawing.Font("宋体", 21, FontStyle.Bold);
                SizeF     headSize  = e.Graphics.MeasureString(head, f1);
                Font      f2        = new System.Drawing.Font("宋体", 12f, FontStyle.Bold);
                SizeF     bodySize  = e.Graphics.MeasureString(body, f2);
                Font      f3        = new System.Drawing.Font("宋体", 12f, FontStyle.Bold);
                SizeF     body1Size = e.Graphics.MeasureString(body1, f2);

                float topMargin  = rect.Top + (rect.Height - headSize.Height - bodySize.Height - body1Size.Height - 6) / 2;
                float leftMargin = rect.Left + (rect.Width - headSize.Width) / 2;

                e.Graphics.DrawString(head, f1, Brushes.Black, new PointF(leftMargin, topMargin));

                float topMargin2  = topMargin + Math.Max(headSize.Height + 3, 12);
                float leftMargin2 = rect.Left;
                e.Graphics.DrawString(body, f2, Brushes.Black, new PointF(leftMargin2, topMargin2));

                float topMargin3  = topMargin2 + Math.Max(bodySize.Height + 2, 12);
                float leftMargin3 = rect.Left;
                e.Graphics.DrawString(body1, f2, Brushes.Black, new PointF(leftMargin3, topMargin3));
            }
        }
Exemple #7
0
        private void 制样_Click(object sender, EventArgs e)
        {
            if (!comboBox1.Text.StartsWith("RJ"))
            {
                MessageBox.Show("请选择正确单号");
                return;
            }
            DbEntityTable <QC_Sample_Mix> mix = new DbEntityTable <QC_Sample_Mix>();
            int mixid = 100000000;

            mix.LoadDataByWhere("main.CardID=@CardID", QC_Sample_Mix.FullStoreCode(comboBox1.Text));
            if (mix.Count > 0)
            {
                mixid = mix[0].Sample_Mix_ID;
            }
            QC_SampleMix_ZhiYang zySample = QC_SampleMix_ZhiYang.GetById(mixid);

            if (zySample == null)
            {
                MessageBox.Show("找不到单据");
                return;
            }

            if (zySample.SampleState < SampleState.组批完成)
            {
                MessageBox.Show("磁卡所对大桶还未组批完成");
                return;
            }
            if (zySample.WLLX != "熔剂")
            {
                MessageBox.Show("物料不是熔剂请选择其他制样点");
                return;
            }
            zySample.ZyDanHao    = mix[0].CardID;
            zySample.SampleState = SampleState.开始制样;
            zySample.ZyWpCode    = workpointCode;
            zySample.ZyRecvUser  = LocalInfo.Current.user.ID;
            zySample.ZyRecvTime  = DateTime.Now;
            if (zySample.SampleType == SampleType.普通样 || zySample.SampleType == SampleType.破包样)
            {
                DbEntityTable <QC_MatAllCheckItem> bjCheckItem = new DbEntityTable <QC_MatAllCheckItem>();
                bjCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='必检'", zySample.MatPK);
                foreach (var stdCheckItem in bjCheckItem)
                {
                    QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId);
                    if (ckItem == null)
                    {
                        QC_MixCheckItem item = new QC_MixCheckItem();
                        item.CheckItemNcId    = stdCheckItem.CheckItemNcId;
                        item.CheckItemCode    = stdCheckItem.CheckItemCode;
                        item.CheckItemName    = stdCheckItem.CheckItemName;
                        item.CheckItemUnit    = stdCheckItem.CheckItemUnit;
                        item.CheckGroupCode   = stdCheckItem.CheckGroupCode;
                        item.CheckGroupName   = stdCheckItem.CheckGroupName;
                        item.CheckGroupType   = stdCheckItem.CheckGroupType;
                        item.CkgShortWord     = stdCheckItem.CkgShortWord;
                        item.Sample_Mix_ID    = item.Sample_Mix_ID;
                        item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx;
                        item.Source           = "检验标准-必检";
                        zySample.CheckItems.Add(item);
                    }
                }
                DbEntityTable <QC_MatAllCheckItem> myCheckItem = new DbEntityTable <QC_MatAllCheckItem>();
                myCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每月'", zySample.MatPK);

                DateTime yue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

                foreach (var stdCheckItem in myCheckItem)
                {
                    object cntObj = DbContext.ExecuteScalar("SELECT count(*)  FROM  QC_MixCheckItem mck  inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID  where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", yue, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId);
                    if (cntObj != null)
                    {
                        int cnt = Convert.ToInt32(cntObj);
                        if (cnt == 0)
                        {
                            QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId);
                            if (ckItem == null)
                            {
                                QC_MixCheckItem item = new QC_MixCheckItem();
                                item.CheckItemNcId    = stdCheckItem.CheckItemNcId;
                                item.CheckItemCode    = stdCheckItem.CheckItemCode;
                                item.CheckItemName    = stdCheckItem.CheckItemName;
                                item.CheckItemUnit    = stdCheckItem.CheckItemUnit;
                                item.CheckGroupCode   = stdCheckItem.CheckGroupCode;
                                item.CheckGroupName   = stdCheckItem.CheckGroupName;
                                item.CheckGroupType   = stdCheckItem.CheckGroupType;
                                item.CkgShortWord     = stdCheckItem.CkgShortWord;
                                item.Sample_Mix_ID    = item.Sample_Mix_ID;
                                item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx;
                                item.Source           = "检验标准-每月";
                                zySample.CheckItems.Add(item);
                            }
                        }
                    }
                }

                int wd2 = (int)DateTime.Now.DayOfWeek - 1;
                if (wd2 == -1)
                {
                    wd2 = 6;
                }

                DateTime zhou1 = DateTime.Today.AddDays(0 - wd2);
                DbEntityTable <QC_MatAllCheckItem> meizhouCheckItem = new DbEntityTable <QC_MatAllCheckItem>();
                meizhouCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每周'", zySample.MatPK);

                foreach (var stdCheckItem in meizhouCheckItem)
                {
                    object cntObj = DbContext.ExecuteScalar("SELECT count(*)  FROM  QC_MixCheckItem mck  inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID  where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", zhou1, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId);
                    if (cntObj != null)
                    {
                        int cnt = Convert.ToInt32(cntObj);
                        if (cnt == 0)
                        {
                            QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId);
                            if (ckItem == null)
                            {
                                QC_MixCheckItem item = new QC_MixCheckItem();
                                item.CheckItemNcId    = stdCheckItem.CheckItemNcId;
                                item.CheckItemCode    = stdCheckItem.CheckItemCode;
                                item.CheckItemName    = stdCheckItem.CheckItemName;
                                item.CheckItemUnit    = stdCheckItem.CheckItemUnit;
                                item.CheckGroupCode   = stdCheckItem.CheckGroupCode;
                                item.CheckGroupName   = stdCheckItem.CheckGroupName;
                                item.CheckGroupType   = stdCheckItem.CheckGroupType;
                                item.CkgShortWord     = stdCheckItem.CkgShortWord;
                                item.Sample_Mix_ID    = item.Sample_Mix_ID;
                                item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx;
                                item.Source           = "检验标准-每周";
                                zySample.CheckItems.Add(item);
                            }
                        }
                    }
                }
                DateTime tian1 = DateTime.Today;
                DbEntityTable <QC_MatAllCheckItem> meitianCheckItem = new DbEntityTable <QC_MatAllCheckItem>();
                meizhouCheckItem.LoadDataByWhere("MATNCID=@MATNCID and JYLX='每天'", zySample.MatPK);

                foreach (var stdCheckItem in meizhouCheckItem)
                {
                    object cntObj = DbContext.ExecuteScalar("SELECT count(*)  FROM  QC_MixCheckItem mck  inner join qc_sample_mix mix on mix.SAMPLE_MIX_ID=mck.SAMPLE_MIX_ID  where mix.Mix_Time>=@MixTime and mix.SampleType=" + (int)SampleType.普通样 + " and mix.SupplierCode=@SupplierCode and mix.MatPK=@MatPK and mck.CheckItemNcId=@CheckItemNcId", tian1, zySample.SupplierCode, zySample.MatPK, stdCheckItem.CheckItemNcId);
                    if (cntObj != null)
                    {
                        int cnt = Convert.ToInt32(cntObj);
                        if (cnt == 0)
                        {
                            QC_MixCheckItem ckItem = zySample.CheckItems.FirstOrDefault <QC_MixCheckItem>((ck) => ck.CheckItemNcId == stdCheckItem.CheckItemNcId);
                            if (ckItem == null)
                            {
                                QC_MixCheckItem item = new QC_MixCheckItem();
                                item.CheckItemNcId    = stdCheckItem.CheckItemNcId;
                                item.CheckItemCode    = stdCheckItem.CheckItemCode;
                                item.CheckItemName    = stdCheckItem.CheckItemName;
                                item.CheckItemUnit    = stdCheckItem.CheckItemUnit;
                                item.CheckGroupCode   = stdCheckItem.CheckGroupCode;
                                item.CheckGroupName   = stdCheckItem.CheckGroupName;
                                item.CheckGroupType   = stdCheckItem.CheckGroupType;
                                item.CkgShortWord     = stdCheckItem.CkgShortWord;
                                item.Sample_Mix_ID    = item.Sample_Mix_ID;
                                item.CheckGroupVisIdx = stdCheckItem.CheckGroupVisIdx;
                                item.Source           = "检验标准-每天";
                                zySample.CheckItems.Add(item);
                            }
                        }
                    }
                }
            }
            else if (zySample.SampleType == SampleType.校验样)
            {
                //加载校验样项目
                QC_MixCheckItem_Table table = new QC_MixCheckItem_Table();
                table.LoadDataByWhere("main.SAMPLE_VEH_ID=(select SAMPLE_VEH_ID from QC_Sample_Veh veh where veh.SAMPLE_MIX_ID=@SAMPLE_MIX_ID)", zySample.Sample_Mix_ID);
                foreach (var item in table)
                {
                    item.Sample_Mix_ID = zySample.Sample_Mix_ID;
                    item.Source        = "校验样";
                    zySample.CheckItems.Add(item);
                }

                //DbContext.ExeSql("update t1 set t1.SAMPLE_MIX_ID =(select SAMPLE_MIX_ID from QC_Sample_Veh t2 where t2.SAMPLE_VEH_ID=t1.SAMPLE_VEH_ID) from QC_MIXCHECKITEM t1 where ISnull(t1.SAMPLE_VEH_ID,0)>0 and ISnull(t1.SAMPLE_MIX_ID,0)<=0");
            }

            //生成样品分类
            foreach (var item in zySample.CheckItems)
            {
                QC_MixCheckGroup mixCG = zySample.CheckGroups.FirstOrDefault <QC_MixCheckGroup>((mcg) => mcg.CheckGroupCode == item.CheckGroupCode);
                if (mixCG == null)
                {
                    mixCG = new QC_MixCheckGroup();
                    mixCG.CheckGroupCode = item.CheckGroupCode;
                    mixCG.CheckGroupName = item.CheckGroupName;
                    mixCG.CheckGroupType = item.CheckGroupType;
                    mixCG.CkgShortWord   = item.CkgShortWord;
                    mixCG.VisIdx         = item.CheckGroupVisIdx;
                    mixCG.StoreCode      = zySample.ZyDanHao + item.CkgShortWord;
                    mixCG.MatPK          = zySample.MatPK;
                    mixCG.SupplierCode   = zySample.SupplierCode;
                    mixCG.Sample_TBZD    = zySample.Sample_TBZD;
                    mixCG.Sample_Mix_ID  = zySample.Sample_Mix_ID;
                    mixCG.ZySample       = zySample;

                    zySample.CheckGroups.Add(mixCG);
                }
                mixCG.MixCheckItem.Add(item);
            }
            //加载物料设置样品分类
            DbEntityTable <QC_MatCheckGroup> MatCheckGroup = new DbEntityTable <QC_MatCheckGroup>();

            MatCheckGroup.LoadDataByWhere("MatNcId=@MatNcId", zySample.MatPK);
            for (int i = 0; i < MatCheckGroup.Count; i++)
            {
                QC_MixCheckGroup item = new QC_MixCheckGroup();
                item.CheckGroupCode = MatCheckGroup[i].CheckGroupCode;
                item.CheckGroupName = MatCheckGroup[i].CheckGroupName;
                item.CheckGroupType = MatCheckGroup[i].CheckGroupType;
                item.CkgShortWord   = MatCheckGroup[i].ShortWord;
                item.VisIdx         = MatCheckGroup[i].CheckGroupVisIdx;
                item.StoreCode      = zySample.ZyDanHao + MatCheckGroup[i].ShortWord;
                item.MatPK          = zySample.MatPK;
                item.SupplierCode   = zySample.SupplierCode;
                item.Sample_TBZD    = zySample.Sample_TBZD;
                item.Sample_Mix_ID  = zySample.Sample_Mix_ID;
                item.ZySample       = zySample;
                zySample.CheckGroups.Add(item);
            }

            zySample.CheckGroups.Sort((tx, ty) => tx.VisIdx.CompareTo(ty.VisIdx));
            foreach (var item in zySample.CheckGroups)
            {
                item.MatPK        = zySample.MatPK;
                item.SupplierCode = zySample.SupplierCode;
                item.Sample_TBZD  = zySample.Sample_TBZD;
                item.ZySample     = zySample;
                item.Billtype     = "未绑定样品扣";
                item.LabState     = "制样";
            }

            zySample.SaveCheckGroups = true;
            zySample.SaveCheckItems  = true;
            zySample.Save();


            //生成Lab
            foreach (var ckg in zySample.CheckGroups)
            {
                if (!ckg.CheckGroupName.Contains("角质层") && (ckg.CheckGroupType == "立刻检验" || ckg.CheckGroupType == "后续检验"))
                {
                    QC_Sample_Lab lb = new QC_Sample_Lab();
                    lb.MixCheckGroup.Add(ckg);
                    lb.StoreCode      = ckg.StoreCode;
                    lb.WpCode         = workpointCode;
                    lb.Billtype       = "未绑定样品扣";
                    lb.LabState       = "制样";
                    lb.WLLX           = zySample.WLLX;
                    lb.CheckGroupCode = ckg.CheckGroupCode;
                    lb.CheckGroupName = ckg.CheckGroupName;
                    lb.CheckGroupType = ckg.CheckGroupType;
                    lb.Sample_Mix_ID  = ckg.Sample_Mix_ID;
                    foreach (var ck in ckg.MixCheckItem)
                    {
                        QC_Sample_Value qcVal = new QC_Sample_Value();
                        qcVal.CheckItemNcId = ck.CheckItemNcId;
                        qcVal.CheckItemCode = ck.CheckItemCode;
                        qcVal.CheckItemName = ck.CheckItemName;
                        qcVal.ActualVal     = ck.ActualVal;
                        lb.CheckVals.Add(qcVal);
                    }
                    lb.SaveCheckVals = true;
                    zyMixSamples.LabTable.Add(lb);
                }
            }
            zyMixSamples.LabTable.Save();

            zyMixSamples.Add(zySample);

            //lblRecvDanHao.Text = zySample.ZyShortDanHao;
            this.gridView1.FocusedRowHandle = this.gridView1.GetRowHandle(zyMixSamples.Count - 1);
            LabTabs();
            rjmixs.LoadDataByWhere("main.SAMPLESTATE=@SAMPLESTATE and main.WLLX='熔剂'", SampleState.组批完成);
            comboBox1.Items.Clear();
            foreach (var item in rjmixs)
            {
                comboBox1.Items.Add(QC_Sample_Mix.ShortStoreCode(item.CardID));
            }
            this.printDocument1.Print();
        }
Exemple #8
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (this.curLab != null)
            {
                string head = QC_Sample_Mix.ShortStoreCode(this.curLab.JyCode);

                StringBuilder dyxm = new StringBuilder();
                foreach (var item in this.curLab.CheckVals)
                {
                    if (dyxm.Length > 0)
                    {
                        dyxm.Append(",");
                    }
                    dyxm.Append(item.CheckItemName);
                }
                dyxm.Append("(" + this.curLab.MatName + ")");

                Rectangle rect = new Rectangle(9, 3, 112, 94);

                Font  f2       = new System.Drawing.Font("宋体", 10.5f);
                SizeF bodySize = e.Graphics.MeasureString(dyxm.ToString(), f2);

                List <string> temp = new List <string>();

                StringBuilder line = new StringBuilder();
                for (int i = 0; i < dyxm.Length; i++)
                {
                    if (line.Length < 10)
                    {
                        line.Append(dyxm[i]);
                    }
                    else
                    {
                        SizeF lineSize = e.Graphics.MeasureString(line.ToString(), f2);
                        if (lineSize.Width < rect.Width - 8)
                        {
                            line.Append(dyxm[i]);
                            continue;
                        }
                        temp.Add(line.ToString());
                        line = new StringBuilder();
                    }
                }
                if (line.Length > 0)
                {
                    temp.Add(line.ToString());
                }

                int totalPages = 1;
                if (temp.Count > 3)
                {
                    totalPages = Convert.ToInt32(Math.Ceiling((temp.Count - 3) / 5.0)) + 1;
                }

                int printPage = totalPages - curPrintPage + 1;
                if (printPage <= 0)
                {
                    e.HasMorePages = false;
                    curPrintPage   = 1;
                }
                else if (printPage == 1)
                {
                    Font  f1         = new System.Drawing.Font("宋体", 20, FontStyle.Bold);
                    SizeF headSize   = e.Graphics.MeasureString(head, f1);
                    float leftMargin = rect.Left + (rect.Width - headSize.Width) / 2;

                    float height = headSize.Height;

                    for (int i = 0; i < 3 && i < temp.Count; i++)
                    {
                        height += bodySize.Height + 2;
                    }

                    float topMargin = rect.Top + (rect.Height - height) / 2;

                    e.Graphics.DrawString(head, f1, Brushes.Black, new PointF(leftMargin, topMargin));
                    topMargin += headSize.Height;

                    int row = 0;
                    for (; row < 3 && row < temp.Count; row++)
                    {
                        e.Graphics.DrawString(temp[row], f2, Brushes.Black, new PointF(4, topMargin));
                        topMargin += bodySize.Height + 2;
                    }

                    e.HasMorePages = false;
                    curPrintPage   = 1;
                }
                else
                {
                    int p    = printPage;
                    int i    = 3 + (p - 2) * 5;
                    int endi = i + 5;
                    int row  = i;

                    float height = 0;

                    for (; i < endi && i < temp.Count; i++)
                    {
                        height += bodySize.Height + 2;
                    }

                    float topMargin = rect.Top + (rect.Height - height) / 2;

                    for (; row < endi && row < temp.Count; row++)
                    {
                        e.Graphics.DrawString(temp[row], f2, Brushes.Black, new PointF(4, topMargin));
                        topMargin += bodySize.Height + 2;
                    }

                    e.HasMorePages = true;
                    curPrintPage++;
                }
            }
        }
Exemple #9
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            List <ZupiData> printData = new List <ZupiData>();

            foreach (var mix in printbill)
            {
                List <string> vehnos = new List <string>();
                DbEntityTable <QC_Sample_Veh> vehs = new DbEntityTable <QC_Sample_Veh>();
                vehs.LoadDataByWhere("main.Sample_Mix_ID=@Sample_Mix_ID order by begintime", mix.Sample_Mix_ID);
                //vehnos.Add(mix.SupplierName);
                vehnos.Add(mix.MatName);

                //if (mix.SampleType == SampleType.人工取样)
                //{
                //    vehnos.Add("人取"+"共" + vehs.Count+"车");
                //}
                //else if (mix.SampleType == SampleType.机器取样)
                //{
                //    vehnos.Add("机取" + "共" + vehs.Count + "车");
                //}
                //else if (mix.SampleType == SampleType.抽查样)
                //{
                //    vehnos.Add("抽查" + "共" + vehs.Count + "车");
                //}

                if (vehs.Count > 0)
                {
                    if (mix.SampleType == SampleType.人工取样)
                    {
                        vehnos.Add("人取" + "共" + vehs.Count + "车");
                    }
                    else if (mix.SampleType == SampleType.机器取样)
                    {
                        vehnos.Add("机取" + "共" + vehs.Count + "车");
                    }
                    else if (mix.SampleType == SampleType.抽查样)
                    {
                        vehnos.Add("抽查" + "共" + vehs.Count + "车");
                    }
                }
                else
                {
                    if (mix.SampleType == SampleType.人工取样)
                    {
                        vehnos.Add("人取");
                    }
                    else if (mix.SampleType == SampleType.机器取样)
                    {
                        vehnos.Add("机取");
                    }
                    else if (mix.SampleType == SampleType.抽查样)
                    {
                        vehnos.Add("抽查");
                    }
                }

                if (vehs.Count > 0)
                {
                    vehnos.Add(vehs[0].VehNo + "->" + vehs[vehs.Count - 1].VehNo);
                }

                //if (vehs.Count >0)
                //{
                //    vehnos.Add("共" + vehs.Count+"车");
                //}

                //foreach (var item in vehs)
                //{
                //    vehnos.Add(item.VehNo);

                //}

                if (vehnos.Count > 0)
                {
                    //ZupiData zd = new ZupiData();
                    //zd.Head = QC_Sample_Mix.ShortStoreCode(mix.CardID);
                    //zd.ZupiItems = vehnos;
                    //printData.Add(zd);
                    ZupiData pbzd = new ZupiData();
                    //编号
                    //pbzd.Head = QC_Sample_Mix.ShortStoreCode("HY" + mix.CardID.Remove(0, 2));
                    pbzd.Head      = QC_Sample_Mix.ShortStoreCode(mix.StoreCode);
                    pbzd.ZupiItems = vehnos;
                    printData.Add(pbzd);
                }
            }
            int totalPage = 1;

            foreach (var item in printData)
            {
                item.BeginPage = totalPage;
                totalPage     += item.NeadPage;
            }

            int printPage = totalPage - curZupiPrintPage;

            foreach (var item in printData)
            {
                if (printPage >= item.BeginPage && printPage < item.EndPage)
                {
                    item.Print(e.Graphics, printPage);
                    break;
                }
            }

            if (curZupiPrintPage < totalPage - 1)
            {
                curZupiPrintPage++;
                e.HasMorePages = true;
            }
            else
            {
                curZupiPrintPage = 1;
                e.HasMorePages   = false;
            }
        }