예제 #1
0
        public PaymentPODetailDetails Details(long PaymentDetailID)
        {
            try
            {
                string SQL = SQLSelect() + "WHERE PaymentDetailID = @PaymentDetailID;";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmPaymentDetailID = new MySqlParameter("@PaymentDetailID", MySqlDbType.Int64);
                prmPaymentDetailID.Value = PaymentDetailID;
                cmd.Parameters.Add(prmPaymentDetailID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                PaymentPODetailDetails Details = new PaymentPODetailDetails();

                while (myReader.Read())
                {
                    Details.PaymentDetailID = PaymentDetailID;
                    Details.PaymentID       = myReader.GetInt64("PaymentID");
                    Details.POID            = myReader.GetInt32("POID");
                    Details.Amount          = myReader.GetDecimal("Amount");
                    Details.PaymentStatus   = (POPaymentStatus)Enum.Parse(typeof(POPaymentStatus), myReader.GetString("PaymentStatus"));
                }

                myReader.Close();

                return(Details);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #2
0
        public long Insert(PaymentPODetailDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblPaymentPODetails (" +
                             "PaymentID, " +
                             "POID, " +
                             "Amount, " +
                             "PaymentStatus" +
                             ") VALUES (" +
                             "@PaymentID, " +
                             "@POID, " +
                             "@Amount, " +
                             "@PaymentStatus" +
                             ");";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID", MySqlDbType.Int64);
                prmPaymentID.Value = Details.PaymentID;
                cmd.Parameters.Add(prmPaymentID);

                MySqlParameter prmPOID = new MySqlParameter("@POID", MySqlDbType.Int64);
                prmPOID.Value = Details.POID;
                cmd.Parameters.Add(prmPOID);

                MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal);
                prmAmount.Value = Details.Amount;
                cmd.Parameters.Add(prmAmount);

                MySqlParameter prmPaymentStatus = new MySqlParameter("@PaymentStatus", MySqlDbType.Int16);
                prmPaymentStatus.Value = Details.PaymentStatus.ToString("d");
                cmd.Parameters.Add(prmPaymentStatus);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }

                return(iID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
예제 #3
0
        public PaymentPODetailDetails Details(long PaymentDetailID)
		{
			try
			{
				string SQL =	SQLSelect() + "WHERE PaymentDetailID = @PaymentDetailID;";
				  
                MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmPaymentDetailID = new MySqlParameter("@PaymentDetailID",MySqlDbType.Int64);			
				prmPaymentDetailID.Value = PaymentDetailID;
				cmd.Parameters.Add(prmPaymentDetailID);

				MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                PaymentPODetailDetails Details = new PaymentPODetailDetails();

				while (myReader.Read()) 
				{
					Details.PaymentDetailID = PaymentDetailID;
					Details.PaymentID = myReader.GetInt64("PaymentID");
					Details.POID = myReader.GetInt32("POID");
					Details.Amount = myReader.GetDecimal("Amount");
                    Details.PaymentStatus = (POPaymentStatus) Enum.Parse(typeof(POPaymentStatus), myReader.GetString("PaymentStatus"));
				}

				myReader.Close();

				return Details;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
예제 #4
0
        public long Insert(PaymentPODetailDetails Details)
		{
			try 
			{
				string SQL = "INSERT INTO tblPaymentPODetails (" +
								"PaymentID, " +
								"POID, " +
								"Amount, " +
                                "PaymentStatus" +
							") VALUES (" +
								"@PaymentID, " +
								"@POID, " +
								"@Amount, " +
                                "@PaymentStatus" +
							");";
				  
				
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID",MySqlDbType.Int64);			
				prmPaymentID.Value = Details.PaymentID;
				cmd.Parameters.Add(prmPaymentID);

				MySqlParameter prmPOID = new MySqlParameter("@POID",MySqlDbType.Int64);			
				prmPOID.Value = Details.POID;
				cmd.Parameters.Add(prmPOID);

				MySqlParameter prmAmount = new MySqlParameter("@Amount",MySqlDbType.Decimal);			
				prmAmount.Value = Details.Amount;
				cmd.Parameters.Add(prmAmount);

                MySqlParameter prmPaymentStatus = new MySqlParameter("@PaymentStatus",MySqlDbType.Int16);
                prmPaymentStatus.Value = Details.PaymentStatus.ToString("d");
                cmd.Parameters.Add(prmPaymentStatus);

				base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
예제 #5
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);
            }
        }