Exemplo n.º 1
0
        private void LoadOptions()
        {
            Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["id"], Session.SessionID));
            lblContactID.Text = iID.ToString();

            ContactGroups clsContactGroup = new ContactGroups();

            cboGroup.DataTextField = "ContactGroupName";
            cboGroup.DataValueField = "ContactGroupID";
            cboGroup.DataSource = clsContactGroup.ListAsDataTable().DefaultView;
            cboGroup.DataBind();
            cboGroup.SelectedIndex = cboGroup.Items.Count - 1;

            Department clsDepartment = new Department(clsContactGroup.Connection, clsContactGroup.Transaction);
            cboDepartment.DataTextField = "DepartmentName";
            cboDepartment.DataValueField = "DepartmentID";
            cboDepartment.DataSource = clsDepartment.ListAsDataTable().DefaultView;
            cboDepartment.DataBind();
            cboDepartment.SelectedIndex = 0;

            Positions clsPosition = new Positions(clsContactGroup.Connection, clsContactGroup.Transaction);
            cboPosition.DataTextField = "PositionName";
            cboPosition.DataValueField = "PositionID";
            cboPosition.DataSource = clsPosition.ListAsDataTable("PositionName", SortOption.Ascending, 0).DefaultView;
            cboPosition.DataBind();
            cboPosition.SelectedIndex = 0;

            cboCreditCardStatus.Items.Clear();
            foreach (CreditCardStatus selection in Enum.GetValues(typeof(CreditCardStatus)))
            {
                cboCreditCardStatus.Items.Add(new ListItem(selection.ToString("G"), selection.ToString("d")));
            }
            cboCreditCardStatus.SelectedIndex = cboCreditCardStatus.Items.IndexOf(cboCreditCardStatus.Items.FindByValue(CreditCardStatus.All.ToString("d")));

            Data.CardType clsCardType = new Data.CardType(clsContactGroup.Connection, clsContactGroup.Transaction);
            cboCreditCardType.Items.Clear();
            cboCreditCardType.DataTextField = "CardTypeName";
            cboCreditCardType.DataValueField = "CardTypeID";
            cboCreditCardType.DataSource = clsCardType.ListAsDataTable(new CardTypeDetails(CreditCardTypes.Internal)).DefaultView;
            cboCreditCardType.DataBind();
            cboCreditCardType.SelectedIndex = 0;

            Billing clsBilling = new Billing(clsContactGroup.Connection, clsContactGroup.Transaction);
            cboBillingDate.DataTextField = "BillingDate";
            cboBillingDate.DataValueField = "BillingFile";
            cboBillingDate.DataSource = clsBilling.ListBillingDateAsDataTable(CreditType.Individual, long.Parse(lblContactID.Text), limit: 10).DefaultView;
            cboBillingDate.DataBind();
            cboBillingDate.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, Constants.PLEASE_SELECT));
            cboBillingDate.SelectedIndex = 0;

            Salutation clsSalutation = new Salutation(clsContactGroup.Connection, clsContactGroup.Transaction);
            cboSalutation.DataTextField = "SalutationName";
            cboSalutation.DataValueField = "SalutationCode";
            cboSalutation.DataSource = clsSalutation.ListAsDataTable().DefaultView;
            cboSalutation.DataBind();
            cboSalutation.SelectedIndex = 0;
            cboSalutation.SelectedIndex = cboSalutation.Items.IndexOf(cboSalutation.Items.FindByValue("MR"));

            clsContactGroup.CommitAndDispose();
        }
Exemplo 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;
            }
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
		private void LoadOptions()
		{
            cboReportType.Items.Clear();
            cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION, ReportTypes.REPORT_SELECTION));
            cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR));
            cboReportType.Items.Add(new ListItem(ReportTypes.CREDITS_Purchases, ReportTypes.CREDITS_Purchases));
            cboReportType.Items.Add(new ListItem(ReportTypes.CREDITS_Payments, ReportTypes.CREDITS_Payments));
            cboReportType.Items.Add(new ListItem(ReportTypes.CREDITS_CreditorsLedgerSummary, ReportTypes.CREDITS_CreditorsLedgerSummary));
            cboReportType.Items.Add(new ListItem(ReportTypes.REPORT_SELECTION_SEPARATOR, ReportTypes.REPORT_SELECTION_SEPARATOR));
            cboReportType.Items.Add(new ListItem(ReportTypes.CustomerCreditSummarizedStatistics, ReportTypes.CustomerCreditSummarizedStatistics));
            cboReportType.SelectedIndex = 0;

            if (Request.QueryString["reporttype"] != null)
            {
                lblReportType.Text = Common.Decrypt(Request.QueryString["reporttype"].ToString(), Session.SessionID);

                switch (lblReportType.Text.ToLower())
                {
                    case "purchases": cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.CREDITS_Purchases)); break;
                    case "payments": cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.CREDITS_Payments)); break;
                    case "ledger": cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.CREDITS_CreditorsLedgerSummary)); break;
                    case "stat": cboReportType.SelectedIndex = cboReportType.Items.IndexOf(cboReportType.Items.FindByValue(ReportTypes.CustomerCreditSummarizedStatistics)); break;
                    default:
                        break;
                }
            }

            Data.CardType clsCardType = new Data.CardType();
            cboCreditType.Items.Clear();
            cboCreditType.DataTextField = "CardTypeCode";
            cboCreditType.DataValueField = "CardTypeID";
            cboCreditType.DataSource = clsCardType.ListAsDataTable(new CardTypeDetails(CreditCardTypes.Internal, false)).DefaultView;
            cboCreditType.DataBind();
            cboCreditType.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING));
            cboCreditType.SelectedIndex = cboCreditType.Items.Count >= 2 ? 1 : 0;


            Branch clsBranch = new Branch(clsCardType.Connection, clsCardType.Transaction);
            cboBranch.DataTextField = "BranchCode";
            cboBranch.DataValueField = "BranchID";
            cboBranch.DataSource = clsBranch.ListAsDataTable().DefaultView;
            cboBranch.DataBind();
            cboBranch.Items.Insert(0, new ListItem(Constants.ALL, Constants.ZERO_STRING));
            cboBranch.SelectedIndex = 0;

            Billing clsBilling = new Billing(clsCardType.Connection, clsCardType.Transaction);
            cboBillingDate.DataTextField = "BillingDate";
            cboBillingDate.DataValueField = "BillingDate";
            cboBillingDate.DataSource = clsBilling.ListBillingDateAsDataTable(CreditType.Individual, CreditCardTypeID: Int16.Parse(cboCreditType.SelectedItem.Value)).DefaultView;
            cboBillingDate.DataBind();
            cboBillingDate.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, Constants.C_DATE_MIN_VALUE_STRING));
            cboBillingDate.SelectedIndex = cboBillingDate.Items.Count >= 2 ? 1 : 0;

            clsCardType.CommitAndDispose();

            txtTrxStartDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
            txtTrxEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd");

            cboReportType_SelectedIndexChanged(null, null);
        }