Beispiel #1
0
        public static string SaveOrganization(string org_id, string user_id, string org_name, string org_code, string orgType,
                                              string joint_date, string expiry_date, string InvoiceAccountName, string InvoiceAccountNo, string user_count, string orgplan,
                                              string Website, string Facebook, string Email, string PhoneNo, string Address, string InvoiceType,
                                              string remark, string remark1, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc = new LINQ_SystemDataContext();

                DateTime Joint_Date = DateTime.Today;
                DateTime.TryParseExact(joint_date, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out Joint_Date);

                DateTime Expiry_Date = DateTime.Today;
                DateTime.TryParseExact(expiry_date, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out Expiry_Date);


                SYS_Organization the_record = new SYS_Organization();
                if (org_id == "" || org_id == null)
                {
                    the_record = (from c in dc.SYS_Organizations where c.OrgID == org_id && c.Active == true select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new SYS_Organization()
                        {
                            CreatedBy  = user_id,
                            CreatedOn  = DateTime.Now,
                            Active     = true,
                            OrgID      = Guid.NewGuid().ToString(),
                            LastAction = Guid.NewGuid().ToString()
                        };
                        dc.SYS_Organizations.InsertOnSubmit(the_record);
                    }
                    else
                    {
                        return("Error~Duplicate Organization Name");
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from c in dc.SYS_Organizations where c.OrgID == org_id select c).FirstOrDefault();
                    if (the_record == null)
                    {
                        throw new Exception("System cannot find the record");
                    }
                }
                the_record.ModifiedBy = user_id;
                the_record.ModifiedOn = DateTime.Now;
                the_record.LastAction = Guid.NewGuid().ToString();
                the_record.OrgType    = orgType;

                the_record.OrgName = org_name;
                the_record.OrgCode = org_code;

                the_record.JointDate  = Joint_Date;
                the_record.ExpiryDate = Expiry_Date;
                the_record.UserCount  = user_count;
                the_record.OrgPlan    = org_code;

                the_record.Website     = Website;
                the_record.Facebook    = Facebook;
                the_record.Email       = Email;
                the_record.PhoneNo     = PhoneNo;
                the_record.Address     = Address;
                the_record.InvoiceType = InvoiceType;

                the_record.Remark             = remark;
                the_record.Remark1            = remark1;
                the_record.InvoiceAccountName = InvoiceAccountName;
                the_record.InvoiceAccountNo   = InvoiceAccountNo;

                #region update the log

                SYS_Organization log_obj = dc.GetChangeSet().Updates.OfType <SYS_Organization>().FirstOrDefault();
                if (log_obj != null)
                {
                    if (Controller_SystemLog.WirteUpdateLog(dc.SYS_Organizations.GetModifiedMembers(log_obj).ToList(), org_id, RequestID) == false)
                    {
                        //Error fail to log.
                    }
                }
                #endregion


                dc.SubmitChanges();
                return("Success~" + the_record.OrgID);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
Beispiel #2
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);
            }
        }