Int64 ICMProjectMilestoneDataAccess.Add(CMProjectMilestoneEntity cMProjectMilestoneEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void SaveCMProjectMilestoneEntity()
        {
            if (IsValid)
            {
                try
                {
                    CMProjectMilestoneEntity cMProjectMilestoneEntity = BuildCMProjectMilestoneEntity();

                    Int64 result = -1;

                    if (cMProjectMilestoneEntity.IsNew)
                    {
                        result = FCCCMProjectMilestone.GetFacadeCreate().Add(cMProjectMilestoneEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMProjectMilestoneEntity.FLD_NAME_ProjectMilestoneID, cMProjectMilestoneEntity.ProjectMilestoneID.ToString(), SQLMatchType.Equal);
                        result = FCCCMProjectMilestone.GetFacadeCreate().Update(cMProjectMilestoneEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ProjectMilestoneID       = 0;
                        _CMProjectMilestoneEntity = new CMProjectMilestoneEntity();
                        PrepareInitialView();
                        BindCMProjectMilestoneList();

                        if (cMProjectMilestoneEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Milestone Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Project Milestone Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cMProjectMilestoneEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Project Milestone Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Project Milestone Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 UpdateTran(CMProjectMilestoneEntity cMProjectMilestoneEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMProjectMilestone_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, "@ProjectMilestoneID", DbType.Int64, cMProjectMilestoneEntity.ProjectMilestoneID);
                db.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMProjectMilestoneEntity.ProjectID);
                db.AddInParameter(cmd, "@IssueID", DbType.Int64, cMProjectMilestoneEntity.IssueID);

                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 lvCMProjectMilestone_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ProjectMilestoneID;

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

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

                    PrepareEditView();

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMProjectMilestoneEntity.FLD_NAME_ProjectMilestoneID, ProjectMilestoneID.ToString(), SQLMatchType.Equal);

                        CMProjectMilestoneEntity cMProjectMilestoneEntity = new CMProjectMilestoneEntity();


                        result = FCCCMProjectMilestone.GetFacadeCreate().Delete(cMProjectMilestoneEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ProjectMilestoneID       = 0;
                            _CMProjectMilestoneEntity = new CMProjectMilestoneEntity();
                            PrepareInitialView();
                            BindCMProjectMilestoneList();

                            MiscUtil.ShowMessage(lblMessage, "Project Milestone has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Project Milestone.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private void PrepareEditView()
        {
            CMProjectMilestoneEntity cMProjectMilestoneEntity = CurrentCMProjectMilestoneEntity;


            if (!cMProjectMilestoneEntity.IsNew)
            {
                if (ddlIssueID.Items.Count > 0 && cMProjectMilestoneEntity.IssueID != null)
                {
                    ddlIssueID.SelectedValue = cMProjectMilestoneEntity.IssueID.ToString();
                }


                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
        private CMProjectMilestoneEntity BuildCMProjectMilestoneEntity()
        {
            CMProjectMilestoneEntity cMProjectMilestoneEntity = CurrentCMProjectMilestoneEntity;

            cMProjectMilestoneEntity.ProjectID = this.OverviewProjectID;

            if (ddlIssueID.Items.Count > 0)
            {
                if (ddlIssueID.SelectedValue == "0")
                {
                }
                else
                {
                    cMProjectMilestoneEntity.IssueID = Int64.Parse(ddlIssueID.SelectedValue);
                }
            }


            return(cMProjectMilestoneEntity);
        }
        private Int64 Update(CMProjectMilestoneEntity cMProjectMilestoneEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.CMProjectMilestone_SET";

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

                Database.AddInParameter(cmd, "@ProjectMilestoneID", DbType.Int64, cMProjectMilestoneEntity.ProjectMilestoneID);
                Database.AddInParameter(cmd, "@ProjectID", DbType.Int64, cMProjectMilestoneEntity.ProjectID);
                Database.AddInParameter(cmd, "@IssueID", DbType.Int64, cMProjectMilestoneEntity.IssueID);

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

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

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

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

            return(returnCode);
        }
Ejemplo n.º 8
0
        private void SaveNodesToDB()
        {
            foreach (TreeNode tn in treeProjectSchedule.CheckedNodes)
            {
                Int64 issueID = Int64.Parse(tn.Value.ToString());
                if (issueID > 0)
                {
                    CMProjectMilestoneEntity projectMilestone = new CMProjectMilestoneEntity();

                    projectMilestone.ProjectID = this.OverviewProjectID;
                    projectMilestone.IssueID   = Int64.Parse(tn.Value.ToString());
                    newMappedMilestones.Add(projectMilestone);
                }
            }

            IList <CMProjectMilestoneEntity> deleteList = currentMappedMilestone.Except(newMappedMilestones, new CustomerComparer()).ToList();
            IList <CMProjectMilestoneEntity> addNewList = newMappedMilestones.Except(currentMappedMilestone, new CustomerComparer()).ToList();

            if (deleteList != null && deleteList.Count > 0)
            {
                foreach (CMProjectMilestoneEntity ent in deleteList)
                {
                    String fe1 = SqlExpressionBuilder.PrepareFilterExpression(CMProjectMilestoneEntity.FLD_NAME_ProjectID, ent.ProjectID.ToString(), SQLMatchType.Equal);
                    String fe2 = SqlExpressionBuilder.PrepareFilterExpression(CMProjectMilestoneEntity.FLD_NAME_IssueID, ent.IssueID.ToString(), SQLMatchType.Equal);
                    String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                    FCCCMProjectMilestone.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                }
            }

            if (addNewList != null && addNewList.Count > 0)
            {
                foreach (CMProjectMilestoneEntity ent in addNewList)
                {
                    FCCCMProjectMilestone.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
                }
            }
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ProjectMilestoneID       = 0;
     _CMProjectMilestoneEntity = new CMProjectMilestoneEntity();
     PrepareInitialView();
 }
Ejemplo n.º 10
0
 private void PrepareEditView()
 {
     CMProjectMilestoneEntity cMProjectMilestoneEntity = CurrentCMProjectMilestoneEntity;
 }
Ejemplo n.º 11
0
 Int64 ICMProjectMilestoneFacade.Delete(CMProjectMilestoneEntity cMProjectMilestoneEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMProjectMilestoneDataAccess().Delete(cMProjectMilestoneEntity, filterExpression, option, reqTran));
 }
Ejemplo n.º 12
0
 Int64 ICMProjectMilestoneFacade.Add(CMProjectMilestoneEntity cMProjectMilestoneEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateCMProjectMilestoneDataAccess().Add(cMProjectMilestoneEntity, option, reqTran));
 }