/// <summary>
        /// load dropdownlist 
        /// </summary>
        /// <param name="ddl">System.Web.UI.WebControls.DropDownList ddl</param>
        public static void fillDropDownItems(System.Web.UI.WebControls.DropDownList ddl, string comID, string type)
        {
            try
            {

                RulesData _r = new RulesData();
                Geofence _g = new Geofence();
                Units _u = new Units();

                if (type == "rules")
                {
                    new RulesDataSelect().RulesDropDownList(_r._dropDownList, comID);

                    ddl.DataSource = _r._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }
                else if ( type == "geo")
                {
                    new RulesDataSelect("geo").GeoDropDownList(_g._dropDownList, comID);
                    ddl.DataSource = _g._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }

                else if (type == "units")
                {
                    new RulesDataSelect("units").UnitsDropDownList(_u._dropDownList, comID);
                    ddl.DataSource = _u._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddl = null;
            }
        }
    public void UpdateRules()
    {
        RulesData _rules = new RulesData();

        ProcessSpeedingNotQueries update = new ProcessSpeedingNotQueries(AlarmasABC.BLL.InvokeOperations.operations.UPDATE);

        try
        {
            bool _status = false;
        bool isSMS = _ckOnSMS.Checked;

            _status = _chkOn.Checked;

            _rules.RulesValue = _txtSpeedValue.Text.ToString();
            _rules.Email = _txtNotificationEmails.Text.ToString();
            _rules.Message = _txtMessage.Text.ToString();
            _rules.SpeedingPhoneNum = _txtPhoneNumber.Text.Trim();
            if (_txtPhoneNumber.Text == "")
            {
        isSMS = false;
            }
            _rules.IsSMS = isSMS;
            _rules.UnitID = int.Parse( Request.QueryString["unitID"].ToString());
            _rules.RulesID = int.Parse(ViewState["rulesID"].ToString());
            _rules.IsActive = _status;

            update.RulesInfo = _rules;
            update.invoke();

            _lblMessage.ForeColor = System.Drawing.Color.Green;
            _lblMessage.Text = "Rules Update Successfully.";

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message.ToString());
            _lblMessage.ForeColor = System.Drawing.Color.Red;
            _lblMessage.Text = "Rules Update fail.";
        }
        finally
        {
            _rules = null;
        }
    }
    public void AssignRules()
    {
        RulesData _rules = new RulesData();

        ProcessSpeedingNotQueries insert = new ProcessSpeedingNotQueries(AlarmasABC.BLL.InvokeOperations.operations.INSERT);

        try
        {
            _rules.RulesName = "";
            _rules.RulesValue = _txtSpeedValue.Text.ToString();
            _rules.Email = _txtNotificationEmails.Text.ToString();

            bool isSMS = _ckOnSMS.Checked;
            if (_txtPhoneNumber.Text == "")
            {
        isSMS = false;
            }
            _rules.SpeedingPhoneNum = _txtPhoneNumber.Text.Trim();
            _rules.IsSMS = isSMS;
            _rules.Message = _txtMessage.Text.ToString();
            string _comID = Session["trkCompany"].ToString();
            _rules.ComID = int.Parse(_comID);
            _rules.UnitID =int.Parse( Request.QueryString["unitID"].ToString());

            insert.RulesInfo = _rules;
            insert.invoke();

            _lblMessage.ForeColor = System.Drawing.Color.Green;
           _lblMessage.Text = "Rules Assign Successfully.";

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message.ToString());
           _lblMessage.ForeColor = System.Drawing.Color.Red;
           _lblMessage.Text = "Rules Assign fail.";
        }
        finally
        {
            _rules = null;
        }
    }
    public bool CancelRules()
    {
        ProcessRulesData _unitRules = new ProcessRulesData();
        RulesData _units = new RulesData();
        bool cStatus = false;

        //foreach (DataListItem item in CancelUnitDataList.Items)
        //{
            //CheckBox chkUnit = (CheckBox)item.FindControl("UnitCheckBox");
            if (_ddlUnits.SelectedIndex > 0)
            {

                //Label UnitID = (Label)item.FindControl("lblUnitID");
                _units.UnitID = int.Parse(_ddlUnits.SelectedValue.ToString());
                _unitRules.RulesData = _units;
                _unitRules.CancelRules();
                cStatus = true;
            }

        //if (cStatus)
        //{
        //    ConfirmationFlageLabel.ForeColor = System.Drawing.Color.Green;
        //    ConfirmationFlageLabel.Text = "Rules update Succesfull.";
        //    cStatus = true;
        //    //FormRest();

        //}
        //else
        //{
        //    ConfirmationFlageLabel.ForeColor = System.Drawing.Color.Red;
        //    ConfirmationFlageLabel.Text = "Failed to Update Rules!";
        //    cStatus = false;
        //    //FormRest();
        //}

        return cStatus;
    }
    private bool AddRules()
    {
        try
        {
            RulesData _rulesObj = new RulesData();
            ProcessRulesData _rulesAdd=new ProcessRulesData(AlarmasABC.BLL.InvokeOperations.operations.INSERT);

            _rulesObj.RulesID=1;
            _rulesObj.RulesOperator="<";
            _rulesObj.RulesOperatorName="Less Than";
            _rulesObj.RulesValue=_txtValue.Text.Trim();
            _rulesObj.ComID=int.Parse(Session["trkCompany"].ToString());

            _rulesAdd.RulesObj=_rulesObj;
            _rulesAdd.invoke();
            return true;

        }
        catch (Exception ex)
        {
            ex.Message.ToString();
            return false;
        }
    }
 public makeSpeedingParam(RulesData _rules)
 {
     this._rulesInfo = _rules;
         build();
 }
    private void ShowRulesDetails()
    {
        try
        {
            ProcessSpeedingQueries _rulesData = new ProcessSpeedingQueries();
            RulesData _rulesInfo = new RulesData();
            _rulesInfo.ComID = int.Parse(Session["trkCompany"].ToString());
            _rulesInfo.UnitID = int.Parse(Request.QueryString["unitID"].ToString());

            _rulesData.RulesInfo = _rulesInfo;

            _rulesData.invoke();
            DataSet _ds = new DataSet();
            _ds = _rulesData.Ds;

            if (_ds.Tables[0].Rows.Count > 0)
            {
                _txtSpeedValue.Text = _ds.Tables[0].Rows[0]["rulesValue"].ToString();
                _txtNotificationEmails.Text = _ds.Tables[0].Rows[0]["email"].ToString();
                _txtMessage.Text = _ds.Tables[0].Rows[0]["description"].ToString();
                _txtPhoneNumber.Text = _ds.Tables[0].Rows[0]["speedPhoneNum"].ToString();
                bool isActive = bool.Parse(_ds.Tables[0].Rows[0]["isActive"].ToString());
                ViewState["rulesID"] = _ds.Tables[0].Rows[0]["rulesID"].ToString();

                if (isActive)
                {
                    _chkOff.Checked = false;

                }
                else
                {
                    _chkOff.Checked = true;
                    _chkOn.Checked = false;

                }
                bool isSMS = false;
                string tmp = _ds.Tables[0].Rows[0]["isSMS"].ToString();
                if (tmp.Length > 0)
                {
                    isSMS = bool.Parse(tmp);
                }

                if (isSMS)
                {
                    _ckOnSMS.Checked = true;
                    _chkOffSMS.Checked = false;
                }
                else
                {
                    _ckOnSMS.Checked = false;
                    _chkOffSMS.Checked = true;
                }

                _btnOk.Text = "Update";

            }
            else
            {
                _btnOk.Text = "Assign Rules";
            }
        }
        catch (Exception ex)
        {

        }
    }
    private void LoadUnitRulesInfo()
    {
        try
        {
            ProcessRulesData _unitRules = new ProcessRulesData();
            RulesData _units = new RulesData();

            _units.UnitID = int.Parse(_ddlUnits.SelectedValue.ToString());

            _unitRules.RulesData = _units;

            _unitRules.UnitRuleInfo();
            DataSet _ds = _unitRules.Ds;
            EmailTextBox.Text = _ds.Tables[0].Rows[0][0].ToString();
            SubjectTextBox.Text = _ds.Tables[0].Rows[0][1].ToString();
            DescriptionTextBox.Text = _ds.Tables[0].Rows[0][2].ToString();
            isActiveCheckBox.Checked = bool.Parse(_ds.Tables[0].Rows[0][3].ToString());
            _ddlGeofence.SelectedValue = _ds.Tables[0].Rows[0][4].ToString();
        }
        catch (Exception ex)
        {
        }
    }
    private void EditRules()
    {
        //string updateSQl = "";
        bool flag = false;
        //bool Status = cancelStatus;
        bool isActive = isActiveCheckBox.Checked;

        //foreach (DataListItem item in CancelUnitDataList.Items)
        //{
        //    CheckBox chkUnit = (CheckBox)item.FindControl("UnitCheckBox");

            if (_ddlUnits.SelectedIndex > 0)
            {
                //Label UnitID = (Label)item.FindControl("lblUnitID");
                RulesData rules = new RulesData();
                ProcessRulesData rulesObj = new ProcessRulesData();
                rules.UnitID = int.Parse(_ddlUnits.SelectedValue.ToString());
                rules.RulesID = int.Parse(_ddlRules.SelectedValue.ToString());
                rules.GeoID = int.Parse(_ddlGeofence.SelectedValue.ToString());
                rules.Email = EmailTextBox.Text.ToString();
                rules.Message = SubjectTextBox.Text.ToString();
                rules.IsActive = isActive;
                rulesObj.RulesData = rules;
                rulesObj.UpdateRules();
                flag = true;
                //updateSQl += " Update tblUnitWiseRules set RulesID=" + _ddlRules.SelectedValue.ToString() + ",GeofenceID=" + _ddlGeofence.SelectedValue.ToString() + ",Email='" + EmailTextBox.Text.Trim() + "',Subject='" + SubjectTextBox.Text.Trim() + "',Description='" + DescriptionTextBox.Text.Trim() + "',isActive=" + isActive + " where UnitID=" + UnitID.Text.Trim() + ";";
            }

        if (flag )
        {
            ConfirmationFlageLabel.ForeColor = System.Drawing.Color.Green;
            ConfirmationFlageLabel.Text = "Rules update Succesfull.";
            FormReset();

        }
        else
        {
            ConfirmationFlageLabel.ForeColor = System.Drawing.Color.Red;
            ConfirmationFlageLabel.Text = "Failed to Update Rules!";
            //FormRest();
        }
    }
    private void createStr()
    {
        foreach (DataGridItem item in _grdMain.Items)
            {
            DataList lstUnit = (DataList)item.FindControl("lstUnits");

            foreach (DataListItem lstItem in lstUnit.Items)
            {
                CheckBox chkUnit = (CheckBox)lstItem.FindControl("chkUnit");
                if (chkUnit.Checked)
                {
                    Label UnitID = (Label)lstItem.FindControl("lblUnitID");
                     RulesData rules = new RulesData();
                     ProcessRulesData rulesObj = new ProcessRulesData();
                        rules.UnitID = int.Parse(UnitID.Text.Trim());
                        rules.RulesID = int.Parse(_ddlRules.SelectedValue.ToString()) ;
                        rules.GeoID = int.Parse(_ddlGeofence.SelectedValue.ToString());
                        rules.Email = Email.Text.ToString();
                        rules.Message = Subject.Text.ToString();
                        rules.IsActive = true;
                        rulesObj.RulesData = rules;
                        rulesObj.AssignRules();
                        ConfirmationFlagLabel.ForeColor = System.Drawing.Color.Green;
                        ConfirmationFlagLabel.Text = "Rules Applied Succesfully.";
                        //FormRest();

                }
            }
         }
        //Database db = new Database();
        //bool flag = db.executeNonQry(insertSQl);
        //db.Close();
        //if (flag)
        //{
        //    ConfirmationFlagLabel.ForeColor = System.Drawing.Color.Green;
        //    ConfirmationFlagLabel.Text = "Rules Applied Succesfully.";
        //    FormRest();
        //    BindParentGrid(Session["trkCompany"].ToString());

        //}
        //else
        //{
        //    ConfirmationFlagLabel.ForeColor = System.Drawing.Color.Red;
        //    ConfirmationFlagLabel.Text = "Failed To Apply Rules!";
        //    FormRest();
        //}
    }
    private void BindParentGrid(string comID)
    {
        try
        {
            ProcessRulesData _unitRules = new ProcessRulesData();
            RulesData _units = new RulesData();
            if (Session["roleID"] != null)
            {
                if (Session["roleID"].ToString() != "3")
                {
                    _units.ComID = int.Parse(comID);
                    _units.UID = int.Parse(Session["roleID"].ToString());

                    _unitRules.RulesData = _units;
                    _unitRules.GetUnits();
                    _ds = _unitRules.Ds;

                }
                else
                {
                    //RulesData _units = new RulesData();
                    _units.ComID = int.Parse(comID);
                    _unitRules.RulesData = _units;
                    _unitRules.GetUnits3();
                    _ds = _unitRules.Ds;

                }
            }

            _ds.Tables[0].TableName = "Group";
            _ds.Tables[1].TableName = "Units";
            int count = _ds.Tables[0].Rows.Count;
            _grdMain.DataSource = _ds.Tables["Group"];
            _grdMain.DataBind();
            if (count > 1)
            {
                chkAllUnit.Visible = true;
            }
            else
            {
                chkAllUnit.Visible = false;
                ConfirmationFlagLabel.ForeColor = System.Drawing.Color.Red;
                ConfirmationFlagLabel.Text = "No Unit Record Found For This company";
            }
        }
        catch (Exception ex)
        {
        }
    }
Exemple #12
0
 public TreeColor3(RulesData _rules)
 {
     this.Rules = _rules;
     Command = @"SELECT frulesFor,r.rulesOperator,r.rulesValue FROM tblRules r INNER JOIN" +
               @" tblRulesFor f ON f.rulesForID=r.rulesForID WHERE rulesID = :rulesID;";
 }
 public SpeedingInsertParams(RulesData _rules)
 {
     this._rulesInfo = _rules;
     build();
 }
 public SpeedingUpdateParams(RulesData _rules)
 {
     this._rulesInfo = _rules;
     build();
 }
 public makeRulesDeleteParam(RulesData rules)
 {
     this._rulesData = rules;
        build();
 }