public ActionResult SaveFNMGROUP(FNMGROUP_VM FG)
        {
            List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>;

            if (list == null)
            {
                return(Redirect("Login/InLogin"));
            }
            else
            {
                FG.CMPYCODE = list[0].CmpyCode;
                FG.UserName = list[0].user_name;
                return(Json(_FNMGROUPService.SaveFNMGROUP(FG), JsonRequestBehavior.AllowGet));
            }
        }
        public FNMGROUP_VM SaveFNMGROUP(FNMGROUP_VM FG)
        {
            try
            {
                if (!FG.EditFlag)
                {
                    var Drecord = new List <string>();
                    List <FNMGROUPDetailnew> ObjList = new List <FNMGROUPDetailnew>();
                    ObjList.AddRange(FG.FNMGROUPDetailnew.Select(m => new FNMGROUPDetailnew
                    {
                        CMPYCODE      = m.CMPYCODE,
                        FNMGROUP_CODE = m.FNMGROUP_CODE,
                        DESCRIPTION   = m.DESCRIPTION,
                    }).ToList());
                    int n = 0;
                    n = ObjList.Count;

                    while (n > 0)
                    {
                        int Stats1 = _EzBusinessHelper.ExecuteScalar("Select count(*) as [count1] from FNMGROUP where CmpyCode='" + FG.CMPYCODE + "' and FNMGROUP_CODE='" + ObjList[n - 1].FNMGROUP_CODE + "'");
                        if (Stats1 == 0)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append("'" + FG.CMPYCODE + "',");
                            sb.Append("'" + ObjList[n - 1].FNMGROUP_CODE + "',");
                            sb.Append("'" + ObjList[n - 1].DESCRIPTION + "')");

                            _EzBusinessHelper.ExecuteNonQuery("insert into FNMGROUP(CMPYCODE,FNMGROUP_CODE,DESCRIPTION) values(" + sb.ToString() + "");

                            _EzBusinessHelper.ActivityLog(FG.CMPYCODE, FG.UserName, "Add FN Group", ObjList[n - 1].FNMGROUP_CODE, Environment.MachineName);

                            FG.SaveFlag     = true;
                            FG.ErrorMessage = string.Empty;
                        }
                        else
                        {
                            Drecord.Add(ObjList[n - 1].FNMGROUP_CODE.ToString());

                            FG.Drecord      = Drecord;
                            FG.SaveFlag     = false;
                            FG.ErrorMessage = "Duplicate Record";
                        }
                        n = n - 1;
                    }

                    return(FG);
                }
                var StatsEdit = _EzBusinessHelper.ExecuteScalarDec("Select count(*) from FNMGROUP where CmpyCode='" + FG.CMPYCODE + "' and FNMCAT_CODE='" + FG.FNMGROUP_CODE + "'and Flag=0");
                if (StatsEdit != 0)
                {
                    _EzBusinessHelper.ExecuteNonQuery("update FNMGROUP set CmpyCode='" + FG.CMPYCODE + "',FNMGROUP_CODE='" + FG.FNMGROUP_CODE + "',DESCRIPTION='" + FG.DESCRIPTION + "' where CmpyCode='" + FG.CMPYCODE + "' and FNMGROUP_CODE='" + FG.FNMGROUP_CODE + "'");

                    _EzBusinessHelper.ActivityLog(FG.CMPYCODE, FG.UserName, "Update FNMGROUP", FG.FNMGROUP_CODE, Environment.MachineName);

                    FG.SaveFlag     = true;
                    FG.ErrorMessage = string.Empty;
                }
                else
                {
                    FG.SaveFlag     = false;
                    FG.ErrorMessage = "Record not available";
                }
            }
            catch (Exception ex)
            {
                FG.SaveFlag = false;
            }

            return(FG);
        }
 public FNMGROUP_VM SaveFNMGROUP(FNMGROUP_VM FC)
 {
     return(_FNMGROUPERepo.SaveFNMGROUP(FC));
 }