Exemplo n.º 1
0
 protected void linkbtnEdit_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "UpdateID")
         {
             int cmdArg = Convert.ToInt32(e.CommandArgument);
             EventConfigurationModel li = obj.getEventConfigByID(cmdArg);
             if (li != null)
             {
                 ddlObject.SelectedValue = li.ObjectID.ToString();
                 ddlObjsensorbind(Convert.ToInt32(li.ObjectID));
                 ddlObjSensor.SelectedValue = li.ObjectSensorID.ToString();
                 txtMin.Text = li.Min.ToString();
                 txtMax.Text = li.MAX.ToString();
                 ddlCondition.SelectedValue = li.Condition.ToString();
                 cbEnabled.Checked          = Convert.ToBoolean(li.EnableOrDisable);
                 Session["eventConfigId"]   = cmdArg.ToString();
                 btnSave.Text = "Update";
             }
         }
     }
     catch (Exception)
     { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
 }
Exemplo n.º 2
0
        public EventConfigurationModel getEventConfigByID(int eventConfigID)
        {
            EventConfigurationModel model = null;

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@EventConfigID", eventConfigID)
            };
            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("Select * from [EventConfiguration] Where EventConfigID = @EventConfigID", CommandType.Text, parameters))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];
                    model = new EventConfigurationModel();
                    model.EventConfigID   = Convert.ToInt32(row["EventConfigID"]);
                    model.ObjectID        = Convert.ToInt32(row["ObjectID"]);
                    model.ObjectSensorID  = Convert.ToInt64(row["ObjectSensorID"]);
                    model.Min             = Convert.ToDouble(row["Min"]);
                    model.MAX             = Convert.ToDouble(row["MAX"]);
                    model.a0              = Convert.ToDouble(row["a0"]);
                    model.a1              = Convert.ToDouble(row["a1"]);
                    model.Condition       = Convert.ToInt32(row["Condition"]);
                    model.Contact         = row["Contact"].ToString();
                    model.Units           = row["Units"].ToString();
                    model.Format          = row["Format"].ToString();
                    model.EnableOrDisable = Convert.ToBoolean(row["EnableOrDisable"]);
                }
            }
            return(model);
        }
Exemplo n.º 3
0
        public List <EventConfigurationModel> getEventConfigByObject(int objectID)
        {
            List <EventConfigurationModel> list = new List <EventConfigurationModel>();

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ObjectID", objectID)
            };
            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("uspGET_EventConfigurationByObject", CommandType.StoredProcedure, parameters))
            {
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        EventConfigurationModel model = new EventConfigurationModel();
                        model.EventConfigID   = Convert.ToInt32(row["EventConfigID"]);
                        model.ObjectID        = Convert.ToInt32(row["ObjectID"]);
                        model.ObjectSensorID  = Convert.ToInt64(row["ObjectSensorID"]);
                        model.Name            = row["Name"].ToString();
                        model.Min             = Convert.ToDouble(row["Min"]);
                        model.MAX             = Convert.ToDouble(row["MAX"]);
                        model.a0              = Convert.ToDouble(row["a0"]);
                        model.a1              = Convert.ToDouble(row["a1"]);
                        model.Condition       = Convert.ToInt32(row["Condition"]);
                        model.Contact         = row["Contact"].ToString();
                        model.Units           = row["Units"].ToString();
                        model.Format          = row["Format"].ToString();
                        model.EnableOrDisable = Convert.ToBoolean(row["EnableOrDisable"]);
                        list.Add(model);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (ddlObject.SelectedValue != "0" && ddlObjSensor.SelectedValue != "0" && ddlCondition.SelectedValue != "0")
         {
             EventConfigurationModel model = new EventConfigurationModel();
             model.EnableOrDisable = cbEnabled.Checked ? true : false;
             model.ObjectID        = Convert.ToInt32(ddlObject.SelectedValue);
             model.ObjectSensorID  = Convert.ToInt32(ddlObjSensor.SelectedValue);
             model.Min             = Convert.ToDouble(txtMin.Text);
             model.MAX             = Convert.ToDouble(txtMax.Text);
             model.Condition       = Convert.ToInt32(ddlCondition.SelectedValue);
             model.a0      = Convert.ToDouble(txta0.Text);
             model.a1      = Convert.ToDouble(txta1.Text);
             model.Contact = txtContact.Text + ",";
             model.Format  = txtFormat.Text;
             model.Units   = txtUnit.Text;
             if (btnSave.Text == "Save")
             {
                 model.EventConfigID = 0;
                 bool status = obj.postEventConfig(model);
                 if (status == true)
                 {
                     alert = AlertsClass.SuccessUpdate;
                 }
                 else
                 {
                     alert = AlertsClass.ErrorWentWrong;
                 }
             }
             if (btnSave.Text == "Update")
             {
                 model.EventConfigID = Convert.ToInt32(Session["eventConfigId"]);
                 bool status = obj.postEventConfig(model);
                 if (status == true)
                 {
                     alert = AlertsClass.SuccessUpdate;
                 }
                 else
                 {
                     alert = AlertsClass.ErrorWentWrong;
                 }
             }
         }
         else
         {
             alert = AlertsClass.ErrorRequired;
         }
         gridBind(Convert.ToInt32(ddlObject.SelectedValue));
         allowStaticMethods("ALerts('" + alert + "');applyDatatable('.gvdEventConfigClass');staticMethod('Disable');");
     }
     catch (Exception)
     { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
 }
        public EventConfigurationModel GetEventConfigurationById(int ECId)
        {
            var    url    = "api/EventConfiguration/" + ECId;
            string result = SC.Getcaller(url);

            if (result != null)
            {
                EventConfigurationModel _EventConfigurationModel = JsonConvert.DeserializeObject <EventConfigurationModel>(result);
                return(_EventConfigurationModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        public bool postEventConfig(EventConfigurationModel _object)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@EventConfigID", _object.EventConfigID),
                new SqlParameter("@ObjectSensorID", _object.ObjectSensorID),
                new SqlParameter("@ObjectID", _object.ObjectID),
                new SqlParameter("@Min", _object.Min),
                new SqlParameter("@MAX", _object.MAX),
                new SqlParameter("@a0", _object.a0),
                new SqlParameter("@a1", _object.a1),
                new SqlParameter("@Contact", _object.Contact),
                new SqlParameter("@Units", _object.Units),
                new SqlParameter("@Format", _object.Format),
                new SqlParameter("@Condition", _object.Condition),
                new SqlParameter("@EnableOrDisable", _object.EnableOrDisable),
            };

            return(DBHelper.ExecuteNonQuery("uspPOST_EventConfiguration", CommandType.StoredProcedure, parameters));
        }