Int64 IPRMWorkOrderPaymentTermDataAccess.Add(PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private PRMWorkOrderPaymentTermEntity BuildPRMWorkOrderPaymentTermEntity()
        {
            PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity = CurrentPRMWorkOrderPaymentTermEntity;


            pRMWorkOrderPaymentTermEntity.WorkOrderID = PRMWorkOrderID;

            if (!txtPaymentPercentage.Text.Trim().IsNullOrEmpty())
            {
                pRMWorkOrderPaymentTermEntity.PaymentPercentage = Decimal.Parse(txtPaymentPercentage.Text.Trim());
            }

            if (!txtCompletionPercentage.Text.Trim().IsNullOrEmpty())
            {
                pRMWorkOrderPaymentTermEntity.CompletionPercentage = Decimal.Parse(txtCompletionPercentage.Text.Trim());
            }

            pRMWorkOrderPaymentTermEntity.CompletionNote = txtCompletionNote.Text.Trim();
            if (txtPaymentDate.Text.Trim().IsNotNullOrEmpty())
            {
                pRMWorkOrderPaymentTermEntity.PaymentDate = MiscUtil.ParseToDateTime(txtPaymentDate.Text);
            }
            else
            {
                pRMWorkOrderPaymentTermEntity.PaymentDate = null;
            }


            return(pRMWorkOrderPaymentTermEntity);
        }
        private Int64 UpdateTran(PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderPaymentTerm_SET";

            Database db = DatabaseFactory.CreateDatabase();

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

                db.AddInParameter(cmd, "@WorkOrderPaymentTermID", DbType.Int64, pRMWorkOrderPaymentTermEntity.WorkOrderPaymentTermID);
                db.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, pRMWorkOrderPaymentTermEntity.WorkOrderID);
                db.AddInParameter(cmd, "@PaymentPercentage", DbType.Decimal, pRMWorkOrderPaymentTermEntity.PaymentPercentage);
                db.AddInParameter(cmd, "@CompletionPercentage", DbType.Decimal, pRMWorkOrderPaymentTermEntity.CompletionPercentage);
                db.AddInParameter(cmd, "@CompletionNote", DbType.String, pRMWorkOrderPaymentTermEntity.CompletionNote);
                db.AddInParameter(cmd, "@PaymentDate", DbType.DateTime, pRMWorkOrderPaymentTermEntity.PaymentDate);

                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);
        }
        private void SavePRMWorkOrderPaymentTermEntity()
        {
            if (IsValid)
            {
                try
                {
                    PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity = BuildPRMWorkOrderPaymentTermEntity();

                    Int64 result = -1;

                    if (pRMWorkOrderPaymentTermEntity.IsNew)
                    {
                        result = FCCPRMWorkOrderPaymentTerm.GetFacadeCreate().Add(pRMWorkOrderPaymentTermEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(PRMWorkOrderPaymentTermEntity.FLD_NAME_WorkOrderPaymentTermID, pRMWorkOrderPaymentTermEntity.WorkOrderPaymentTermID.ToString(), SQLMatchType.Equal);
                        result = FCCPRMWorkOrderPaymentTerm.GetFacadeCreate().Update(pRMWorkOrderPaymentTermEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _WorkOrderPaymentTermID        = 0;
                        _PRMWorkOrderPaymentTermEntity = new PRMWorkOrderPaymentTermEntity();
                        PrepareInitialView();
                        BindPRMWorkOrderPaymentTermList();

                        if (pRMWorkOrderPaymentTermEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Work Order Payment Term Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Work Order Payment Term Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (pRMWorkOrderPaymentTermEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Work Order Payment Term Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Work Order Payment Term Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        protected void lvPRMWorkOrderPaymentTerm_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 WorkOrderPaymentTermID;

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

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

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(PRMWorkOrderPaymentTermEntity.FLD_NAME_WorkOrderPaymentTermID, WorkOrderPaymentTermID.ToString(), SQLMatchType.Equal);

                        PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity = new PRMWorkOrderPaymentTermEntity();


                        result = FCCPRMWorkOrderPaymentTerm.GetFacadeCreate().Delete(pRMWorkOrderPaymentTermEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _WorkOrderPaymentTermID        = 0;
                            _PRMWorkOrderPaymentTermEntity = new PRMWorkOrderPaymentTermEntity();
                            PrepareInitialView();
                            BindPRMWorkOrderPaymentTermList();

                            MiscUtil.ShowMessage(lblMessage, "Work Order Payment Term has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Work Order Payment Term.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private void PrepareEditView()
        {
            PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity = CurrentPRMWorkOrderPaymentTermEntity;


            if (!pRMWorkOrderPaymentTermEntity.IsNew)
            {
                lblWorkOrderNo.Text = PRMWorkOrderNo.ToString();

                txtPaymentPercentage.Text    = pRMWorkOrderPaymentTermEntity.PaymentPercentage.ToString();
                txtCompletionPercentage.Text = pRMWorkOrderPaymentTermEntity.CompletionPercentage.ToString();
                txtCompletionNote.Text       = pRMWorkOrderPaymentTermEntity.CompletionNote.ToString();
                txtPaymentDate.Text          = pRMWorkOrderPaymentTermEntity.PaymentDate.ToStringDefault();

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
        private Int64 Update(PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderPaymentTerm_SET";

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

                Database.AddInParameter(cmd, "@WorkOrderPaymentTermID", DbType.Int64, pRMWorkOrderPaymentTermEntity.WorkOrderPaymentTermID);
                Database.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, pRMWorkOrderPaymentTermEntity.WorkOrderID);
                Database.AddInParameter(cmd, "@PaymentPercentage", DbType.Decimal, pRMWorkOrderPaymentTermEntity.PaymentPercentage);
                Database.AddInParameter(cmd, "@CompletionPercentage", DbType.Decimal, pRMWorkOrderPaymentTermEntity.CompletionPercentage);
                Database.AddInParameter(cmd, "@CompletionNote", DbType.String, pRMWorkOrderPaymentTermEntity.CompletionNote);
                Database.AddInParameter(cmd, "@PaymentDate", DbType.DateTime, pRMWorkOrderPaymentTermEntity.PaymentDate);

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

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

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

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

            return(returnCode);
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _WorkOrderPaymentTermID        = 0;
     _PRMWorkOrderPaymentTermEntity = new PRMWorkOrderPaymentTermEntity();
     PrepareInitialView();
 }
Example #9
0
 Int64 IPRMWorkOrderPaymentTermFacade.Delete(PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMWorkOrderPaymentTermDataAccess().Delete(pRMWorkOrderPaymentTermEntity, filterExpression, option, reqTran));
 }
Example #10
0
 Int64 IPRMWorkOrderPaymentTermFacade.Add(PRMWorkOrderPaymentTermEntity pRMWorkOrderPaymentTermEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMWorkOrderPaymentTermDataAccess().Add(pRMWorkOrderPaymentTermEntity, option, reqTran));
 }