Beispiel #1
0
        public static bool AddMission(Mission mission)
        {
            bool returnValue = false;

            int missionID = getNextMissionID();

            List<IBaseQueryData> queryDatum = new List<IBaseQueryData>();

            IBaseQueryData queryData = new InsertQueryData();
            queryData.TableName = "PLN_Missions";
            queryData.Fields.Add(new FieldData { FieldName = "MissionID", FieldType = SqlDbType.Int, FieldValue= missionID.ToString() });
            queryData.Fields.Add(new FieldData { FieldName = "MissionTitle", FieldType = SqlDbType.NVarChar, FieldValue = mission.MissionTitle.Trim() });
            queryData.Fields.Add(new FieldData { FieldName = "MissionNotes", FieldType = SqlDbType.NVarChar, FieldValue = mission.MissionNotes.Trim() });
            queryData.Fields.Add(new FieldData { FieldName = "UserId", FieldType = SqlDbType.Int, FieldValue = mission.ForUser.UserID.ToString() });
            queryData.Fields.Add(new FieldData { FieldName = "Sequence", FieldType = SqlDbType.Int, FieldValue = getNextSequenceID(mission.ForUser.UserID).ToString() });
            queryDatum.Add(queryData);

            if (mission.Categories != null)
            {
                for (int i = 0; i <= mission.Categories.Count - 1; i++)
                {
                    queryData = new InsertQueryData();

                    queryData.TableName = "PLN_MissionCategories";
                    queryData.Fields.Add(new FieldData { FieldName = "MissionID", FieldType = SqlDbType.Int, FieldValue = missionID.ToString() });
                    queryData.Fields.Add(new FieldData { FieldName = "CategoryID", FieldType = SqlDbType.Int, FieldValue = mission.Categories[i].CategoryID.ToString() });
                    queryData.Fields.Add(new FieldData { FieldName = "Sequence", FieldType = SqlDbType.Int, FieldValue = (i + 1).ToString() });
                    queryDatum.Add(queryData);
                }
            }

            returnValue = SQLWrapper.ExecuteQuery(queryDatum);

            return returnValue;
        }
Beispiel #2
0
        private bool addupdateRow(DataGridViewCellEventArgs e)
        {
            bool returnValue = false;
            if (validateCurrentRowData(false))
            {
                int missionID = Convert.ToInt32(this.dgMission.CurrentRow.Cells[0].Value);
                Mission mission;
                if (missionID <= 0)
                {
                    mission = new Mission { MissionID = -1, ForUser = CurrentUser, MissionTitle = "", MissionNotes = "" };
                }
                else
                {
                    mission = BLLMission.GetMissionByID(missionID);
                }
                mission.ForUser = CurrentUser;
                mission.MissionNotes = this.dgMission.CurrentRow.Cells[2].EditedFormattedValue.ToString();
                mission.MissionTitle = this.dgMission.CurrentRow.Cells[1].EditedFormattedValue.ToString();
                if (missionID <= 0)
                {
                    BLLMission.AddMission(mission);
                }
                else
                {
                    BLLMission.UpdateMission(mission);
                }
                returnValue = true;
            }

            return returnValue;
        }
Beispiel #3
0
        public static bool DeleteMission(Mission mission)
        {
            bool returnValue = false;

            List<IBaseQueryData> queryDatum = new List<IBaseQueryData>();

            DeleteQueryData queryData = new DeleteQueryData();
            queryData.TableName = "PLN_MissionCategories";
            queryData.KeyFields.Add(new FieldData { FieldName = "MissionID", FieldType = SqlDbType.Int, FieldValue = mission.MissionID.ToString() });
            queryDatum.Add(queryData);

            queryData = new DeleteQueryData();
            queryData.TableName = "PLN_Missions";
            queryData.KeyFields.Add(new FieldData { FieldName = "MissionID", FieldType = SqlDbType.Int, FieldValue = mission.MissionID.ToString() });
            queryDatum.Add(queryData);

            returnValue = SQLWrapper.ExecuteQuery(queryDatum);

            return returnValue;
        }
Beispiel #4
0
 public static bool UpdateMission(Mission mission)
 {
     return DALMission.UpdateMission(mission);
 }
Beispiel #5
0
 public static bool AddMission(Mission mission)
 {
     return DALMission.AddMission(mission);
 }
Beispiel #6
0
 public static bool DeleteMission(int MissionID)
 {
     Mission mission = new Mission();
     mission.MissionID = MissionID;
     return DeleteMission(mission);
 }
Beispiel #7
0
 private static Mission loadMission(DataTable dtMissions, int RowNo)
 {
     Mission mission = new Mission();
     mission.MissionID = Convert.ToInt32(dtMissions.Rows[RowNo]["MissionID"]);
     mission.MissionTitle = dtMissions.Rows[RowNo]["MissionTitle"].ToString();
     mission.MissionNotes = dtMissions.Rows[RowNo]["MissionNotes"].ToString();
     mission.Sequence = Convert.ToInt32(dtMissions.Rows[RowNo]["Sequence"]);
     mission.Categories = loadMissionCategories(mission.MissionID);
     mission.ForUser = DALAppUser.GetUserByID(Convert.ToInt32(dtMissions.Rows[RowNo]["UserID"]));
     return mission;
 }