public ActionResult SaveFNMSUBGROUP(FNMSUBGROUP_VM FSG) { List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>; if (list == null) { return(Redirect("Login/InLogin")); } else { FSG.CMPYCODE = list[0].CmpyCode; FSG.UserName = list[0].user_name; return(Json(_FNMSUBGROUPService.SaveFNMSUBGROUP(FSG), JsonRequestBehavior.AllowGet)); } }
public FNMSUBGROUP_VM SaveFNMSUBGROUP(FNMSUBGROUP_VM FT) { return(_FNMSUBGROUPERepo.SaveFNMSUBGROUP(FT)); }
public FNMSUBGROUP_VM SaveFNMSUBGROUP(FNMSUBGROUP_VM FSG) { try { if (!FSG.EditFlag) { var Drecord = new List <string>(); List <FNMSUBGROUPDetailnew> ObjList = new List <FNMSUBGROUPDetailnew>(); ObjList.AddRange(FSG.FNMSUBGROUPDetailnew.Select(m => new FNMSUBGROUPDetailnew { CMPYCODE = m.CMPYCODE, FNMSUBGROUP_CODE = m.FNMSUBGROUP_CODE, DESCRIPTION = m.DESCRIPTION, }).ToList()); int n = 0; n = ObjList.Count; while (n > 0) { decimal Stats1 = _EzBusinessHelper.ExecuteScalarDec("Select count(*) as [count1] from FNMSUBGROUP where CmpyCode='" + FSG.CMPYCODE + "' and FNMSUBGROUP_CODE='" + ObjList[n - 1].FNMSUBGROUP_CODE + "'"); if (Stats1 == 0) { StringBuilder sb = new StringBuilder(); sb.Append("'" + FSG.CMPYCODE + "',"); sb.Append("'" + ObjList[n - 1].FNMSUBGROUP_CODE + "',"); sb.Append("'" + ObjList[n - 1].DESCRIPTION + "')"); _EzBusinessHelper.ExecuteNonQuery("insert into FNMSUBGROUP(CMPYCODE,FNMSUBGROUP_CODE,DESCRIPTION) values(" + sb.ToString() + ""); _EzBusinessHelper.ActivityLog(FSG.CMPYCODE, FSG.UserName, "Add FN SubGroup", ObjList[n - 1].FNMSUBGROUP_CODE, Environment.MachineName); FSG.SaveFlag = true; FSG.ErrorMessage = string.Empty; } else { Drecord.Add(ObjList[n - 1].FNMSUBGROUP_CODE.ToString()); FSG.Drecord = Drecord; FSG.SaveFlag = false; FSG.ErrorMessage = "Duplicate Record"; } n = n - 1; } return(FSG); } var StatsEdit = _EzBusinessHelper.ExecuteScalarDec("Select count(*) from FNMSUBGROUP where CmpyCode='" + FSG.CMPYCODE + "' and FNMSUBGROUP_CODE='" + FSG.FNMSUBGROUP_CODE + "'and Flag=0"); if (StatsEdit != 0) { _EzBusinessHelper.ExecuteNonQuery("update FNMSUBGROUP set CmpyCode='" + FSG.CMPYCODE + "',FNMSUBGROUP_CODE='" + FSG.FNMSUBGROUP_CODE + "',DESCRIPTION='" + FSG.DESCRIPTION + "' where CmpyCode='" + FSG.CMPYCODE + "' and FNMSUBGROUP_CODE='" + FSG.FNMSUBGROUP_CODE + "'"); _EzBusinessHelper.ActivityLog(FSG.CMPYCODE, FSG.UserName, "Update FNMSUBGROUP", FSG.FNMSUBGROUP_CODE, Environment.MachineName); FSG.SaveFlag = true; FSG.ErrorMessage = string.Empty; } else { FSG.SaveFlag = false; FSG.ErrorMessage = "Record not available"; } } catch (Exception ex) { FSG.SaveFlag = false; } return(FSG); }