Exemplo n.º 1
0
		private void LoadList()
		{	
			Contacts clsContact = new Contacts();
			DataClass clsDataClass = new DataClass();
            ContactColumns clsContactColumns = new ContactColumns();
            clsContactColumns.ContactID = true;
            clsContactColumns.ContactCode = true;
            clsContactColumns.ContactName = true;
            clsContactColumns.CreditDetails = true;

            ContactColumns clsSearchColumns = new ContactColumns();
            clsSearchColumns.ContactCode = true;
            clsSearchColumns.ContactName = true;
            clsSearchColumns.CreditDetails = true;

			string SortField = "ContactID";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}
			
			System.Data.SqlClient.SortOrder sortoption = System.Data.SqlClient.SortOrder.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (System.Data.SqlClient.SortOrder) Enum.Parse(typeof(System.Data.SqlClient.SortOrder), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

            string SearchKey = string.Empty;
			if (Request.QueryString["Search"]!=null)
			{
                SearchKey = Common.Decrypt((string)Request.QueryString["search"],Session.SessionID);
                txtSearch.Text = SearchKey;
			}

            string strSearch = txtSearch.Text.Trim();

            DateTime dteExpiryDateFrom = DateTime.TryParse(txtExpiryDateFrom.Text, out dteExpiryDateFrom) ? dteExpiryDateFrom : DateTime.MinValue;
            DateTime dteExpiryDateTo = DateTime.TryParse(txtExpiryDateTo.Text, out dteExpiryDateTo) ? dteExpiryDateTo : DateTime.MinValue;
            CreditCardStatus enumCreditCardStatus = (CreditCardStatus)Enum.Parse(typeof(CreditCardStatus), cboCreditCardStatus.SelectedItem.Value);

            PageData.DataSource = clsContact.CustomersWithCredits(clsContactColumns, LastNameFrom: txtLastNameFrom.Text, LastNameTo: txtLastNameTo.Text, CustomerCode_CreditCardNo: strSearch, CreditCardExpiryDateFrom: dteExpiryDateFrom, CreditCardExpiryDateTo: dteExpiryDateTo, CreditCardStatus: enumCreditCardStatus, CreditCardTypeID: Int32.Parse(cboCreditType.SelectedItem.Value), CheckCustomersGuarantor: true, SortField: SortField, SortOrder: sortoption).DefaultView;
            
			clsContact.CommitAndDispose();

			int iPageSize = Convert.ToInt16(Session["PageSize"]) ;
			
			PageData.AllowPaging = true;
			PageData.PageSize = iPageSize;
			try
			{
				PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;				
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}
			catch
			{
				PageData.CurrentPageIndex = 1;
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}			
			
			cboCurrentPage.Items.Clear();
			for (int i=0; i < PageData.PageCount;i++)
			{
				int iValue = i + 1;
				cboCurrentPage.Items.Add(new ListItem(iValue.ToString(),iValue.ToString()));
				if (PageData.CurrentPageIndex == i)
				{	cboCurrentPage.Items[i].Selected = true;}
				else
				{	cboCurrentPage.Items[i].Selected = false;}
			}
			lblDataCount.Text = " of " + " " + PageData.PageCount;
		}
Exemplo n.º 2
0
        protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                LoadSortFieldOptions(e);
            }
            else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView dr = (DataRowView)e.Item.DataItem;
                ImageButton imgItemEdit = (ImageButton)e.Item.FindControl("imgItemEdit");
                ImageButton imgPrintBilling = (ImageButton)e.Item.FindControl("imgPrintBilling");

                HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
                chkList.Value = dr["ContactID"].ToString();
                if (chkList.Value == "1" || chkList.Value == "2")
                {
                    chkList.Attributes.Add("disabled", "false");
                    imgItemEdit.Enabled = false; imgItemEdit.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    imgPrintBilling.Enabled = false; ; imgPrintBilling.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                }
                else
                {
                    imgItemEdit.Enabled = cmdEdit.Visible; if (!imgItemEdit.Enabled) imgItemEdit.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    if (DateTime.Parse(dr["LastBillingDate"].ToString()) != DateTime.MinValue && DateTime.Parse(dr["LastBillingDate"].ToString()) != Constants.C_DATE_MIN_VALUE)
                    {
                        imgPrintBilling.Enabled = imgPrintBilling.Visible; if (!imgPrintBilling.Enabled) imgPrintBilling.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/print.gif";
                        imgPrintBilling.ToolTip = DateTime.Parse(dr["LastBillingDate"].ToString()).ToString("yyyy-MMM-dd");
                    }
                    else
                    {
                        imgPrintBilling.Enabled = false; ; imgPrintBilling.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                        imgPrintBilling.ToolTip = Constants.C_DATE_MIN_VALUE_STRING;
                    }
                }

                HyperLink lnkContactCode = (HyperLink)e.Item.FindControl("lnkContactCode");
                lnkContactCode.Text = dr["ContactCode"].ToString();
                lnkContactCode.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID);

                HyperLink lnkContactName = (HyperLink)e.Item.FindControl("lnkContactName");
                lnkContactName.Text = dr["ContactName"].ToString();
                lnkContactName.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID);

                Label lblCreditType = (Label)e.Item.FindControl("lblCreditType");
                lblCreditType.Text = dr["CardTypeCode"].ToString().ToString();

                //Label lblCreditCardNo = (Label)e.Item.FindControl("lblCreditCardNo");
                //lblCreditCardNo.Text = dr["CreditCardNo"].ToString();

                //Label lblCreditCardStatus = (Label)e.Item.FindControl("lblCreditCardStatus");
                //lblCreditCardStatus.Text = Enum.Parse(typeof(CreditCardStatus), dr["CreditCardStatus"].ToString()).ToString();

                //Label lblCreditActive = (Label)e.Item.FindControl("lblCreditActive");
                //lblCreditActive.Text = Data.Contacts.checkCreditActive((CreditCardStatus)Enum.Parse(typeof(CreditCardStatus), dr["CreditCardStatus"].ToString())) ? "Active" : "InActive";

                //Label lblExpiryDate = (Label)e.Item.FindControl("lblExpiryDate");
                //lblExpiryDate.Text = Convert.ToDateTime(dr["ExpiryDate"].ToString()).ToString("dd-MMM-yyyy");

                //decimal decCreditLimit = Convert.ToDecimal(dr["CreditLimit"].ToString());
                //decimal decCredit = Convert.ToDecimal(dr["Credit"].ToString());
                //decimal decAvailableCredit = decCreditLimit - decCredit;

                //Label lblCreditLimit = (Label)e.Item.FindControl("lblCreditLimit");
                //lblCreditLimit.Text = decCreditLimit.ToString("#,##0.#");

                //Label lblCredit = (Label)e.Item.FindControl("lblCredit");
                //lblCredit.Text = decCredit.ToString("#,##0.#");

                //Label lblAvailableCredit = (Label)e.Item.FindControl("lblAvailableCredit");
                //lblAvailableCredit.Text = decAvailableCredit.ToString("#,##0.#");

                //Label lblTotalPurchases = (Label)e.Item.FindControl("lblTotalPurchases");
                //lblTotalPurchases.Text = Convert.ToDecimal(dr["TotalPurchases"].ToString()).ToString("#,##0.#");

                //Label lblLastBillingDate = (Label)e.Item.FindControl("lblLastBillingDate");
                //lblLastBillingDate.Text = Convert.ToDateTime(dr["LastBillingDate"].ToString()).ToString("dd-MMM-yyyy");

                DataClass clsDataClass = new DataClass();
                ContactColumns clsContactColumns = new ContactColumns();
                clsContactColumns.ContactID = true;
                clsContactColumns.ContactCode = true;
                clsContactColumns.ContactName = true;
                clsContactColumns.CreditDetails = true;

                ContactColumns clsSearchColumns = new ContactColumns();
                clsSearchColumns.ContactCode = true;
                clsSearchColumns.ContactName = true;
                clsSearchColumns.CreditDetails = true;

                Int64 iGuarantorID = Int64.Parse(dr["ContactID"].ToString());
                DataList lstItemCustomer = (DataList)e.Item.FindControl("lstItemCustomer");

                if (iGuarantorID != 0)
                {
                    Contacts clsContact = new Contacts();
                    System.Data.DataTable dt = clsContact.CustomersWithCredits(clsContactColumns, GuarantorID: iGuarantorID, SortField: "CreditCardNo");
                    clsContact.CommitAndDispose();
                    lstItemCustomer.DataSource = dt.DefaultView;
                    lstItemCustomer.DataBind();
                    lstItemCustomer.Visible = true;
                }
                else
                {
                    lstItemCustomer.Visible = false;
                }
            }
        }
Exemplo n.º 3
0
        protected void cboContact_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            try
            {
                if (cboContact.SelectedItem.Value != Constants.ZERO_STRING)
                {
                    ContactColumns clsContactColumns = new ContactColumns();
                    clsContactColumns.ContactID = true;
                    clsContactColumns.ContactCode = true;
                    clsContactColumns.ContactName = true;
                    clsContactColumns.CreditDetails = true;

                    ContactColumns clsSearchColumns = new ContactColumns();
                    clsSearchColumns.ContactCode = true;
                    clsSearchColumns.ContactName = true;
                    clsSearchColumns.CreditDetails = true;

                    Int64 iGuarantorID = Int64.Parse(cboContact.SelectedItem.Value);

                    Contacts clsContact = new Contacts();
                    Data.ContactDetails clsContactDetails = clsContact.Details(iGuarantorID);
                    System.Data.DataTable dt = clsContact.CustomersWithCredits(clsContactColumns, iGuarantorID, SortField: "CreditCardNo"); //  "", dteExpiryDateFrom, dteExpiryDateTo, enumCreditCardStatus, Int32.Parse(cboCreditType.SelectedItem.Value), 
                    clsContact.CommitAndDispose();

                    lstItemCustomer.DataSource = dt.DefaultView;
                    lstItemCustomer.DataBind();

                    txtCreditCardTypeCode.Text = clsContactDetails.CreditDetails.CardTypeDetails.CardTypeCode;
                    txtCreditCardTypeCode.ToolTip = clsContactDetails.CreditDetails.CardTypeDetails.CardTypeID.ToString();

                    divGuarantorInfo.Visible = true;
                }
                else
                {
                    divGuarantorInfo.Visible = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }