Example #1
0
        Int64 IACBankAccountPaymentItemDataAccess.Add(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(aCBankAccountPaymentItemEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(aCBankAccountPaymentItemEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void btnAddItem_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                ACBankAccountPaymentItemEntity acBankAccountPaymentItemEntity = new ACBankAccountPaymentItemEntity();

                if (hdEmpID.Value != "0")
                {
                    acBankAccountPaymentItemEntity.AccountID = Int64.Parse(hdEmpID.Value);
                }

                if (!txtAmount.Text.Trim().IsNullOrEmpty())
                {
                    acBankAccountPaymentItemEntity.Amount = Decimal.Parse(txtAmount.Text.Trim());
                }

                acBankAccountPaymentItemEntity.Memo = txtMemoDetail.Text.Trim();
                acBankAccountPaymentItemEntity.BankAccountPaymentID = OverviewBankAccountPaymentID;

                FCCACBankAccountPaymentItem.GetFacadeCreate().Add(acBankAccountPaymentItemEntity, DatabaseOperationType.Add, TransactionRequired.No);

                BindACBankAccountPaymentItemList();

                ClearAll();

                BuildTotalValueLabel();
            }
        }
Example #3
0
        private Int64 AddTran(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPaymentItem_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddNullPrimaryKeyParameter(cmd, "BankAccountPaymentItemID", db);

                db.AddInParameter(cmd, "@BankAccountPaymentID", DbType.Int64, aCBankAccountPaymentItemEntity.BankAccountPaymentID);
                db.AddInParameter(cmd, "@AccountID", DbType.Int64, aCBankAccountPaymentItemEntity.AccountID);
                db.AddInParameter(cmd, "@DimensionID", DbType.Int64, aCBankAccountPaymentItemEntity.DimensionID);
                db.AddInParameter(cmd, "@ItemID", DbType.Int64, aCBankAccountPaymentItemEntity.ItemID);
                db.AddInParameter(cmd, "@Amount", DbType.Decimal, aCBankAccountPaymentItemEntity.Amount);
                db.AddInParameter(cmd, "@Memo", DbType.String, aCBankAccountPaymentItemEntity.Memo);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectID);
                db.AddInParameter(cmd, "@RequisitionID", DbType.Int64, aCBankAccountPaymentItemEntity.RequisitionID);
                db.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, aCBankAccountPaymentItemEntity.WorkOrderID);
                db.AddInParameter(cmd, "@BillID", DbType.Int64, aCBankAccountPaymentItemEntity.BillID);
                db.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectFloorID);
                db.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectFloorUnitID);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    returnCode = db.ExecuteNonQuery(cmd, transaction);

                    returnCode = GetReturnCodeFromParameter(cmd, db);

                    if (returnCode > 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
Example #4
0
        private Int64 Update(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPaymentItem_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@BankAccountPaymentItemID", DbType.Int64, aCBankAccountPaymentItemEntity.BankAccountPaymentItemID);
                Database.AddInParameter(cmd, "@BankAccountPaymentID", DbType.Int64, aCBankAccountPaymentItemEntity.BankAccountPaymentID);
                Database.AddInParameter(cmd, "@AccountID", DbType.Int64, aCBankAccountPaymentItemEntity.AccountID);
                Database.AddInParameter(cmd, "@DimensionID", DbType.Int64, aCBankAccountPaymentItemEntity.DimensionID);
                Database.AddInParameter(cmd, "@ItemID", DbType.Int64, aCBankAccountPaymentItemEntity.ItemID);
                Database.AddInParameter(cmd, "@Amount", DbType.Decimal, aCBankAccountPaymentItemEntity.Amount);
                Database.AddInParameter(cmd, "@Memo", DbType.String, aCBankAccountPaymentItemEntity.Memo);
                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectID);
                Database.AddInParameter(cmd, "@RequisitionID", DbType.Int64, aCBankAccountPaymentItemEntity.RequisitionID);
                Database.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, aCBankAccountPaymentItemEntity.WorkOrderID);
                Database.AddInParameter(cmd, "@BillID", DbType.Int64, aCBankAccountPaymentItemEntity.BillID);
                Database.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectFloorID);
                Database.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, aCBankAccountPaymentItemEntity.ProjectFloorUnitID);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity already exists. Please specify another ACBankAccountPaymentItemEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity already exists. Please specify another ACBankAccountPaymentItemEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
Example #5
0
        private Int64 DeleteTran(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPaymentItem_SET";

            Database db = DatabaseFactory.CreateDatabase();


            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);


                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode >= 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
        protected void lvACBankAccountPaymentItem_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 BankAccountPaymentitemID;

            Int64.TryParse(e.CommandArgument.ToString(), out BankAccountPaymentitemID);

            if (BankAccountPaymentitemID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _BankAccountPaymentItemID = BankAccountPaymentitemID;

                    PrepareEditViewPaymentItem();

                    pnlAdd.Visible    = false;
                    pnlUpdate.Visible = true;
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity = new ACBankAccountPaymentItemEntity();
                        String fe = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountPaymentItemEntity.FLD_NAME_BankAccountPaymentItemID, BankAccountPaymentitemID.ToString(), SQLMatchType.Equal);
                        result = FCCACBankAccountPaymentItem.GetFacadeCreate().Delete(aCBankAccountPaymentItemEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            BindACBankAccountPaymentItemList();
                        }

                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
Example #7
0
        private Int64 Delete(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPaymentItem_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);


                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity already exists. Please specify another ACBankAccountPaymentItemEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentItemEntity already exists. Please specify another ACBankAccountPaymentItemEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
Example #8
0
 Int64 IACBankAccountPaymentItemFacade.Delete(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACBankAccountPaymentItemDataAccess().Delete(aCBankAccountPaymentItemEntity, filterExpression, option, reqTran));
 }
Example #9
0
 Int64 IACBankAccountPaymentItemFacade.Add(ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACBankAccountPaymentItemDataAccess().Add(aCBankAccountPaymentItemEntity, option, reqTran));
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                // Implement Update Code Here.
                ACBankAccountPaymentItemEntity aCBankAccountPaymentItemEntity = FCCACBankAccountPaymentItem.GetFacadeCreate().GetByID(_BankAccountPaymentItemID);

                if (hdEmpID.Value != "0")
                {
                    aCBankAccountPaymentItemEntity.AccountID = Int64.Parse(hdEmpID.Value);
                }

                if (ddlItemID.Items.Count > 0)
                {
                    if (ddlItemID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.ItemID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.ItemID = Int64.Parse(ddlItemID.SelectedValue);
                    }
                }

                if (ddlRequisitionID.Items.Count > 0)
                {
                    if (ddlRequisitionID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.RequisitionID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.RequisitionID = Int64.Parse(ddlRequisitionID.SelectedValue);
                    }
                }

                if (ddlWorkOrderID.Items.Count > 0)
                {
                    if (ddlWorkOrderID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.WorkOrderID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.WorkOrderID = Int64.Parse(ddlWorkOrderID.SelectedValue);
                    }
                }

                if (ddlBillID.Items.Count > 0)
                {
                    if (ddlBillID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.BillID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.BillID = Int64.Parse(ddlBillID.SelectedValue);
                    }
                }

                if (ddlProjectID.Items.Count > 0)
                {
                    if (ddlProjectID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.ProjectID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.ProjectID = Int64.Parse(ddlProjectID.SelectedValue);
                    }
                }

                if (ddlProjectFloorID.Items.Count > 0)
                {
                    if (ddlProjectFloorID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.ProjectFloorID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.ProjectFloorID = Int64.Parse(ddlProjectFloorID.SelectedValue);
                    }
                }

                if (ddlProjectFloorUnitID.Items.Count > 0)
                {
                    if (ddlProjectFloorUnitID.SelectedValue == "0")
                    {
                        aCBankAccountPaymentItemEntity.ProjectFloorUnitID = null;
                    }
                    else
                    {
                        aCBankAccountPaymentItemEntity.ProjectFloorUnitID = Int64.Parse(ddlProjectFloorUnitID.SelectedValue);
                    }
                }

                if (!txtAmount.Text.Trim().IsNullOrEmpty())
                {
                    aCBankAccountPaymentItemEntity.Amount = Decimal.Parse(txtAmount.Text.Trim());
                }

                aCBankAccountPaymentItemEntity.Memo = txtMemoDetail.Text.Trim();

                aCBankAccountPaymentItemEntity.BankAccountPaymentID = OverviewBankAccountPaymentID;

                #region Update Bank Account Payment Item

                String fe = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountPaymentItemEntity.FLD_NAME_BankAccountPaymentItemID, _BankAccountPaymentItemID.ToString(), SQLMatchType.Equal);
                FCCACBankAccountPaymentItem.GetFacadeCreate().Update(aCBankAccountPaymentItemEntity, fe, DatabaseOperationType.Update, TransactionRequired.No);

                #endregion

                BindACBankAccountPaymentItemList();

                ClearAll();

                pnlAdd.Visible    = true;
                pnlUpdate.Visible = false;
                BuildTotalValueLabel();
            }
        }