Пример #1
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     crtCORecust2 rpt = new crtCORecust2();
     rpt.Site = this.Site;
     return rpt;
 }
Пример #2
0
        private void COReport_Load(object sender, EventArgs e)
        {
            if (Cas == 1)
            {
                String fname = @"ImageBarCode.jpg";
                String strData = strID + "";
                Image img = GenerateBarcode(strData, TYPE.CODE128);
                img.Save(fname);
                DataTable dtImg = DtImageForReport(fname, "DT_IMGBAR", "imgBar");

                //StockAsiaDrink.crtCOSent4 Crv = new StockAsiaDrink.crtCOSent4();
                //Crv.SetDataSource(Dt);
                //Crv.Subreports["DETAIL_SUB"].Database.Tables[0].SetDataSource(dtImg);
                //CtrReceiveSelect.ReportSource = Crv;
                //CtrReceiveSelect.Refresh();
                //CtrReceiveSelect.Show();
                StockAsiaDrink.crtCOSent5 Crv2 = new StockAsiaDrink.crtCOSent5();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 2)
            {
                StockAsiaDrink.crtCoBri Crv2 = new StockAsiaDrink.crtCoBri();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 3)
            {
                StockAsiaDrink.crtCORe Crv2 = new StockAsiaDrink.crtCORe();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 4)
            {
                crtCOCD Crv2 = new crtCOCD();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 44)
            {
                crtCOrr Crv2 = new crtCOrr();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 5)
            {
                //Transf.crtTRRE Crv2 = new Transf.crtTRRE();
                //Crv2.SetDataSource(Dt);
                //CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 6)
            {
                //Transf.crtTRSE Crv2 = new Transf.crtTRSE();
                //Crv2.SetDataSource(Dt);
                //CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 7)
            {
                String fname = @"ImageBarCode.jpg";
                String strData = strID + "";
                Image img = GenerateBarcode(strData, TYPE.CODE128);
                img.Save(fname);
                DataTable dtImg = DtImageForReport(fname, "DT_IMGBAR", "imgBar");

                crtCOREQ2 Crv2 = new crtCOREQ2();
                Crv2.SetDataSource(Dt);
                Crv2.Subreports["DETAIL_SUB"].Database.Tables[0].SetDataSource(dtImg);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 8)
            {
                //CtrCODetail2 Crv2 = new CtrCODetail2();
                //Crv2.SetDataSource(Dt);
                //CtrReceiveSelect.ReportSource = Crv2;
                //CtrReceiveSelect.Refresh();
                //CtrReceiveSelect.Show();
                //ReportDocument reportDocument = new CtrCODetail2();

                int cros_s = 0;
                int l1=1, l2=1, l3=1, l4=1, l5=1, l6=1;
                int s1 = 1, s2 = 1, s3 = 1;

                String fname = @"ImageBarCode.jpg";
                String strData = Dt.Rows[0]["ReceiveHeadId"].ToString() + "";
                Image img = GenerateBarcode(strData, TYPE.CODE128);
                img.Save(fname);
                DataTable dtImg = DtImageForReport(fname, "DT_IMGBAR", "imgBar");

                CtrCODetail2 Crv = new CtrCODetail2();

                if (Convert.ToDouble(Dt.Rows[0]["CompanyAddressEng"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l1 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["CompanyPhone"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l2 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["CompanyFax"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l3 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["CompanyCode"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l4 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["LocationProductName"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l5 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["CreditTerm"].ToString()) == 0) { cros_s = cros_s + 1; }
                else { l6 = 0; }

                if (Convert.ToDouble(Dt.Rows[0]["Dis"].ToString()) != 0) { s1 = 0; }
               // if (Convert.ToInt16(Dt.Rows[0]["Dis"].ToString()) != 0) { s1 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["Vat"].ToString()) != 0) { s2 = 0; }
                if (Convert.ToDouble(Dt.Rows[0]["DiscountBth"].ToString()) != 0) { s3 = 0; }

                //Line 1
                ReportObject field_before = Crv.ReportDefinition.ReportObjects["CompanyPhone1"];
                ReportObject text = Crv.ReportDefinition.ReportObjects["Text30"];
                ReportObject field_after = Crv.ReportDefinition.ReportObjects["CompanyNameEng7"];
                FieldObject fieldObject = (FieldObject)field_before;
                TextObject textObject = (TextObject)text;
                FieldObject field2Object = (FieldObject)field_after;
                int top = fieldObject.Top;
                fieldObject.Top = top - l1 * 360;
                textObject.Top = top - l1 * 360;
                field2Object.Top = top - l1 * 360;

                //Line 2
                ReportObject field_before1 = Crv.ReportDefinition.ReportObjects["CompanyFax1"];
                ReportObject text1 = Crv.ReportDefinition.ReportObjects["Text53"];
                ReportObject field_after1 = Crv.ReportDefinition.ReportObjects["CompanyNameEng8"];
                FieldObject fieldObject1 = (FieldObject)field_before1;
                TextObject textObject1 = (TextObject)text1;
                FieldObject field2Object1 = (FieldObject)field_after1;
                int top1 = fieldObject1.Top;
                fieldObject1.Top = top1 - (l1 + l2) * 360;
                textObject1.Top = top1 - (l1 + l2) * 360;
                field2Object1.Top = top1 - (l1 + l2) * 360;

                //Line 3
                ReportObject field_before2 = Crv.ReportDefinition.ReportObjects["CompanyCode1"];
                ReportObject text2 = Crv.ReportDefinition.ReportObjects["Text52"];
                ReportObject field_after2 = Crv.ReportDefinition.ReportObjects["CompanyNameEng9"];
                FieldObject fieldObject2 = (FieldObject)field_before2;
                TextObject textObject2 = (TextObject)text2;
                FieldObject field2Object2 = (FieldObject)field_after2;
                int top2 = fieldObject2.Top;
                fieldObject2.Top = top2 - (l1 + l2 + l3) * 360;
                textObject2.Top = top2 - (l1 + l2 + l3) * 360;
                field2Object2.Top = top2 - (l1 + l2 + l3) * 360;

                //Line 4
                ReportObject field_before3 = Crv.ReportDefinition.ReportObjects["LocationProductName1"];
                ReportObject text3 = Crv.ReportDefinition.ReportObjects["Text51"];
                ReportObject field_after3 = Crv.ReportDefinition.ReportObjects["CompanyNameEng10"];
                FieldObject fieldObject3 = (FieldObject)field_before3;
                TextObject textObject3 = (TextObject)text3;
                FieldObject field2Object3 = (FieldObject)field_after3;
                int top3 = fieldObject3.Top;
                fieldObject3.Top = top3 - (l1 + l2 + l3 + l4) * 360;
                textObject3.Top = top3 - (l1 + l2 + l3 + l4) * 360;
                field2Object3.Top = top3 - (l1 + l2 + l3 + l4) * 360;

                //Line 5
                ReportObject field_before4 = Crv.ReportDefinition.ReportObjects["CreditTerm1"];
                ReportObject text4 = Crv.ReportDefinition.ReportObjects["Text50"];
                ReportObject field_after4 = Crv.ReportDefinition.ReportObjects["CompanyNameEng11"];
                FieldObject fieldObject4 = (FieldObject)field_before4;
                TextObject textObject4 = (TextObject)text4;
                FieldObject field2Object4 = (FieldObject)field_after4;
                int top4 = fieldObject4.Top;
                fieldObject4.Top = top4 - (l1 + l2 + l3 + l4 + l5) * 360;
                textObject4.Top = top4 - (l1 + l2 + l3 + l4 + l5) * 360;
                field2Object4.Top = top4 - (l1 + l2 + l3 + l4 + l5) * 360;

                //Line 6
                ReportObject field_before5 = Crv.ReportDefinition.ReportObjects["sumtotal1"];
                ReportObject text5 = Crv.ReportDefinition.ReportObjects["Text47"];
                ReportObject field_after5 = Crv.ReportDefinition.ReportObjects["CompanyNameEng12"];
                FieldObject fieldObject5 = (FieldObject)field_before5;
                TextObject textObject5 = (TextObject)text5;
                FieldObject field2Object5 = (FieldObject)field_after5;
                int top5 = fieldObject5.Top;
                fieldObject5.Top = top5 - (l1 + l2 + l3 + l4 + l5 + l6) * 360;
                textObject5.Top = top5 - (l1 + l2 + l3 + l4 + l5 + l6) * 360;
                field2Object5.Top = top5 - (l1 + l2 + l3 + l4 + l5 + l6) * 360;

                //Sum Price
                //Line S 1
                ReportObject field_s1 = Crv.ReportDefinition.ReportObjects["Vat1"];
                ReportObject text_s1 = Crv.ReportDefinition.ReportObjects["RateVat1"];
                ReportObject field_sa1 = Crv.ReportDefinition.ReportObjects["CompanyNameEng3"];
                FieldObject fieldObject_s1 = (FieldObject)field_s1;
                FieldObject textObject_s1 = (FieldObject)text_s1;
                FieldObject field2Object_s1 = (FieldObject)field_sa1;
                int top_s1 = fieldObject_s1.Top;
                fieldObject_s1.Top = top_s1 - (s1) * 360;
                textObject_s1.Top = top_s1 - (s1) * 360;
                field2Object_s1.Top = top_s1 - (s1) * 360;
                //Line S 2
                ReportObject field_s2 = Crv.ReportDefinition.ReportObjects["DiscountBth1"];
                ReportObject text_s2 = Crv.ReportDefinition.ReportObjects["Text13"];
                ReportObject field_sa2 = Crv.ReportDefinition.ReportObjects["CompanyNameEng4"];
                FieldObject fieldObject_s2 = (FieldObject)field_s2;
                TextObject textObject_s2 = (TextObject)text_s2;
                FieldObject field2Object_s2 = (FieldObject)field_sa2;
                int top_s2 = fieldObject_s2.Top;
                fieldObject_s2.Top = top_s2 - (s1 + s2) * 360;
                textObject_s2.Top = top_s2 - (s1 + s2) * 360;
                field2Object_s2.Top = top_s2 - (s1 + s2) * 360;
                //Line S 3
                ReportObject field_s3 = Crv.ReportDefinition.ReportObjects["TotalPrice1"];
                ReportObject text_s3 = Crv.ReportDefinition.ReportObjects["Text12"];
                ReportObject field_sa3 = Crv.ReportDefinition.ReportObjects["CompanyNameEng5"];
                FieldObject fieldObject_s3 = (FieldObject)field_s3;
                TextObject textObject_s3 = (TextObject)text_s3;
                FieldObject field2Object_s3 = (FieldObject)field_sa3;
                int top_s3 = fieldObject_s3.Top;
                fieldObject_s3.Top = top_s3 - (s1 + s2 + s3) * 360;
                textObject_s3.Top = top_s3 - (s1 + s2 + s3) * 360;
                field2Object_s3.Top = top_s3 - (s1 + s2 + s3) * 360;
                //End sum price
                //Point under line
                ReportObject UnderLine = Crv.ReportDefinition.ReportObjects["Text48"];
                TextObject TextUndetLine = (TextObject)UnderLine;

                ReportObject VerticleLine2 = Crv.ReportDefinition.ReportObjects["Line2"];
                LineObject BVerticleLine2 = (LineObject)VerticleLine2;

                ReportObject VerticleLine1 = Crv.ReportDefinition.ReportObjects["Line1"];
                LineObject BVerticleLine1 = (LineObject)VerticleLine1;

                if (fieldObject5.Top > fieldObject_s3.Top)
                {
                    if (fieldObject5.Top < 2000)
                    {
                        TextUndetLine.Top = 2160;
                        BVerticleLine2.Bottom = 2310;
                        BVerticleLine1.Bottom = 2310;
                    }
                    else
                    {
                        TextUndetLine.Top = textObject5.Top + 100;
                        BVerticleLine2.Bottom = textObject5.Top + 250;
                        BVerticleLine1.Bottom = textObject5.Top + 250;
                    }
                }
                else
                {
                    if (fieldObject_s3.Top < 2000)
                    {
                        TextUndetLine.Top = 2160;
                        BVerticleLine2.Bottom = 2310;
                        BVerticleLine1.Bottom = 2310;
                    }
                    else
                    {
                        TextUndetLine.Top = fieldObject_s3.Top + 100;
                        BVerticleLine2.Bottom = fieldObject_s3.Top + 250;
                        BVerticleLine1.Bottom = fieldObject_s3.Top + 250;
                    }
                }

                //End point under line

                Crv.SetDataSource(Dt);
                Crv.Subreports["Img_Barcode"].Database.Tables[0].SetDataSource(dtImg);
                CtrReceiveSelect.ReportSource = Crv;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 9)
            {
                crtCORecust2 Crv2 = new crtCORecust2();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 10)
            {
                crtStockKey Crv2 = new crtStockKey();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 11)
            {
                crtStockKey Crv2 = new crtStockKey();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
            else if (Cas == 12)
            {
                StockAsiaDrink.crtCoBri Crv2 = new StockAsiaDrink.crtCoBri();
                Crv2.SetDataSource(Dt);
                CtrReceiveSelect.ReportSource = Crv2;
                CtrReceiveSelect.Refresh();
                CtrReceiveSelect.Show();
            }
        }