Пример #1
0
        public int SaveRecord(SETUP_Calendar lrow_Calendar)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Calendar lRow_ExistingData = dbSCMS.SETUP_Calendars.Where(b => b.Cldr_Id.Equals(lrow_Calendar.Cldr_Id)).SingleOrDefault();

                if (lRow_ExistingData != null)
                {
                    lRow_ExistingData.Loc_Id = lrow_Calendar.Loc_Id;
                    lRow_ExistingData.Cmp_Id = lrow_Calendar.Cmp_Id;
                    lRow_ExistingData.Cldr_Title = lrow_Calendar.Cldr_Title;
                    lRow_ExistingData.Cldr_Prefix = lrow_Calendar.Cldr_Prefix;
                    lRow_ExistingData.Cldr_DateStart = lrow_Calendar.Cldr_DateStart;
                    lRow_ExistingData.Cldr_DateEnd = lrow_Calendar.Cldr_DateEnd;
                    lRow_ExistingData.CldrType_Id = lrow_Calendar.CldrType_Id;
                }
                else
                {
                    dbSCMS.SETUP_Calendars.InsertOnSubmit(lrow_Calendar);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(lrow_Calendar.Cldr_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
Пример #2
0
        // Insertion
        public ActionResult SaveRecord(String ps_Code, String CalenderType, String Prefix, String Title, DateTime SratrtDate, DateTime EndDate)
        {
            SETUP_Calendar lrow_Calendar = new SETUP_Calendar();
            String ls_Action = "Delete", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[6], ls_Data = new String[6];
            Int32 li_ReturnValue = 0;

            // Get Company name show in list
            List<SCMSDataLayer.DB.SETUP_CalendarType> ListCalendarType = new List<SCMSDataLayer.DB.SETUP_CalendarType>();
            ListCalendarType = new SCMSDataLayer.DALCalendarType().GetAllRecords().ToList();
            SCMSDataLayer.DB.SETUP_CalendarType CalendarTypeRow = ListCalendarType.Where(c => c.CldrType_Id.Equals(CalenderType)).SingleOrDefault();

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Calendar") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_Calendar");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_Calendar.Cldr_Id = ps_Code;
                    lrow_Calendar.Cldr_Code = ps_Code;
                    lrow_Calendar.CldrType_Id = CalenderType;
                    lrow_Calendar.Cldr_Prefix = Prefix;
                    lrow_Calendar.Cldr_Title = Title;
                    lrow_Calendar.Cldr_DateStart = SratrtDate;
                    lrow_Calendar.Cldr_DateEnd = EndDate;
                    lrow_Calendar.CldrType_Level = CalendarTypeRow.CldrType_Level;
                    lrow_Calendar.Cldr_Active = 1;

                    li_ReturnValue = objDalCalendar.SaveRecord(lrow_Calendar);
                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                    // Audit Trail Entry Section
                    if (li_ReturnValue > 0 && IsAuditTrail == "1")
                    {
                        DALAuditLog objAuditLog = new DALAuditLog();

                        ls_UserId = ((SECURITY_User)Session["user"]).User_Id;
                        ls_Lable[0] = "Code";
                        ls_Lable[1] = "Title";
                        ls_Lable[2] = "Prefix";
                        ls_Lable[3] = "Calendar Type";
                        ls_Lable[4] = "Start Date";
                        ls_Lable[5] = "End Date";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = Title;
                        ls_Data[2] = Prefix;
                        ls_Data[3] = CalenderType;
                        ls_Data[4] = SratrtDate.ToString("dd/MM/yyyy");
                        ls_Data[5] = EndDate.ToString("dd/MM/yyyy");

                        objAuditLog.SaveRecord(14, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                    // Audit Trail Section End
                }
                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }