Ejemplo n.º 1
0
        public ActionResult SaveDis(DisciplineVM Dis)
        {
            List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>;

            if (list == null)
            {
                return(Redirect("Login/InLogin"));
            }
            else
            {
                Dis.CmpyCode = list[0].CmpyCode;
                Dis.UserName = list[0].user_name;
                return(Json(_DiService.SaveDis(Dis), JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public DisciplineVM SaveDis(DisciplineVM Dis)
        {
            try
            {
                if (!Dis.EditFlag)
                {
                    var Drecord = new List <string>();
                    List <DisciplineDetailnew> ObjList = new List <DisciplineDetailnew>();
                    ObjList.AddRange(Dis.DisciplineDetailnew.Select(m => new DisciplineDetailnew
                    {
                        CmpyCode    = m.CmpyCode,
                        Code        = m.Code,
                        Name        = m.Name,
                        UniCodeName = m.UniCodeName
                    }).ToList());
                    int n = 0;
                    n = ObjList.Count;

                    while (n > 0)
                    {
                        int Dis1 = _EzBusinessHelper.ExecuteScalar("Select count(*) as [count1] from MDISC010 where CmpyCode='" + Dis.CmpyCode + "' and Code='" + ObjList[n - 1].Code + "'");
                        if (Dis1 == 0)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append("'" + Dis.CmpyCode + "',");
                            sb.Append("'" + ObjList[n - 1].Code + "',");
                            sb.Append("'" + ObjList[n - 1].Name + "',");
                            sb.Append("'" + ObjList[n - 1].UniCodeName + "')");
                            _EzBusinessHelper.ExecuteNonQuery("insert into MDISC010(CmpyCode,Code,Name,UniCodeName) values(" + sb.ToString() + "");
                            Dis.SaveFlag     = true;
                            Dis.ErrorMessage = string.Empty;
                        }
                        else
                        {
                            Drecord.Add(ObjList[n - 1].Code.ToString());

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


                    return(Dis);
                }
                var StatsEdit = _EzBusinessHelper.ExecuteScalar("Select count(*) from MDISC010 where CmpyCode='" + Dis.CmpyCode + "' and Code='" + Dis.Code + "'");
                if (StatsEdit != 0)
                {
                    _EzBusinessHelper.ExecuteNonQuery("update MDISC010 set CmpyCode='" + Dis.CmpyCode + "',Code='" + Dis.Code + "',Name='" + Dis.Name + "',UniCodeName='" + Dis.UniCodeName + "' where CmpyCode='" + Dis.CmpyCode + "' and Code='" + Dis.Code + "'");
                    Dis.SaveFlag     = true;
                    Dis.ErrorMessage = string.Empty;
                }
                else
                {
                    Dis.SaveFlag     = false;
                    Dis.ErrorMessage = "Record not available";
                }
            }
            catch (Exception ex)
            {
                Dis.SaveFlag = false;
                //  unit.ErrorMessage = exceptionMessage;
            }



            return(Dis);
        }
Ejemplo n.º 3
0
 public DisciplineVM SaveDis(DisciplineVM Dis)
 {
     return(_DiRepo.SaveDis(Dis));
 }