Ejemplo n.º 1
0
        private Boolean PrintBilling(System.Web.UI.Control sender)
        {
            bool boRetValue = false;

            int iPrintedBills = 0, iBills = 0;

            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                
                if (chkList != null)
                {
                    if (chkList.Checked == true)
                    {
                        iBills++;
                        ImageButton imgPrintBilling = (ImageButton) item.FindControl("imgPrintBilling");
                        if (DateTime.Parse(imgPrintBilling.ToolTip) != DateTime.MinValue && DateTime.Parse(imgPrintBilling.ToolTip) != Constants.C_DATE_MIN_VALUE)
                        {
                            Billing clsBilling = new Billing();
                            System.Data.DataTable dt = clsBilling.ListBillingDateAsDataTable(CreditType.Group, long.Parse(chkList.Value), DateTime.Parse(imgPrintBilling.ToolTip));
                            clsBilling.CommitAndDispose();

                            if (dt.Rows.Count > 0)
                            {
                                if (dt.Rows[0]["BillingFile"].ToString().IndexOf(".pdf") > -1)
                                {
                                 if (PdfHelper.PrintPDFs(Constants.ROOT_DIRECTORY_BILLING_WithG + "/" + dt.Rows[0]["BillingFile"].ToString()))
                                    iPrintedBills++;
                                }
                                else
                                {
                                    if (PrinterHelper.PrintFile(Constants.ROOT_DIRECTORY_BILLING_WithG + "/" + dt.Rows[0]["BillingFile"].ToString()))
                                        iPrintedBills++;
                                }
                            }
                        }
                        boRetValue = true;
                    }
                }
            }

            if (boRetValue)
            {
                string javaScript = "window.alert(" + iPrintedBills.ToString() + "/" + iBills.ToString() + " bills has been successfully printed.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(sender, sender.GetType(), "openwindow", javaScript, true);
            }
            else
            {
                string javaScript = "window.alert('Sorry there was no billing file to print.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(sender, sender.GetType(), "openwindow", javaScript, true);
            }
            return boRetValue;
        }
Ejemplo n.º 2
0
        protected void lstItem_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
            string stParam = string.Empty;
            switch (e.CommandName)
            {
                case "imgItemEdit":
                    stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID);
                    Response.Redirect("Default.aspx" + stParam);
                    break;

                case "imgPrintBilling":
                    ImageButton imgPrintBilling = (ImageButton)e.Item.FindControl("imgPrintBilling");
                    if (DateTime.Parse(imgPrintBilling.ToolTip) != DateTime.MinValue && DateTime.Parse(imgPrintBilling.ToolTip) != Constants.C_DATE_MIN_VALUE)
                    {
                        Billing clsBilling = new Billing();
                        System.Data.DataTable dt = clsBilling.ListBillingDateAsDataTable(CreditType.Group, long.Parse(chkList.Value), DateTime.Parse(imgPrintBilling.ToolTip));
                        clsBilling.CommitAndDispose();

                        if (dt.Rows.Count > 0)
                        {
                            string newWindowUrl = Constants.ROOT_DIRECTORY_BILLING_WithG + "/" + dt.Rows[0]["BillingFile"].ToString();
                            string javaScript = "window.open('" + newWindowUrl + "','_blank');";
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.lstItem, this.lstItem.GetType(), "openwindow", javaScript, true);
                        }
                    }
                    else
                    {
                        string javaScript = "window.alert('Sorry there is no billing file to print.');";
                        System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.lstItem, this.lstItem.GetType(), "openwindow", javaScript, true);
                    }
                    break;
                case "imgUpdateCardType":
                    stParam = "?task=" + Common.Encrypt("changecardtype", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID);
                    Response.Redirect("Default.aspx" + stParam);
                    break;
            }
        }