Пример #1
0
        public int InsertBarTenderPrintingLable(int productid, string formatname, int chk)
        {
            try
            {
                string  btFileName = "";
                LogFile lf         = new LogFile();

                using (Engine btEngine = new Engine())
                {
                    lf.LogMessge("S1 :" + "Inside Service");
                    btEngine.Start();
                    lf.LogMessge("S2 :" + "Service Started");
                    btEngine.Window.Visible = true;

                    // btFileName = @"\\glpdc01\corp\IT Files\GPLS\BarTenderFiles\" + filename + ".btw";

                    //btFileName = @"\\psapp01\IT Files\PLS\BarTenderFiles\" + filename + ".btw";
                    btFileName = @"\\psapp01\IT Files\PLS\BarTenderFilesTest01\" + formatname + ".btw";
                    lf.LogMessge("S3 :" + "File Path");
                    lf.LogMessge("S4 :" + "File :" + btFileName);
                    LabelFormatDocument btFormat = btEngine.Documents.Open(btFileName);
                    lf.LogMessge("S5 :" + "Go the File");
                    Seagull.BarTender.Print.Database.QueryPrompts queryprompts = btFormat.DatabaseConnections.QueryPrompts;
                    queryprompts["productid"].Value = productid.ToString();
                    queryprompts["chk"].Value       = chk.ToString();

                    lf.LogMessge("S6 :" + "Query Promted");
                    //btFormat.PrintSetup.IdenticalCopiesOfLabel = labelcount;
                    //btFormat.PrintSetup.NumberOfSerializedLabels = 4
                    Result result = btFormat.Print(btFileName);
                    lf.LogMessge("S7 :" + "Result: " + result);
                    //Result result = btFormat.Print();
                    if (result == Result.Failure)
                    {
                        lf.LogMessge("S8 :" + "Failure ");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(0);
                    }
                    else
                    {
                        lf.LogMessge("S9 :" + "Sucess ");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(1);
                    }
                }
            }
            catch (Exception ex)
            {
                LogFile lf1 = new LogFile();
                lf1.LogMessge("S10 :" + "Exception Date :" + DateTime.Now.ToLongTimeString() + "\nException  Message:" + ex.Message);
                // Page.ClientScript.RegisterStartupScript(this.GetType(), "log", "log('" + ex.Message + "');", true);
                return(0);
            }
        }
Пример #2
0
        public int BarTenderPrintingLable(int controlId, int labelcount, int categorycode, string filename, int batchid, int testprint)
        {
            try
            {
                string  btFileName = "";
                LogFile lf         = new LogFile();
                using (Engine btEngine = new Engine())
                {
                    lf.LogMessge("S1 :" + "Inside Service");
                    btEngine.Start();
                    lf.LogMessge("S2 :" + "Service Started");
                    btEngine.Window.Visible = true;

                    // btFileName = @"\\psapp01\IT Files\PLS\BarTenderFilesTes1\" + filename + ".btw";
                    btFileName = @"\\psapp01\IT Files\PLS\BarTenderFiles\" + filename + ".btw";
                    lf.LogMessge("S4 :" + "File :" + btFileName);
                    LabelFormatDocument btFormat = btEngine.Documents.Open(btFileName);
                    lf.LogMessge("S3 :" + "File Path");
                    lf.LogMessge("S4 :" + "File :" + btFileName);

                    Seagull.BarTender.Print.Database.QueryPrompts queryprompts = btFormat.DatabaseConnections.QueryPrompts;
                    lf.LogMessge("S5 :" + "Go the File");
                    queryprompts["controlid"].Value    = controlId.ToString();
                    queryprompts["categorycode"].Value = categorycode.ToString();
                    queryprompts["toprint"].Value      = labelcount.ToString();
                    queryprompts["batchid"].Value      = batchid.ToString();
                    queryprompts["testprint"].Value    = testprint.ToString();
                    lf.LogMessge("S6 :" + "Query Promted");
                    //btFormat.PrintSetup.IdenticalCopiesOfLabel = labelcount;
                    //btFormat.PrintSetup.NumberOfSerializedLabels = 4
                    Result result = btFormat.Print(btFileName);
                    lf.LogMessge("S7 :" + "Result: " + result);
                    //Result result = btFormat.Print();
                    if (result == Result.Failure)
                    {
                        lf.LogMessge("S8 :" + "Failure ");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(0);
                    }
                    else
                    {
                        lf.LogMessge("S9 :" + "Sucess ");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(1);
                    }
                }
            }
            catch (Exception ex)
            {
                LogFile lf1 = new LogFile();
                lf1.LogMessge("S10 :" + "Exception Date :" + DateTime.Now.ToLongTimeString() + "\nException  Message:" + ex.Message);
                return(0);
            }
        }
Пример #3
0
        public void BarTenderPrintingLable(int id)
        {
            try
            {
                DataTable dt = new DataTable();
                //SqlCommand cmd = new SqlCommand("dbo.spLabelingReportPreview", conn);
                //cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Parameters.AddWithValue("@ControlID", id);
                //SqlDataAdapter da = new SqlDataAdapter(cmd);
                //da.Fill(dt);
                dt = st_dll.ReportData("dbo.spLabelingReportPreview", id, 4);
                DataRow row = dt.Rows[0];
                using (Engine btEngine = new Engine())
                {
                    btEngine.Start();
                    //btEngine.Window.Visible = true;
                    string btFileName = "";
                    btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\Product_Label.btw";
                    //btFileName = @"C:\Users\samancha\Desktop\Product_Label.btw";
                    LabelFormatDocument btFormat = btEngine.Documents.Open(btFileName);
                    Seagull.BarTender.Print.Database.QueryPrompts queryprompts = btFormat.DatabaseConnections.QueryPrompts;
                    queryprompts["controlid"].Value            = id.ToString();
                    btFormat.PrintSetup.IdenticalCopiesOfLabel = Convert.ToInt32(dt.Rows[0]["LabelCount"]);

                    Result result = btFormat.Print(btFileName);
                    //Result result = btFormat.Print();

                    if (result == Result.Failure)
                    {
                        //string Message = "Label is printed Failure";
                        //string wsScript = "<script type=\"text/javascript\">document.getElementById('#divfailure').style.display='block';document.getElementById('#divfailure').InnerHtml ='" + Message + "'</script>";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "validation", wsScript, true);

                        SucessMessage("Label is printed successfully !");
                    }

                    else
                    {
                        //string Message = "Label is printed Successfully";
                        //string wsScript = "<script type=\"text/javascript\">document.getElementById('#divAdded').style.display='block';document.getElementById('#divAdded').InnerHtml ='" + Message + "'</script>";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "validation", wsScript, true);
                        ErrorMessage("Failed to print the label !");
                    }

                    btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                    btEngine.Stop();
                }
            }
            catch (Exception ex)
            {
                ErrorMessage(ex.Message);
            }
        }
Пример #4
0
        //protected void btnPrint_Click(object sender, EventArgs e)
        //{
        //    btnPrint.Enabled = false;
        //    DataTable dt = st_dll.GetLabelCountData("dbo.spGenerateLabels", "C", controlId, categorycode);
        //    if (Convert.ToInt32(dt.Rows[0]["LabelCount"]) > 0)
        //    {
        //        ProductsEntity pe = new ProductsEntity();
        //        pe.ControlID = controlId;
        //        pe.PrintedByID = Convert.ToInt32(Session["UserID"]);
        //        pe.categorycode = categorycode;


        //        int print_result = BarTenderPrintingLable(controlId, Convert.ToInt32(dt.Rows[0]["LabelCount"]), categorycode);
        //        if (print_result != 0)
        //        {
        //            int result = st_dll.UpdatePrinting("dbo.spUpdatePrinting", pe);

        //            if (result != 0)
        //            {
        //                if (categorycode == 2)
        //                {
        //                    ProductsEntity pe1 = new ProductsEntity();
        //                    pe1.ControlID = controlId;
        //                    pe1.PrintedByID = Convert.ToInt32(Session["UserID"]);
        //                    pe1.categorycode = 3;
        //                    DataTable dt2 = st_dll.GetLabelCountData("dbo.spGenerateLabels", "C", controlId, 3);
        //                    System.Threading.Thread.Sleep(2000);
        //                    int case_result = BarTenderPrintingLable(controlId, Convert.ToInt32(dt2.Rows[0]["LabelCount"]), 3);
        //                    //DelayMethod(controlId, Convert.ToInt32(dt2.Rows[0]["LabelCount"]), categorycode);
        //                    if (case_result != 0) {
        //                        st_dll.UpdatePrinting("dbo.spUpdatePrinting", pe1);
        //                    }
        //                }
        //                BindGrid(1,100);
        //                CheckLabelPrint(controlId, categorycode);
        //                SucessMessage("The labels are printed successfully!");
        //            }
        //            else {
        //                ErrorMessage("Failed to Save the Print Data!");
        //            }
        //        }
        //        else {

        //            ErrorMessage("Failed to Print the Label in BarTender!");
        //        }
        //    }
        //    else {
        //        ErrorMessage("All labels are printed!");
        //    }
        //    btnPrint.Enabled = true;
        //}

        //public void DelayMethod(int ControlID,int labelcount,int categorycode)
        //{
        //    System.Threading.Timer timer = null;
        //    timer = new System.Threading.Timer((obj) =>
        //    {
        //        BarTenderPrintingLable(ControlID, labelcount, categorycode);
        //        timer.Dispose();
        //    },
        //                null, 1000, System.Threading.Timeout.Infinite);
        //}

        public int BarTenderPrintingLable(int controlId, int labelcount, int categorycode)
        {
            try
            {
                //DataTable dt = new DataTable();
                //dt = st_dll.ReportData("dbo.spLabelingReportPreview", controlId, categorycode);
                //DataRow row = dt.Rows[0];
                string btFileName = "";
                string fileName   = "";
                using (Engine btEngine = new Engine())
                {
                    btEngine.Start();
                    btEngine.Window.Visible = true;
                    if (categorycode == 3)
                    {
                        if (ddlLabelFormats.SelectedValue == "0")
                        {
                            fileName   = st_dll.GetCaseFileName("dbo.spGetCaseFileName", controlId, categorycode);
                            btFileName = @"\\glpdc01\corp\IT Files\GPLS\BarTenderFiles\" + fileName + ".btw";
                        }
                        else
                        {
                            //fileName = ddlLabelFormats.SelectedItem.Text;
                            fileName   = ddlLabelFormats.SelectedValue.ToString();
                            btFileName = @"\\glpdc01\corp\IT Files\GPLS\BarTenderFiles\" + fileName + ".btw";
                        }
                    }
                    else
                    {
                        //fileName = ddlLabelFormats.SelectedItem.Text;
                        fileName = ddlLabelFormats.SelectedValue.ToString();
                        // btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\" + fileName + ".btw";
                        btFileName = @"\\glpdc01\corp\IT Files\GPLS\BarTenderFiles\" + fileName + ".btw";
                    }

                    //if (categorycode == 1 || categorycode == 4)
                    //{ //Product Label
                    //    int unitsize = st_dll.GetUnitSize(controlId);
                    //    string itemdesc = st_dll.GetItemDesc(controlId);
                    //    if (unitsize != 0)
                    //    {
                    //        btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\ProductLabel_New.btw";
                    //    }

                    //    else {
                    //        btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\ProductLabel_New_ItemDesc.btw";
                    //    }

                    //}
                    //else if (categorycode == 2)
                    //{ //Insert Box Label
                    //    btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\InsertLabel_New.btw";
                    //}
                    //else if (categorycode == 3)
                    //{ //Case Label
                    //    btFileName = @"\\GLWS18\Users\samancha\Documents\BarTender\BarTenderDocuments\CaseLabel_New.btw";
                    //}

                    // btFileName = @"C:\Users\samancha\Desktop\Product_Label.btw";
                    LabelFormatDocument btFormat = btEngine.Documents.Open(btFileName);
                    Seagull.BarTender.Print.Database.QueryPrompts queryprompts = btFormat.DatabaseConnections.QueryPrompts;
                    queryprompts["controlid"].Value    = controlId.ToString();
                    queryprompts["categorycode"].Value = categorycode.ToString();
                    queryprompts["toprint"].Value      = labelcount.ToString();
                    //btFormat.PrintSetup.IdenticalCopiesOfLabel = labelcount;
                    //btFormat.PrintSetup.NumberOfSerializedLabels = 4
                    Result result = btFormat.Print(btFileName);
                    //Result result = btFormat.Print();

                    if (result == Result.Failure)
                    {
                        //string Message = "Label is printed Failure";
                        //string wsScript = "<script type=\"text/javascript\">document.getElementById('#divfailure').style.display='block';document.getElementById('#divfailure').InnerHtml ='" + Message + "'</script>";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "validation", wsScript, true);

                        //SucessMessage("Label is printed Successfully !");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(0);
                    }

                    else
                    {
                        //string Message = "Label is printed Successfully";
                        //string wsScript = "<script type=\"text/javascript\">document.getElementById('#divAdded').style.display='block';document.getElementById('#divAdded').InnerHtml ='" + Message + "'</script>";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "validation", wsScript, true);
                        //ErrorMessage("Failed to Print the Label !");
                        btFormat.Close(Seagull.BarTender.Print.SaveOptions.DoNotSaveChanges);
                        btEngine.Stop();
                        btEngine.Dispose();
                        return(1);
                    }
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }