public object SaveTemplateType(TemplateTypeParam TP)
        {
            try
            {
                string msg = "";
                if (TP.BtnStatus == "Save")
                {
                    var usercode = db.TblTemplateTypeMasters.Where(r => r.TemplateType == TP.TemplateType.ToUpper()).FirstOrDefault();
                    if (usercode != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Template Type Name is Already Exists!"
                        });
                    }
                    TblTemplateTypeMaster objTemplate = new TblTemplateTypeMaster();

                    objTemplate.TemplateType = TP.TemplateType.ToUpper();

                    objTemplate.CreatedBy   = TP.CreatedBy;
                    objTemplate.CreatedDate = DateTime.Now;

                    objTemplate.Status = 1;
                    db.TblTemplateTypeMasters.Add(objTemplate);
                    db.SaveChanges();
                    msg = "Template Type Saved Successfully!";
                }
                else
                {
                    TblTemplateTypeMaster objTempalte = db.TblTemplateTypeMasters.Where(r => r.TemplateTypeId == TP.TemplateTypeId).FirstOrDefault();
                    var Data = db.TblTemplateTypeMasters.Where(r => r.TemplateType == TP.TemplateType && r.TemplateTypeId == TP.TemplateTypeId).FirstOrDefault();
                    if (Data == null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Duplicate Entry Not Allowed"
                        });
                    }
                    objTempalte.TemplateType   = TP.TemplateType.ToUpper();
                    objTempalte.ModifiedBy     = TP.ModifiedBy;
                    objTempalte.ModifiedDate   = DateTime.Now;
                    objTempalte.TemplateTypeId = TP.TemplateTypeId;
                    db.SaveChanges();
                    msg = "Template Type Updated Successfully!";
                }

                return(new Result()
                {
                    IsSucess = true, ResultData = msg
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
Beispiel #2
0
        public object SaveModule(ModuleParam MP)
        {
            try
            {
                string msg = "";
                if (MP.BtnStatus == "Save")
                {
                    var usercode = db.TblModuleMasters.Where(r => r.ModuleName == MP.ModuleName.ToUpper()).FirstOrDefault();
                    if (usercode != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Module Name Already Exists!"
                        });
                    }
                    TblModuleMaster objModule = new TblModuleMaster();

                    objModule.ModuleName     = MP.ModuleName.ToUpper();
                    objModule.ModuleOrder    = MP.ModuleOrder;
                    objModule.CreatedBy      = MP.CreatedBy;
                    objModule.CreatedDate    = DateTime.Now;
                    objModule.ParentModuleId = 0;
                    objModule.Status         = 1;
                    db.TblModuleMasters.Add(objModule);
                    db.SaveChanges();
                    msg = "Module Saved Successfully!";
                }
                else
                {
                    TblModuleMaster objModule = db.TblModuleMasters.Where(r => r.ModuleId == MP.ModuleId).FirstOrDefault();

                    objModule.ModuleName   = MP.ModuleName.ToUpper();
                    objModule.ModuleOrder  = MP.ModuleOrder;
                    objModule.ModifiedDate = DateTime.Now;
                    objModule.ModuleId     = MP.ModuleId;
                    db.SaveChanges();
                    msg = "Module Updated Successfully!";
                }

                return(new Result()
                {
                    IsSucess = true, ResultData = msg
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        public object SaveDivision(DivisionParam DivParam)
        {
            Tbl_Division_Master obj = new Tbl_Division_Master();

            obj.DivisionName = DivParam.DivisionName;
            obj.CreatedBy    = 1;
            obj.CreatedDate  = DateTime.Now;
            obj.ModifiedBy   = null;
            obj.ModifiedDate = null;
            obj.Status       = 1;
            db.Tbl_Division_Master.Add(obj);
            db.SaveChanges();
            return(new Result()
            {
                IsSucess = true, ResultData = "Division Save Successfully"
            });
        }
Beispiel #4
0
        public object AddStandard(StandardParam StdParam)
        {
            Tbl_StandardMaster obj = new Tbl_StandardMaster();

            obj.StandardName = StdParam.StandardName;
            obj.Status       = 1;
            obj.CreatedBy    = 1;
            obj.CreatedDate  = System.DateTime.Today.Date;
            obj.ModifiedBy   = null;
            obj.ModifiedDate = null;
            db.Tbl_StandardMaster.Add(obj);
            db.SaveChanges();
            return(new Result()
            {
                IsSucess = true, ResultData = "Standard Save Successfully"
            });
        }
Beispiel #5
0
        public object SaveWidget(WidgetParam b)
        {
            if (b.WidgetName == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Required WidgetName"
                });
            }
            var data = db.Tbl_Widget_Master.FirstOrDefault(r => r.WidgetName == b.WidgetName);

            if (data != null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Duplicate Entry Not Allowed"
                });
            }
            try
            {
                Tbl_Widget_Master obj = new Tbl_Widget_Master();
                obj.WidgetName   = b.WidgetName;
                obj.ActionName   = b.ActionName;
                obj.Status       = 1;
                obj.CreatedBy    = 1;
                obj.CreatedDate  = System.DateTime.Today.Date;
                obj.ModifiedBy   = null;
                obj.ModifiedDate = System.DateTime.Today.Date;
                db.Tbl_Widget_Master.Add(obj);
                db.SaveChanges();
                return(new Result()
                {
                    IsSucess = true, ResultData = "Widget Created Successfully!"
                });
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
Beispiel #6
0
 public object SaveSubject(SubjectParam ObjParam)
 {
     try
     {
         var Duplicate = db.Tbl_Subject_Master.SingleOrDefault(r => r.SubjectName == ObjParam.SubjectName && r.SubjectCode == ObjParam.SubjectCode);
         if (Duplicate != null)
         {
             return(new Result()
             {
                 IsSucess = true, ResultData = "Duplicate Entry Not Allowed"
             });
         }
         else
         {
             Tbl_Subject_Master obj = new Tbl_Subject_Master();
             obj.SubjectName  = ObjParam.SubjectName;
             obj.SubjectCode  = ObjParam.SubjectCode;
             obj.Status       = 1;
             obj.CreatedBy    = 1;
             obj.ModifiedBy   = null;
             obj.ModifiedDate = null;
             obj.CreatedDate  = DateTime.Now;
             db.Tbl_Subject_Master.Add(obj);
             db.SaveChanges();
             return(new Result()
             {
                 IsSucess = true, ResultData = "Subject Save Successfully"
             });
         }
     }
     catch (Exception ex)
     {
         return(new Error()
         {
             IsError = true, Message = "Error"
         });
     }
 }
        public object SaveTemplateMaster(TemplateMasterParam TP)
        {
            try
            {
                TblTemplatesMaster objTemplate = new TblTemplatesMaster();

                string msg = "";
                if (TP.BtnStatus == "Save")
                {
                    var usercode = db.TblTemplatesMasters.Where(r => r.Name == TP.Name.ToUpper()).FirstOrDefault();
                    if (usercode != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Template Name Already Exists!"
                        });
                    }

                    objTemplate.Name           = TP.Name.ToUpper();
                    objTemplate.TemplateTypeId = TP.TemplateTypeId;
                    objTemplate.CreatedBy      = TP.CreatedBy;
                    objTemplate.CreatedDate    = DateTime.Now;
                    objTemplate.Status         = 1;
                    db.TblTemplatesMasters.Add(objTemplate);
                    db.SaveChanges();

                    TblTemplateModule objTemplateModule = new TblTemplateModule();

                    string   MenuIds = TP.MenuListIds.Trim(',');
                    string[] ids     = MenuIds.Split(',');
                    for (int i = 0; i < ids.Length; i++)
                    {
                        objTemplateModule.TemplateId  = objTemplate.TemplateId;
                        objTemplateModule.ModuleId    = Convert.ToInt32(ids[i]);
                        objTemplateModule.CreatedBy   = TP.CreatedBy;
                        objTemplateModule.CreatedDate = DateTime.Now;
                        objTemplateModule.Status      = 1;
                        db.TblTemplateModules.Add(objTemplateModule);
                        db.SaveChanges();
                    }
                    msg = "Template Master Saved Successfully!";
                }
                else
                {
                    TblTemplatesMaster objTempalte = db.TblTemplatesMasters.Where(r => r.TemplateId == TP.TemplateId).FirstOrDefault();
                    objTempalte.Name           = TP.Name.ToUpper();
                    objTempalte.TemplateId     = TP.TemplateId;
                    objTempalte.ModifiedBy     = TP.ModifiedBy;
                    objTempalte.ModifiedDate   = DateTime.Now;
                    objTempalte.TemplateTypeId = TP.TemplateTypeId;
                    db.SaveChanges();


                    db.TblTemplateModules.RemoveRange(db.TblTemplateModules.Where(c => c.TemplateId == TP.TemplateId));

                    db.SaveChanges();

                    TblTemplateModule objTemplateModule = new TblTemplateModule();

                    string   MenuIds = TP.MenuListIds.Trim(',');
                    string[] ids     = MenuIds.Split(',');
                    for (int i = 0; i < ids.Length; i++)
                    {
                        objTemplateModule.TemplateId  = TP.TemplateId;
                        objTemplateModule.ModuleId    = Convert.ToInt32(ids[i]);
                        objTemplateModule.CreatedBy   = TP.CreatedBy;
                        objTemplateModule.CreatedDate = DateTime.Now;
                        objTemplateModule.Status      = 1;
                        db.TblTemplateModules.Add(objTemplateModule);
                        db.SaveChanges();
                    }
                    msg = "Template Master Updated Successfully!";
                }

                return(new Result()
                {
                    IsSucess = true, ResultData = msg
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        public object SaveSchool(School school)
        {
            if (school.UserName == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Required Username"
                });
            }

            TblSchool obj         = new TblSchool();
            var       httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count > 0)
            {
                string UploadBaseUrl = ConfigurationManager.AppSettings["UploadBaseURL"];
                string fileName      = string.Empty;
                var    filePath      = string.Empty;
                string savePath      = string.Empty;
                foreach (string file in httpRequest.Files)
                {
                    var postedFile = httpRequest.Files[file];
                    fileName              = postedFile.FileName;
                    filePath              = ConfigurationManager.AppSettings["UploadDir"] + Guid.NewGuid() + fileName;
                    savePath              = HttpContext.Current.Server.MapPath(filePath); postedFile.SaveAs(savePath);
                    obj.SchoolName        = school.SchoolName;
                    obj.PhoneNo           = school.PhoneNo;
                    obj.Address           = school.Address;
                    obj.ContactPerson     = school.ContactPerson;
                    obj.LandlineNo        = school.LandlineNo;
                    obj.EmailId           = school.EmailId;
                    obj.Designation       = school.Designation;
                    obj.ValidityStartDate = school.ValidityStartDate;
                    obj.ValidityEndDate   = school.ValidityEndDate;
                    obj.PayrollTemplateId = school.PayrollTemplateId;
                    obj.FeeTemplateId     = school.FeeTemplateId;
                    obj.LoginTemplateId   = school.LoginTemplateId;
                    obj.ExamTemplateId    = school.ExamTemplateId;
                    obj.CreatedBy         = 1;
                    obj.CreatedDate       = school.CreatedDate;
                    obj.ModifiedBy        = 1;
                    obj.ModifiedDate      = school.ModifiedDate;
                    obj.UserPrefix        = school.UserPrefix;
                    obj.UserName          = school.UserName;
                    obj.Password          = school.Password;
                    obj.BoardId           = school.BoardId;
                    obj.Language          = school.Language;
                    obj.Logo              = UploadBaseUrl + filePath.Replace("~/", "");
                    obj.Banner            = school.Banner;
                    obj.Status            = 1;

                    db.TblSchools.Add(obj);
                    db.SaveChanges();
                }
            }
            //user.code = Convert.ToInt32(HttpContext.Current.Session["Code"]);
            return(new Result
            {
                IsSucess = true,
                ResultData = "School Created!"
            });
        }
        public object SaveMenu(ModuleParam PM)
        {
            try
            {
                if (PM.BtnStatus == "Save")
                {
                    if (PM.ModuleName == null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Please Enter Menu Name !!"
                        });
                    }

                    TblModuleMaster objuser = new TblModuleMaster();
                    var             result  = db.TblModuleMasters.FirstOrDefault(r => r.ModuleName == PM.ModuleName.ToUpper());
                    if (result != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Menu with Same Name Already Exists !!"
                        });
                    }

                    if (PM.ParentMenuId == 0)
                    {
                        objuser.ParentModuleId = PM.ModuleId;
                    }
                    else
                    {
                        objuser.ParentModuleId = PM.ParentMenuId;
                    }
                    objuser.ModuleName  = PM.ModuleName.ToUpper();
                    objuser.ModuleOrder = Convert.ToInt64(PM.ModuleOrder);
                    objuser.Status      = 1;
                    objuser.ActionName  = PM.ActionName;
                    objuser.CreatedDate = DateTime.Now;


                    db.TblModuleMasters.Add(objuser);
                    db.SaveChanges();

                    return(new Result()
                    {
                        IsSucess = true, ResultData = "Menu Added Successfully."
                    });
                }

                else
                {
                    TblModuleMaster obGR = db.TblModuleMasters.Where(r => r.ModuleId == PM.ModuleId).FirstOrDefault();

                    obGR.ModuleName     = PM.ModuleName;
                    obGR.ParentModuleId = PM.ParentMenuId;
                    obGR.ModuleOrder    = Convert.ToInt64(PM.ModuleOrder);
                    obGR.ActionName     = PM.ActionName;
                    obGR.ModifiedBy     = PM.ModifiedBy;
                    obGR.ModifiedDate   = DateTime.Now;
                    db.SaveChanges();

                    return(new Result()
                    {
                        IsSucess = true, ResultData = "Menu Updated Successfully."
                    });
                }
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
Beispiel #10
0
        public object SaveSchool(School s)
        {
            try
            {
                var    Logo   = System.Web.HttpContext.Current.Request.Files["file"];
                var    Banner = System.Web.HttpContext.Current.Request.Files["file1"];
                var    json1  = System.Web.HttpContext.Current.Request.Form["id"];
                var    json   = System.Web.HttpContext.Current.Request.Form["data"];
                School school = Newtonsoft.Json.JsonConvert.DeserializeObject <School>(json);
                //var boardid = json1.Replace(",", "");

                if (school.UserName == null)
                {
                    return(new Error()
                    {
                        IsError = true, Message = "Required Username"
                    });
                }
                var info = db.TblSchools.FirstOrDefault(r => r.SchoolName == school.SchoolName);
                if (info != null)
                {
                    return(new Error()
                    {
                        IsError = true, Message = "Duplicate Entry Not Allowed"
                    });
                }
                TblSchool obj            = new TblSchool();
                var       httpRequest    = HttpContext.Current.Request;
                string    UploadBaseUrl  = ConfigurationManager.AppSettings["UploadBaseURL"];
                string    fileLogo       = string.Empty;
                string    fileBanner     = string.Empty;
                var       filePath       = string.Empty;
                string    savePath       = string.Empty;
                var       filePathBanner = string.Empty;
                var       filePathSave   = string.Empty;
                var       Upload         = school.SchoolName;

                obj.SchoolName        = school.SchoolName;
                obj.PhoneNo           = school.PhoneNo;
                obj.Address           = school.Address;
                obj.ContactPerson     = school.ContactPerson;
                obj.LandlineNo        = school.LandlineNo;
                obj.EmailId           = school.EmailId;
                obj.Designation       = school.Designation;
                obj.ValidityStartDate = school.ValidityStartDate;
                obj.ValidityEndDate   = school.ValidityEndDate;
                obj.PayrollTemplateId = school.PayrollTemplateId;
                obj.FeeTemplateId     = school.FeeTemplateId;
                obj.LoginTemplateId   = school.LoginTemplateId;
                obj.ExamTemplateId    = school.ExamTemplateId;
                obj.CreatedBy         = 1;
                obj.CreatedDate       = System.DateTime.Today.Date;
                obj.ModifiedBy        = 1;
                obj.ModifiedDate      = System.DateTime.Today.Date;
                obj.UserPrefix        = school.UserPrefix;
                obj.UserName          = school.UserName;
                obj.Password          = school.Password;
                obj.Language          = school.Language;
                obj.Status            = 1;

                var uploaddirc = Path.Combine(HttpContext.Current.Server.MapPath("/"), "SchoolUpload" + ("\\"));
                if (!Directory.Exists(uploaddirc))
                {
                    DirectoryInfo di = Directory.CreateDirectory(uploaddirc);
                }
                string paths = "SchoolUpload";
                for (int i = 0; i < httpRequest.Files.Count; i++)
                {
                    var uploadpath = Path.Combine(HttpContext.Current.Server.MapPath("/"), paths, Upload.ToString() + ("\\"));
                    if (!Directory.Exists(uploadpath))
                    {
                        DirectoryInfo di = Directory.CreateDirectory(uploadpath);
                    }
                    if (i == 0 && Logo != null)
                    {
                        var file  = httpRequest.Files[i];
                        var Guids = Guid.NewGuid();
                        filePathSave = uploadpath + Guids;
                        filePath     = filePathSave + file.FileName;

                        savePath = uploadpath;
                        file.SaveAs(filePath);
                        obj.Logo = UploadBaseUrl + paths + ("/") + Upload.ToString() + ("/") + Guids + file.FileName;
                        //string Logo1 = data.Logo.Replace("~/", "");
                        //data.Logo = Logo1;
                    }
                    else
                    {
                        var file        = httpRequest.Files[i];
                        var GuidsBanner = Guid.NewGuid();
                        filePathSave   = uploadpath + GuidsBanner;
                        filePathBanner = filePathSave + file.FileName;

                        savePath = uploadpath;
                        file.SaveAs(filePathBanner);
                        obj.Banner = UploadBaseUrl + paths + ("/") + Upload.ToString() + ("\\") + GuidsBanner + file.FileName;
                        //string Banner1 = data.Banner.Replace("~/", "");
                        //data.Banner = Banner1;
                    }
                }

                db.TblSchools.Add(obj);
                db.SaveChanges();
                CopyDB objDB = new CopyDB();
                string name  = school.SchoolName.Replace(" ", "") + "DB";
                objDB.Copydata(name.ToUpper());
                var            details = db.TblSchools.FirstOrDefault(r => r.SchoolName == school.SchoolName);
                TblBoardDetail board   = new TblBoardDetail();
                string[]       ids     = json1.Split(',');

                for (int i = 0; i < ids.Length; i++)
                {
                    board.SchoolId     = details.SchoolId;
                    board.BoardId      = Convert.ToInt64(ids[i].Replace("[", "").Replace("]", ""));
                    board.CreatedBy    = 1;
                    board.CreatedDate  = System.DateTime.Today.Date;
                    board.ModifiedBy   = null;
                    board.ModifiedDate = System.DateTime.Today.Date;
                    db.TblBoardDetails.Add(board);
                    db.SaveChanges();
                }


                //user.code = Convert.ToInt32(HttpContext.Current.Session["Code"]);
                return(new Result
                {
                    IsSucess = true,
                    ResultData = "School Created!"
                });
            }
            catch (Exception e)
            {
                return(new Error {
                    IsError = true, Message = e.Message
                });
            }
        }
        public object SaveStdWiseDiv(StdWiseDivParam objParam)
        {
            try
            {
                objParam.DivisionID = objParam.DivisionID.Trim(',');
                string[] division     = objParam.DivisionID.Split(',');
                int      count        = 0;
                String   DivisionName = "";
                string   StandardName = "";

                for (int i = 0; i < division.Length; i++)
                {
                    var divid = Convert.ToInt32(division[i]);

                    var duplicate = db.View_Display_StandardWiseDivision.SingleOrDefault(r => r.DivisionID == divid && r.StandardID == objParam.StandardID && r.Status == 1);
                    if (duplicate != null)
                    {
                        DivisionName = DivisionName + duplicate.DivisionName + ",";
                        StandardName = duplicate.StandardName;
                        count        = 1;
                    }
                    if (i == division.Length - 1)
                    {
                        if (count == 0)
                        {
                            Tbl_StandardWiseDivision obj = new Tbl_StandardWiseDivision();
                            obj.BoardID      = objParam.BoardId;
                            obj.DivisionID   = Convert.ToInt64(division[i].ToString());
                            obj.StandardID   = objParam.StandardID;
                            obj.Status       = 1;
                            obj.CreatedBy    = 1;
                            obj.CreatedDate  = DateTime.Now;
                            obj.ModifiedBy   = null;
                            obj.ModifiedDate = null;
                            db.Tbl_StandardWiseDivision.Add(obj);
                            db.SaveChanges();
                        }


                        else
                        {
                            DivisionName = DivisionName.Trim(',');
                            StandardName = StandardName.Trim(',');

                            return(new Result {
                                IsSucess = true, ResultData = "Division " + DivisionName + " Already Assign to Standard " + StandardName
                            });
                        }
                    }
                }

                return(new Result {
                    IsSucess = true, ResultData = "Division Assign Successfully"
                });
            }
            catch (Exception ex)
            {
                return(new Result {
                    IsSucess = false, ResultData = "Error"
                });
            }
        }