Exemplo n.º 1
0
        Int64 IMDProjectDocumentDataAccess.Add(MDProjectDocumentEntity mDProjectDocumentEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private MDProjectDocumentEntity BuildMDProjectDocumentEntity()
        {
            MDProjectDocumentEntity mDProjectDocumentEntity = CurrentMDProjectDocumentEntity;

            mDProjectDocumentEntity.Name = txtName.Text.Trim();
            if (!txtRequiredStandardTime.Text.Trim().IsNullOrEmpty())
            {
                mDProjectDocumentEntity.RequiredStandardTime = Int32.Parse(txtRequiredStandardTime.Text.Trim());
            }
            else
            {
                mDProjectDocumentEntity.RequiredStandardTime = null;
            }

            if (!txtReminderTime.Text.Trim().IsNullOrEmpty())
            {
                mDProjectDocumentEntity.ReminderTime = Int32.Parse(txtReminderTime.Text.Trim());
            }
            else
            {
                mDProjectDocumentEntity.ReminderTime = null;
            }

            mDProjectDocumentEntity.Remarks   = txtRemarks.Text.Trim();
            mDProjectDocumentEntity.IsRemoved = chkIsRemoved.Checked;


            return(mDProjectDocumentEntity);
        }
Exemplo n.º 3
0
        private Int64 UpdateTran(MDProjectDocumentEntity mDProjectDocumentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDProjectDocument_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, "@ProjectDocumentID", DbType.Int64, mDProjectDocumentEntity.ProjectDocumentID);
                db.AddInParameter(cmd, "@ProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentEntity.ProjectDocumentCategoryID);
                db.AddInParameter(cmd, "@Name", DbType.String, mDProjectDocumentEntity.Name);
                db.AddInParameter(cmd, "@RequiredStandardTime", DbType.Int32, mDProjectDocumentEntity.RequiredStandardTime);
                db.AddInParameter(cmd, "@ReminderTime", DbType.Int32, mDProjectDocumentEntity.ReminderTime);
                db.AddInParameter(cmd, "@Remarks", DbType.String, mDProjectDocumentEntity.Remarks);
                db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDProjectDocumentEntity.IsRemoved);

                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);
        }
Exemplo n.º 4
0
        private Int64 DeleteTran(MDProjectDocumentEntity mDProjectDocumentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDProjectDocument_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);
        }
        private void PrepareEditView()
        {
            MDProjectDocumentEntity mDProjectDocumentEntity = CurrentMDProjectDocumentEntity;


            if (!mDProjectDocumentEntity.IsNew)
            {
                txtName.Text = mDProjectDocumentEntity.Name.ToString();
                txtRequiredStandardTime.Text = mDProjectDocumentEntity.RequiredStandardTime.ToString();
                txtReminderTime.Text         = mDProjectDocumentEntity.ReminderTime.ToString();
                txtRemarks.Text      = mDProjectDocumentEntity.Remarks.ToString();
                chkIsRemoved.Checked = mDProjectDocumentEntity.IsRemoved;

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
Exemplo n.º 6
0
        private Int64 Update(MDProjectDocumentEntity mDProjectDocumentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDProjectDocument_SET";

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

                Database.AddInParameter(cmd, "@ProjectDocumentID", DbType.Int64, mDProjectDocumentEntity.ProjectDocumentID);
                Database.AddInParameter(cmd, "@ProjectDocumentCategoryID", DbType.Int64, mDProjectDocumentEntity.ProjectDocumentCategoryID);
                Database.AddInParameter(cmd, "@Name", DbType.String, mDProjectDocumentEntity.Name);
                Database.AddInParameter(cmd, "@RequiredStandardTime", DbType.Int32, mDProjectDocumentEntity.RequiredStandardTime);
                Database.AddInParameter(cmd, "@ReminderTime", DbType.Int32, mDProjectDocumentEntity.ReminderTime);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, mDProjectDocumentEntity.Remarks);
                Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, mDProjectDocumentEntity.IsRemoved);

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

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

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

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

            return(returnCode);
        }
        private void DeleteDocument()
        {
            Int64 ProjectDocumentID;

            Int64.TryParse(BayTreeNodeValue.GetValue(treeProjectDocument.SelectedValue), out ProjectDocumentID);

            if (ProjectDocumentID > 0)
            {
                try
                {
                    Int64 result = -1;

                    String fe = SqlExpressionBuilder.PrepareFilterExpression(MDProjectDocumentEntity.FLD_NAME_ProjectDocumentID, ProjectDocumentID.ToString(), SQLMatchType.Equal);

                    MDProjectDocumentEntity mDProjectDocumentEntity = new MDProjectDocumentEntity();


                    result = FCCMDProjectDocument.GetFacadeCreate().Delete(mDProjectDocumentEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                    if (result == 0)
                    {
                        _ProjectDocumentID       = 0;
                        _MDProjectDocumentEntity = new MDProjectDocumentEntity();

                        PrepareInitialView();

                        LoadTreeView();

                        MiscUtil.ShowMessage(lblMessage, "Project Document has been successfully deleted.", true);
                    }
                    else
                    {
                        MiscUtil.ShowMessage(lblMessage, "Failed to delete Project Document.", true);
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 8
0
        private Int64 Delete(MDProjectDocumentEntity mDProjectDocumentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.MDProjectDocument_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("MDProjectDocumentEntity already exists. Please specify another MDProjectDocumentEntity.");
                    }

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

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

            return(returnCode);
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ProjectDocumentID       = 0;
     _MDProjectDocumentEntity = new MDProjectDocumentEntity();
     PrepareInitialView();
 }
Exemplo n.º 10
0
        private void SaveMDProjectDocumentEntity()
        {
            if (IsValid)
            {
                try
                {
                    MDProjectDocumentEntity mDProjectDocumentEntity = BuildMDProjectDocumentEntity();

                    Int64 result = -1;

                    Boolean insertValidation = true;

                    if (mDProjectDocumentEntity.IsNew)
                    {
                        if (ValidateInput())
                        {
                            if (treeProjectDocument.SelectedNode != null)
                            {
                                mDProjectDocumentEntity.ProjectDocumentCategoryID = Int64.Parse(BayTreeNodeValue.GetValue(treeProjectDocument.SelectedValue));
                            }

                            result = FCCMDProjectDocument.GetFacadeCreate().Add(mDProjectDocumentEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                        else
                        {
                            insertValidation = false;
                        }
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(MDProjectDocumentEntity.FLD_NAME_ProjectDocumentID, mDProjectDocumentEntity.ProjectDocumentID.ToString(), SQLMatchType.Equal);
                        result = FCCMDProjectDocument.GetFacadeCreate().Update(mDProjectDocumentEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (insertValidation)
                    {
                        if (result > 0)
                        {
                            _ProjectDocumentID       = 0;
                            _MDProjectDocumentEntity = new MDProjectDocumentEntity();
                            PrepareInitialViewForm();

                            if (mDProjectDocumentEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Project Document Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Project Document Information has been updated successfully.", false);
                            }

                            LoadTreeView();
                        }
                        else
                        {
                            if (mDProjectDocumentEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Project Document Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Project Document Information.", false);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 11
0
 Int64 IMDProjectDocumentFacade.Delete(MDProjectDocumentEntity mDProjectDocumentEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDProjectDocumentDataAccess().Delete(mDProjectDocumentEntity, filterExpression, option, reqTran));
 }
Exemplo n.º 12
0
 Int64 IMDProjectDocumentFacade.Add(MDProjectDocumentEntity mDProjectDocumentEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateMDProjectDocumentDataAccess().Add(mDProjectDocumentEntity, option, reqTran));
 }