public static string SaveSysMenuGroup(string menugp_id, string user_id, string menu_gpcode, string menu_gpname, string menu_gpseq, string RequestID)
        {
            try
            {
                LINQ_SystemDataContext dc         = new LINQ_SystemDataContext();
                SYS_MenuGroup          the_record = new SYS_MenuGroup();
                if (menugp_id == "" || menugp_id == null)
                {
                    the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).FirstOrDefault();
                    if (the_record == null)
                    {
                        //Security Check
                        if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "create"))
                        {
                            throw new Exception("No Access.");
                        }

                        the_record = new SYS_MenuGroup()
                        {
                            CreatedBy   = user_id,
                            CreatedOn   = DateTime.Now,
                            Active      = true,
                            MenuGroupID = Guid.NewGuid().ToString(),
                            LastAction  = Guid.NewGuid().ToString()
                        };
                        dc.SYS_MenuGroups.InsertOnSubmit(the_record);
                    }
                }
                else
                {
                    //Security Check
                    if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, RequestID, "update"))
                    {
                        throw new Exception("No Access.");
                    }

                    the_record = (from sysmgp in dc.SYS_MenuGroups where sysmgp.MenuGroupID == menugp_id && sysmgp.Active == true select sysmgp).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.MenuGroupCode = menu_gpcode;
                the_record.MenuGroupName = menu_gpname;
                the_record.MenuGroupSeq  = Convert.ToInt32(menu_gpseq.ToString());

                #region update the log

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


                dc.SubmitChanges();
                return("Success~" + the_record.MenuGroupName);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#2
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);
            }
        }
示例#3
0
        public static string SaveRequest(
            string RequestID,
            string DepartmentID,
            string RequestType,
            string RequestNo,
            string RequestBy,
            string RequestTitle,
            string RequestStatus,
            string RequestOn,
            string MeetingID,
            string Remark,
            string ApprovedBy,
            string ApprovedOn,
            string ApprovedRemark,
            string Description,
            string UserID,
            string Requestitems,
            string RequestDecisions)
        {
            try
            {
                //Security Check
                if (!Controller_User_Access.CheckProgramAccess(AccessProgramCode, UserID, "read"))
                {
                    throw new Exception("No Access.");
                }

                LINQ_MeetingDataContext dc          = new LINQ_MeetingDataContext();
                MET_Request             the_request = new MET_Request();

                if (RequestID == "")
                {
                    the_request = new MET_Request()
                    {
                        Active    = true,
                        CreatedBy = UserID,
                        CreatedOn = DateTime.Now,
                        RequestID = Guid.NewGuid().ToString(),
                        RequestNo = Controller_RunningNo.GetNewRunningCode("Request", UserID),


                        ApprovedBy     = "",
                        ApprovedOn     = DateTime.Now,
                        ApprovedRemark = "",
                        ApprovalStatus = ""
                    };
                    RequestID = the_request.RequestID;
                    dc.MET_Requests.InsertOnSubmit(the_request);
                }
                else
                {
                    the_request = (from c in dc.MET_Requests where c.RequestID == RequestID select c).FirstOrDefault();
                    if (the_request == null)
                    {
                        throw new Exception("System cannot find the record.");
                    }
                }

                DateTime request_on = DateTime.Today;
                DateTime.TryParseExact(RequestOn, "yyyy/M/d", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out request_on);
                the_request.RequestType  = RequestType;
                the_request.RequestBy    = RequestBy;
                the_request.RequestTitle = RequestTitle;
                the_request.DepartmentID = DepartmentID;

                the_request.RequestStatus = RequestStatus;
                the_request.RequestOn     = request_on;
                the_request.AgendaID      = MeetingID;
                the_request.Remark        = Remark.Replace("%27", "");
                the_request.Description   = Description.Replace("%27", "");

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


                #region Clear previous items
                List <MET_RequestItem> req_old_items = (from c in dc.MET_RequestItems
                                                        where c.RequestID == the_request.RequestID &&
                                                        c.Active == true
                                                        select c).ToList();
                if (req_old_items != null)
                {
                    dc.MET_RequestItems.DeleteAllOnSubmit(req_old_items);
                }
                #endregion


                #region Request Items

                if (Requestitems != "")
                {
                    List <MET_RequestItem> request_items = new List <MET_RequestItem>();
                    List <string>          items         = Requestitems.Split('~').ToList();
                    foreach (string item in items)
                    {
                        if (item != "")
                        {
                            List <string> itemInfo = item.Split('^').ToList();

                            request_items.Add(new MET_RequestItem()
                            {
                                CreatedBy     = UserID,
                                CreatedOn     = DateTime.Now,
                                ModifiedBy    = UserID,
                                ModifiedOn    = DateTime.Now,
                                Active        = true,
                                LastAction    = Guid.NewGuid().ToString(),
                                RequestID     = the_request.RequestID,
                                RequestItemID = itemInfo[0],
                                RequestItem   = itemInfo[1],
                                Seq           = convertToDecimal(itemInfo[2]),
                            });
                        }
                    }
                    dc.MET_RequestItems.InsertAllOnSubmit(request_items);
                }

                #endregion

                #region Request Decision

                #region Clear previous items
                List <MET_RequestDecision> req_old_decisions = (from c in dc.MET_RequestDecisions
                                                                where c.RequestID == the_request.RequestID &&
                                                                c.Active == true
                                                                select c).ToList();
                if (req_old_decisions != null)
                {
                    dc.MET_RequestDecisions.DeleteAllOnSubmit(req_old_decisions);
                }
                #endregion
                if (RequestDecisions != "")
                {
                    List <MET_RequestDecision> request_decisions = new List <MET_RequestDecision>();
                    List <string> decisions         = RequestDecisions.Split('~').ToList();
                    string[]      combine_decisions = new string[decisions.Count];
                    int           count             = 0;
                    foreach (string decision in decisions)
                    {
                        if (decision != "")
                        {
                            List <string> decisionInfo = decision.Split('^').ToList();

                            request_decisions.Add(new MET_RequestDecision()
                            {
                                CreatedBy         = UserID,
                                CreatedOn         = DateTime.Now,
                                ModifiedBy        = UserID,
                                ModifiedOn        = DateTime.Now,
                                Active            = true,
                                LastAction        = Guid.NewGuid().ToString(),
                                RequestID         = the_request.RequestID,
                                RequestDecisionID = decisionInfo[0],
                                Description       = decisionInfo[1],
                                Seq = convertToDecimal(decisionInfo[2]),
                            });
                            combine_decisions[count] = decisionInfo[1];
                            count++;
                        }
                    }

                    dc.MET_RequestDecisions.InsertAllOnSubmit(request_decisions);
                    the_request.CombineDecision = string.Join(",", combine_decisions);
                }

                #endregion

                #region update the log for POS_SellVouncher

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

                do_populate_print_description(the_request.RequestID);

                //#region Conbine Decisions
                //the_request.CombineDecision = dc.MET_CombineDecisionsOfRequest(the_request.RequestID).ToString();
                //#endregion
                //dc.SubmitChanges();

                return("Success~" + the_request.RequestID + "~" + the_request.RequestNo);
            }
            catch (Exception ex)
            {
                return("Error~" + ex.Message);
            }
        }
示例#4
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);
            }
        }