Esempio n. 1
0
		private void LoadList()
		{	
			Payments clsPayments = new Payments();
			DataClass clsDataClass = new DataClass();

			string SortField = "PaymentID";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}

			SortOption sortoption = SortOption.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

			if (Request.QueryString["Search"]==null)
			{
				PageData.DataSource = clsDataClass.DataReaderToDataTable(clsPayments.List(SortField, sortoption)).DefaultView;
			}
			else
			{						
				string SearchKey = Common.Decrypt((string)Request.QueryString["search"],Session.SessionID);
				PageData.DataSource = clsDataClass.DataReaderToDataTable(clsPayments.Search(SearchKey, SortField, sortoption)).DefaultView;
			}
			
			clsPayments.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;
		}
Esempio n. 2
0
		private bool Cancel()
		{
			bool boRetValue = false;
			string stIDs = "";

			foreach(DataListItem item in lstItem.Items)
			{
				HtmlInputCheckBox chkList = (HtmlInputCheckBox) item.FindControl("chkList");
				if (chkList!=null)
				{
					if (chkList.Checked == true)
					{
						stIDs += chkList.Value + ",";		
						boRetValue = true;
					}
				}
			}
			if (boRetValue)
			{
				Payments clsPayments = new Payments();
				clsPayments.Cancel( stIDs.Substring(0,stIDs.Length-1));
				clsPayments.CommitAndDispose();
			}

			return boRetValue;
		}
Esempio n. 3
0
        private void PostInvoice()
        {
            try
            {
                decimal decTotalAmount = Convert.ToDecimal(lblTotalAmount.Text);

                if (decTotalAmount == 0)
                {
                    decimal decTotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text);

                    foreach (DataListItem item in lstPO.Items)
                    {
                        HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                        if (chkList != null)
                        {
                            if (chkList.Checked == true)
                            {
                                Label lblUnpaidAmount = (Label)item.FindControl("lblUnpaidAmount");
                                decimal decUnpaidAmount = Convert.ToDecimal(lblUnpaidAmount.Text);

                                if (decTotalDebitAmount == 0)
                                { break; }
                                else if (decTotalDebitAmount >= decUnpaidAmount)
                                { decTotalDebitAmount -= decUnpaidAmount; }
                                else if (decTotalDebitAmount != 0)
                                { decTotalDebitAmount = 0; break; }
                            }
                        }
                    }
                    if (decTotalDebitAmount > 0)
                    {
                        lblReferrer.Text = "Warning!!! Cannot save the transaction, the Total Amount is greater than the payable amount.";
                        string stScript = "<Script>";
                        stScript += "window.alert('Warning!!! Cannot save the transaction, the Total Amount is greater than the payable amount.\n Check more Purchase Order(s) to be paid or decrease the Total debit/credit Amount.')";
                        stScript += "</Script>";
                        Response.Write(stScript);
                    }
                    else
                    {
                        decTotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text);
                        DateTime PostingDate = Convert.ToDateTime(txtPostingDate.Text + " " + DateTime.Now.ToString("HH:mm"));
                        long lPaymentID = Convert.ToInt64(lblPaymentID.Text);
                        Payments clsPayments = new Payments();
                        clsPayments.GetConnection();

                        PaymentPODetailDetails clsPaymentPODetailDetails;

                        PaymentPODetails clsPaymentPODetails = new PaymentPODetails(clsPayments.Connection, clsPayments.Transaction);
                        PO clsPO = new PO(clsPayments.Connection, clsPayments.Transaction);

                        foreach (DataListItem item in lstPO.Items)
                        {
                            HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                            if (chkList != null)
                            {
                                 if (chkList.Checked == true)
                                {
                                    long lPOID = Convert.ToInt64(chkList.Value);
                                    clsPaymentPODetailDetails = new PaymentPODetailDetails();
                                    clsPaymentPODetailDetails.PaymentID = lPaymentID;
                                    clsPaymentPODetailDetails.POID = lPOID;

                                    Label lblUnpaidAmount = (Label)item.FindControl("lblUnpaidAmount");
                                    decimal decUnpaidAmount = Convert.ToDecimal(lblUnpaidAmount.Text);

                                    if (decTotalDebitAmount == 0)
                                    { break; }
                                    else if (decTotalDebitAmount >= decUnpaidAmount)
                                    {
                                        clsPO.UpdatePayment(lPOID, decUnpaidAmount, POPaymentStatus.FullyPaid);

                                        clsPaymentPODetailDetails.Amount = decUnpaidAmount;
                                        clsPaymentPODetailDetails.PaymentStatus = POPaymentStatus.FullyPaid;
                                        clsPaymentPODetails.Insert(clsPaymentPODetailDetails);

                                        decTotalDebitAmount -= decUnpaidAmount;
                                    }
                                    else if (decTotalDebitAmount != 0)
                                    {
                                        clsPO.UpdatePayment(lPOID, decTotalDebitAmount, POPaymentStatus.Partially);

                                        clsPaymentPODetailDetails.Amount = decTotalDebitAmount;
                                        clsPaymentPODetailDetails.PaymentStatus = POPaymentStatus.Partially;
                                        clsPaymentPODetails.Insert(clsPaymentPODetailDetails);

                                        decTotalDebitAmount = 0;
                                    }

                                }
                            }
                        }

                        clsPayments.Post(lPaymentID, PostingDate);
                        clsPayments.CommitAndDispose();

                        Response.Redirect("Default.aspx?task=" + Common.Encrypt("list", Session.SessionID));
                    }
                }
                else
                {
                    //lblReferrer.Text = "Cannot post invoice, the debit/credit amount should be equal. Please check the posted accounts.";
                    string stScript = "<Script>";
                    stScript += "window.alert('Cannot post invoice, the debit/credit amount should be equal. Please check the posted accounts.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                }
            }
            catch (Exception ex) {
                lblReferrer.Text= "'Cannot post invoice. unexpected error occurred: " + ex.ToString();
                string stScript = "<Script>";
                stScript += "window.alert('Cannot post invoice. unexpected error occurred: " + ex.ToString() + "')" ;
                stScript += "</Script>";
                Response.Write(stScript);
            }
        }
Esempio n. 4
0
		private void SaveRecord(string Sender)
		{
			ComputePayment(Sender);

			PaymentsDetails clsDetails = new PaymentsDetails();

            clsDetails.PaymentID = Convert.ToInt64(lblPaymentID.Text);
            clsDetails.BankID = Convert.ToInt32(cboBank.SelectedItem.Value);
            clsDetails.BankCode = cboBank.SelectedItem.Text;
            clsDetails.ChequeDate = Convert.ToDateTime(txtChequeDate.Text);
            clsDetails.ChequeNo = txtChequeNo.Text;
            clsDetails.PayeeID = Convert.ToInt64(cboPayee.SelectedItem.Value);
            clsDetails.PayeeCode = cboPayee.SelectedItem.Text;
            clsDetails.PayeeName = txtPayeeName.Text;
            clsDetails.Particulars = txtRemarks.Text;
            clsDetails.TotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text);
            clsDetails.TotalCreditAmount = Convert.ToDecimal(lblTotalCreditAmount.Text);

			Payments clsPayments = new Payments();
            clsPayments.Update(clsDetails);

            Banks clsBank = new Banks(clsPayments.Connection, clsPayments.Transaction);
            clsBank.UpdateChequeCounter(clsDetails.BankID, clsDetails.ChequeNo);

			clsPayments.CommitAndDispose();
		}
Esempio n. 5
0
		private void LoadRecord()
		{
			Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["paymentid"],Session.SessionID));
			Payments clsPayments = new Payments();
			PaymentsDetails clsDetails = clsPayments.Details(iID);
			clsPayments.CommitAndDispose();

			lblPaymentID.Text = clsDetails.PaymentID.ToString();
            cboBank.SelectedIndex = cboBank.Items.IndexOf(cboBank.Items.FindByValue(clsDetails.BankID.ToString()));
			txtChequeNo.Text = clsDetails.ChequeNo;
			txtChequeDate.Text = clsDetails.ChequeDate.ToString("yyyy-MM-dd");
			cboPayee.SelectedIndex = cboPayee.Items.IndexOf(cboPayee.Items.FindByValue(clsDetails.PayeeID.ToString()));
            cboPayee_SelectedIndexChanged(null, null);
			txtPayeeName.Text = clsDetails.PayeeName;
			txtRemarks.Text = clsDetails.Particulars;
			lblTotalDebitAmount.Text = clsDetails.TotalDebitAmount.ToString("#,##0.#0");
			lblTotalCreditAmount.Text = clsDetails.TotalCreditAmount.ToString("#,##0.#0");
			lblTotalAmount.Text = Convert.ToDecimal(clsDetails.TotalDebitAmount - clsDetails.TotalCreditAmount).ToString("#,##0.#0");

			LoadItems();
		}
Esempio n. 6
0
		private void LoadRecord()
		{
			Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["paymentid"],Session.SessionID));
			Payments clsPayments = new Payments();
			PaymentsDetails clsDetails = clsPayments.Details(iID);
			clsPayments.CommitAndDispose();

			lblPaymentID.Text = clsDetails.PaymentID.ToString();
            lblBank.Text = clsDetails.BankCode;
            lblBank.NavigateUrl = Constants.ROOT_DIRECTORY + "/GeneralLedger/_Bank/Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(clsDetails.BankID.ToString(), Session.SessionID);

			lblChequeNo.Text = clsDetails.ChequeNo;
			lblChequeDate.Text = clsDetails.ChequeDate.ToString("yyyy-MM-dd");
            lblPayeeCode.Text = clsDetails.PayeeCode;

            string stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(clsDetails.PayeeID.ToString(), Session.SessionID);
            lblPayeeCode.NavigateUrl = Constants.ROOT_DIRECTORY + "/PurchasesAndPayables/_Vendor/Default.aspx" + stParam;
            lblPayeeName.Text = clsDetails.PayeeName;
			
			lblRemarks.Text = clsDetails.Particulars;
			lblTotalDebitAmount.Text = clsDetails.TotalDebitAmount.ToString("#,##0.#0");
			lblTotalCreditAmount.Text = clsDetails.TotalCreditAmount.ToString("#,##0.#0");
			lblTotalAmount.Text = Convert.ToDecimal(clsDetails.TotalDebitAmount - clsDetails.TotalCreditAmount).ToString("#,##0.#0");

            LoadPO();
			LoadItems();
		}