示例#1
0
        public static string SaveAgenda(
            string AgendaID,
            string AgendaDate,
            string AgendaNo,
            string AgendaNoLabel,
            string AgendaStatus,
            string AgendaHistory,
            string AgendaRemark,
            string UserID)
        {
            try
            {
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, UserID, "read"))
                {
                    throw new Exception("No Access.");
                }

                LINQ_MeetingDataContext dc = new LINQ_MeetingDataContext();
                MET_Agenda the_agenda      = new MET_Agenda();

                if (AgendaID == "")
                {
                    the_agenda = new MET_Agenda()
                    {
                        Active    = true,
                        CreatedBy = UserID,
                        CreatedOn = DateTime.Now,
                        AgendaID  = Guid.NewGuid().ToString(),
                        AgendaNo  = Controller_RunningNo.GetNewRunningCode("Agenda", UserID),
                    };
                    AgendaID = the_agenda.AgendaID;
                    dc.MET_Agendas.InsertOnSubmit(the_agenda);
                }
                else
                {
                    the_agenda = (from c in dc.MET_Agendas where c.AgendaID == AgendaID select c).FirstOrDefault();
                    if (the_agenda == null)
                    {
                        throw new Exception("System cannot find the record.");
                    }
                }

                DateTime agenda_date = DateTime.Today;
                DateTime.TryParseExact(AgendaDate, "yyyy/M/d", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out agenda_date);
                the_agenda.AgendaStatus  = AgendaStatus;
                the_agenda.AgendaHistory = AgendaHistory;
                the_agenda.AgendaRemark  = AgendaRemark;
                the_agenda.AgendaDate    = agenda_date;
                the_agenda.AgendaNoLable = AgendaNoLabel;

                the_agenda.ModifiedBy = UserID;
                the_agenda.ModifiedOn = DateTime.Now;
                the_agenda.LastAction = Guid.NewGuid().ToString();


                #region update the log for Met_Agenda


                MET_Agenda log_obj = dc.GetChangeSet().Updates.OfType <MET_Agenda>().FirstOrDefault();
                if (log_obj != null)
                {
                    if (Controller_SystemLog.WirteUpdateLog(dc.MET_Agendas.GetModifiedMembers(log_obj).ToList(), AgendaID, UserID) == false)
                    {
                        //Error fail to log.
                    }
                }
                #endregion

                dc.SubmitChanges();


                return("Success~" + the_agenda.AgendaID + "~" + the_agenda.AgendaNo);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#2
0
        public static string AddRequestToAgenda(string agendaID, string user_id)
        {
            //Security Check
            if (!Controller_User_Access.CheckProgramAccess("MeetingRequest", user_id, "update"))
            {
                throw new Exception("No Access.");
            }
            SYS_UserView            current_user = Controller_User.GetUser(user_id, user_id);
            LINQ_MeetingDataContext dc           = new LINQ_MeetingDataContext();

            try
            {
                MET_Agenda agenda_record = new MET_Agenda();
                string     return_str    = "";
                agenda_record = (from c in dc.MET_Agendas where c.AgendaID == agendaID && c.Active == true select c).FirstOrDefault();
                if (agenda_record == null)
                {
                    return("Error~We can't find");
                }


                #region Request in agenda
                //Security Check For AllDepartment
                string departmentID = "";
                if (!Controller_User_Access.CheckProgramAccess("MeetingRequest", user_id, "allDepartment"))
                {
                    departmentID = current_user.DepartmentID;
                }

                List <MET_Request> req_list = new List <MET_Request>();
                req_list = (from c in dc.MET_Requests where c.ApprovalStatus == "Approved" &&
                            (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID)) &&
                            c.Active == true select c).ToList();

                if (req_list.Count > 0)
                {
                    foreach (MET_Request i in req_list)
                    {
                        i.AgendaID      = agenda_record.AgendaID;
                        i.RequestStatus = "Agenda";
                        i.ModifiedBy    = user_id;
                        i.ModifiedOn    = DateTime.Now;
                    }

                    dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                    #region get all request
                    List <MET_RequestView> reqs_list = (from c in dc.MET_RequestViews
                                                        where c.Active == true && c.AgendaID == agendaID &&
                                                        (departmentID == "" || (departmentID != "" && c.DepartmentID == departmentID))
                                                        orderby c.Protocol ascending
                                                        select c).ToList();

                    return_str = new JavaScriptSerializer().Serialize(reqs_list);
                    #endregion
                    return("Success~" + return_str);
                }
                else
                {
                    return("Error~" + "There is no approved requests!");
                }
                #endregion
            }
            catch (ChangeConflictException ex)
            {
                return("Success~");
            }
        }