Exemple #1
0
 //Update Status
 public JsonResult UpdateStatus(string id)
 {
     GlobalVarible.Clear();
     try
     {
         if (id != null)
         {
             Model             = new Josheph.Framework.Entity.SubDeviceMasterSUB();
             Model.SubDeviceId = new Guid(id);
             Model             = (ENT.SubDeviceMasterSUB)objBAL.GetByPrimaryKey(Model);
             if (Model.Status == COM.MyEnumration.MyStatus.Active)
             {
                 if (!objBAL.UpdateStatus(Model.SubDeviceId, COM.MyEnumration.MyStatus.DeActive))
                 {
                     throw new Exception("Internal Server Error in status update.");
                 }
             }
             if (Model.Status == COM.MyEnumration.MyStatus.DeActive)
             {
                 if (!objBAL.UpdateStatus(Model.SubDeviceId, COM.MyEnumration.MyStatus.Active))
                 {
                     throw new Exception("Internal Server Error in status update.");
                 }
             }
             GlobalVarible.AddMessage("Status Update Successfully.");
         }
     }
     catch (Exception ex)
     {
         GlobalVarible.AddError(ex.Message);
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }
Exemple #2
0
 //Edit Record
 public JsonResult EditRecord(string id)
 {
     if (id != null)
     {
         Model = new Josheph.Framework.Entity.SubDeviceMasterSUB();
         Model.UpdatedDateTime = DateTime.Now;
         Model.SubDeviceId     = new Guid(id);
         Model = (ENT.SubDeviceMasterSUB)objBAL.GetByPrimaryKey(Model);
     }
     return(Json(new { Model = Model }, JsonRequestBehavior.AllowGet));
 }
Exemple #3
0
 private List <string> ValidationEntry(object obj)
 {
     strvalidationResult.Clear();
     Entity = (ENT.SubDeviceMasterSUB)obj;
     if (string.IsNullOrWhiteSpace(Entity.SubDeviceName))
     {
         strvalidationResult.Add("Sub Device Name Required!");
     }
     if (string.IsNullOrWhiteSpace(Entity.SerialNo))
     {
         strvalidationResult.Add("Serial No Required!");
     }
     return(strvalidationResult);
 }
Exemple #4
0
        public object GetByPrimaryKey(ENT.SubDeviceMasterSUB Entity)
        {
            object objResult = null;

            try
            {
                DAL.CRUDOperation tt = new DAL.CRUDOperation();
                objResult = tt.GetEntityByPrimartKey(Entity);
            }
            catch (Exception)
            {
                throw;
            }
            return(objResult);
        }
Exemple #5
0
        //Save Entry
        public JsonResult SaveEntry(ENT.SubDeviceMasterSUB model, string SubDeviceId)
        {
            try
            {
                List <Guid> dctDuplication = new List <Guid>();
                //if (model.DeviceId.ToString() == "00000000-0000-0000-0000-000000000000") { throw new Exception("Please Select Device Type."); }
                if (model.SubDeviceType.ToString() == "00000000-0000-0000-0000-000000000000")
                {
                    throw new Exception("Please Select Sub Device Type.");
                }

                if (model.EntryMode == COM.MyEnumration.EntryMode.ADD)
                {
                    model.Status = COM.MyEnumration.MyStatus.Active;
                    List <ENT.SubDeviceMasterSUB> lstResult = new BAL.SubDeviceMasterBAL().CheckDuplicateCombination(dctDuplication, COM.MyEnumration.MasterType.SubDeviceMaster, model.SubDeviceName);
                    if (lstResult.Count > 0)
                    {
                        throw new Exception("Device Name Already Exists.");
                    }

                    List <ENT.SubDeviceMasterSUB> lstResult2 = new BAL.SubDeviceMasterBAL().CheckDuplicateSerialNo(dctDuplication, COM.MyEnumration.MasterType.SubDeviceMaster, model.SerialNo);
                    if (lstResult2.Count > 0)
                    {
                        throw new Exception("Serial No Already Exists.!");
                    }

                    if (objBAL.Insert(model, ""))
                    {
                        GlobalVarible.AddMessage("Record Save Successfully");
                    }
                }
                else
                {
                    model.CreatedDateTime = DateTime.Now;
                    model.SubDeviceId     = new Guid(SubDeviceId.Replace("/", ""));
                    if (objBAL.Update(model))
                    {
                        GlobalVarible.AddMessage("Record Update Successfully");
                    }
                }
            }
            catch (Exception ex)
            { GlobalVarible.AddError(ex.Message); }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
 //Delete Entry
 public JsonResult DeleteEntry(string id)
 {
     GlobalVarible.Clear();
     if (id != null)
     {
         Model             = new Josheph.Framework.Entity.SubDeviceMasterSUB();
         Model.SubDeviceId = new Guid(id);
         if (objBAL.Delete(Model))
         {
             GlobalVarible.AddMessage("Record Delete Successfully.");
         }
         else
         {
             GlobalVarible.AddError("Internal Server Error Please Try Again");
         }
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }