Esempio n. 1
0
        protected void Delete_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton delete = (ImageButton)sender;

            AlertsClass.GetSubmitLeaveID = Convert.ToInt32(delete.CommandArgument);
            AlertsClass.Delete_Alerts();
        }
Esempio n. 2
0
        protected void btnAddClient_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtClient.Text != "" && txtAddress.Text != "" && txtOperatorId.Text != "" && txtContact.Text != "" && txtCode.Text != "" && txtEmail.Text != "")
                {
                    ClientModel model = new ClientModel();
                    model.Name       = txtClient.Text;
                    model.Address    = txtAddress.Text;
                    model.OperatorID = Convert.ToInt32(txtOperatorId.Text);
                    model.Contact    = txtContact.Text;
                    model.Code       = txtCode.Text;
                    model.Email      = txtEmail.Text;
                    model.ExpireDate = Convert.ToDateTime(txtExpireDate.Text);

                    if (btnAddClient.Text == "Save")
                    {
                        bool exist = obj.codeExist(model.Code, model.Name);
                        if (exist == false)
                        {
                            model.ClientID = 0;
                            bool status = obj.postClient(model);
                            if (status == true)
                            {
                                alert = AlertsClass.SuccessUpdate;
                            }
                            else
                            {
                                alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                        else
                        {
                            alert = AlertsClass.ErrorExist("Code");
                        }
                    }
                    if (btnAddClient.Text == "Update")
                    {
                        model.ClientID = Convert.ToInt32(Session["ClientId"]);
                        bool status = obj.postClient(model);
                        if (status == true)
                        {
                            alert = AlertsClass.SuccessUpdate;
                        }
                        else
                        {
                            alert = AlertsClass.ErrorWentWrong;
                        }
                    }
                }
                else
                {
                    alert = AlertsClass.ErrorRequired;
                }
                clearControls();
                BindingClass.CallScriptManager(this.Page, this.GetType(), "ALerts('" + alert + "');applyDatatable('.gvdclientclass'); staticMethod('Disable')");
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }
Esempio n. 3
0
        protected void btnGroup_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlClient.SelectedValue != "0" && txtGroupName.Text != "" && txtComments.Text != "")
                {
                    GetGroupModel model = new GetGroupModel();
                    model.ClientID = Convert.ToInt32(ddlClient.SelectedValue);
                    model.Name     = txtGroupName.Text;
                    model.Comment  = txtComments.Text;

                    if (btnGroup.Text == "Save")
                    {
                        model.GroupID = 0;
                        bool exist = obj.groupExist(model.Name);
                        if (exist == false)
                        {
                            bool status = obj.postGroup(model);
                            if (status == true)
                            {
                                alert = AlertsClass.SuccessAdd;
                            }
                            else
                            {
                                alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                        else
                        {
                            alert = AlertsClass.ErrorExist("Branch");
                        }
                    }
                    if (btnGroup.Text == "Update")
                    {
                        model.GroupID = Convert.ToInt32(Session["GroupId"]);
                        bool status = obj.postGroup(model);
                        if (status == true)
                        {
                            alert = AlertsClass.SuccessUpdate;
                        }
                        else
                        {
                            alert = AlertsClass.ErrorWentWrong;
                        }
                    }
                }
                else
                {
                    alert = AlertsClass.ErrorRequired;
                }
                clearControls();
                gridBind();
                allowStaticMethods("ALerts('" + alert + "'); ApplyDatatable('.gvdGroupClass'); staticMethod('Disable');");
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }
Esempio n. 4
0
        //Button clicks
        protected void btnAddUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlClient.SelectedValue != "0" && txtUser.Text != "" && txtPassword.Text != "" && txtConfirmPassword.Text != "")
                {
                    PostLoginModel model = new PostLoginModel();
                    model.ClientID    = Convert.ToInt32(ddlClient.SelectedValue);
                    model.RoleID      = Convert.ToInt32(ddlUserType.SelectedValue);
                    model.User        = txtUser.Text;
                    model.Password    = txtPassword.Text;
                    model.Comment     = txtComments.Text;
                    model.DisplayName = txtdisplayName.Text;

                    if (txtPassword.Text == txtConfirmPassword.Text)
                    {
                        if (btnAddUser.Text == "Save")
                        {
                            model.LoginID = 0;
                            bool exist = obj.usernameExist(model.User);
                            if (exist == false)
                            {
                                bool status = obj.postLogin(model);
                                if (status == true)
                                {
                                    alert = AlertsClass.SuccessAdd;
                                }
                                else
                                {
                                    alert = AlertsClass.ErrorPasswordMatch;
                                }
                            }
                            else
                            {
                                alert = AlertsClass.ErrorExist("Username");
                            }
                        }
                        if (btnAddUser.Text == "Update")
                        {
                            model.LoginID = Convert.ToInt32(Session["LoginId"]);
                            bool status = obj.postLogin(model);
                            if (status == true)
                            {
                                alert = AlertsClass.SuccessUpdate;
                            }
                        }
                    }
                    else
                    {
                        alert = AlertsClass.ErrorPasswordMatch;
                    }
                    clearControls();
                    gridBind(Convert.ToInt32(ddlClient.SelectedValue));
                    allowStaticMethods(" ALerts('" + alert + "'); applyDatatable('.gvduserclass'); staticMethod('Disable');");
                }
                else
                {
                    alert = AlertsClass.ErrorRequired;
                }
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }
Esempio n. 5
0
        protected void btnAddObject_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlClient.SelectedValue != "0" && ddlDeviceType.SelectedValue != "0" && txtObjectName.Text != "" && txtAddress.Text != "" && txtLat.Text != "" && txtLong.Text != "" && txtIMEI.Text != "" && txtSimNumber.Text != "" && txtFirmWareVersion.Text != "" && txtHardwareVersion.Text != "")
                {
                    bool           RStatus = chkRelaySt.Checked ? true : false;
                    ObjectModelDLL model   = new ObjectModelDLL();
                    model.Name            = txtObjectName.Text;
                    model.Address         = txtAddress.Text;
                    model.LAT             = Convert.ToDouble(txtLat.Text);
                    model.LONG            = Convert.ToDouble(txtLong.Text);
                    model.IMEI            = Convert.ToInt64(txtIMEI.Text);
                    model.SimNumber       = Convert.ToInt64(txtSimNumber.Text);
                    model.ClientID        = Convert.ToInt32(ddlClient.SelectedValue);
                    model.HardwareVersion = txtHardwareVersion.Text;
                    model.FirmWareVersion = txtFirmWareVersion.Text;
                    model.ObjectType      = ddlDeviceType.SelectedItem.Text;
                    model.Contact         = txtContact.Text + ",";
                    model.RelayStatus     = RStatus;

                    if (btnAddObject.Text == "Save")
                    {
                        model.ObjectID = 0;
                        bool exist = obj.objectExist(model.IMEI.ToString());
                        if (exist == false)
                        {
                            bool status = obj.postObject(model);
                            if (status == true)
                            {
                                alert = AlertsClass.SuccessAdd;
                            }
                            else
                            {
                                alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                        else
                        {
                            { alert = AlertsClass.ErrorExist("IMEI"); }
                        }
                    }
                    if (btnAddObject.Text == "Update")
                    {
                        model.ObjectID = Convert.ToInt32(Session["ObjectId"]);
                        bool status = obj.postObject(model);
                        if (status == true)
                        {
                            alert = AlertsClass.SuccessAdd;
                        }
                        else
                        {
                            alert = AlertsClass.ErrorWentWrong;
                        }
                    }
                }
                else
                {
                    alert = AlertsClass.ErrorRequired;
                }
                clearControls();
                GridBind();
                allowStaticMethods("ALerts('" + alert + "');applyDatatable('.gvdObjectClass'); staticMethod('Disable'); phonenumber();");
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }
Esempio n. 6
0
        protected void btnAddCategory_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text != "" && txtMin.Text != "" && txtMin.Text != "" && imgCategory.FileName != null)
                {
                    CategoryModel model = new CategoryModel();
                    model.CategoryID      = 0;
                    model.Name            = txtName.Text;
                    model.ImgPath         = "Images/categoryIcons/" + imgCategory.FileName;
                    model.Min             = txtMin.Text;
                    model.Max             = txtMax.Text;
                    model.EnableORDisable = chkEnable.Checked ? true : false;

                    bool exist = obj.categoryExist(model.Name);
                    if (exist == false)
                    {
                        if (btnAddCategory.Text == "Save")
                        {
                            bool status = obj.postCategory(model);
                            if (status == true)
                            {
                                Alert = AlertsClass.SuccessAdd;
                                string extension = Path.GetExtension(imgCategory.FileName);
                                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg")
                                {
                                    Stream strm = imgCategory.PostedFile.InputStream;
                                    using (var image = System.Drawing.Image.FromStream(strm))
                                    {
                                        int newWidth   = 24;
                                        int newHeight  = 24;
                                        var thumbImg   = new Bitmap(newWidth, newHeight);
                                        var thumbGraph = Graphics.FromImage(thumbImg);
                                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                                        thumbGraph.DrawImage(image, imgRectangle);
                                        string targetPath = Server.MapPath(@"~\Images\categoryIcons\") + imgCategory.FileName;
                                        thumbImg.Save(targetPath, image.RawFormat);
                                    }
                                }
                            }
                            else
                            {
                                Alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                        if (btnAddCategory.Text == "Update")
                        {
                            model.CategoryID = Convert.ToInt32(Session["CategoryId"]);
                            bool status = obj.postCategory(model);
                            if (status == true)
                            {
                                Alert = AlertsClass.SuccessUpdate;
                                string extension = Path.GetExtension(imgCategory.FileName);
                                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg")
                                {
                                    Stream strm = imgCategory.PostedFile.InputStream;
                                    using (var image = System.Drawing.Image.FromStream(strm))
                                    {
                                        int newWidth   = 24;
                                        int newHeight  = 24;
                                        var thumbImg   = new Bitmap(newWidth, newHeight);
                                        var thumbGraph = Graphics.FromImage(thumbImg);
                                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                                        thumbGraph.DrawImage(image, imgRectangle);
                                        string targetPath = Server.MapPath(@"~\Images\categoryIcons\") + imgCategory.FileName;
                                        thumbImg.Save(targetPath, image.RawFormat);
                                    }
                                }
                            }
                            else
                            {
                                Alert = AlertsClass.ErrorWentWrong;
                            }
                        }
                    }
                    else
                    {
                        Alert = AlertsClass.ErrorExist("Category ");
                    }
                    BindgridView();
                    clearControls();
                }
                else
                {
                    Alert = AlertsClass.ErrorRequired;
                }
                allowStaticMethods("staticMethod('Disable');   applyDatatable('.gvdcategoryclass');ALerts('" + Alert + "');");
            }
            catch (Exception)
            { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
        }
Esempio n. 7
0
 protected void btnAddObjectSensor_Click(object sender, EventArgs e)
 {
     try
     {
         if (ddlClient.SelectedValue != "0" && ddlcategory.SelectedValue != "0" && ddlObject.SelectedValue != "0" && ddlSensor.SelectedValue != "0" && txtName.Text != "" && txtMax.Text != "" && txtMin.Text != "" && txta1.Text != "" && txta0.Text != "")
         {
             ObjectSensorModelDLL model = new ObjectSensorModelDLL();
             model.ObjectID   = Convert.ToInt32(ddlObject.SelectedValue);
             model.SensorID   = Convert.ToInt32(ddlSensor.SelectedValue);
             model.Name       = txtName.Text;
             model.SMSAlert   = cbSmsAlert.Checked;
             model.EmailAlert = false;
             model.Contact    = txtContact.Text + ",";
             model.Max        = Convert.ToInt32(txtMax.Text);
             model.Min        = Convert.ToInt32(txtMin.Text);
             model.A1         = Convert.ToDouble(txta1.Text);
             model.A0         = Convert.ToDouble(txta0.Text);
             model.CategoryID = Convert.ToInt32(ddlcategory.SelectedValue);
             if (btnAddObjectSensor.Text == "Save")
             {
                 model.ObjectSensorId = 0;
                 bool exist = obj.objectSensorExist(model.ObjectID, model.SensorID);
                 if (exist == false)
                 {
                     bool status = obj.postObjectSensor(model);
                     if (status == true)
                     {
                         alert = AlertsClass.SuccessAdd;
                     }
                     else
                     {
                         alert = AlertsClass.ErrorWentWrong;
                     }
                 }
                 else
                 {
                     alert = AlertsClass.ErrorExist("Device Sensor ");
                 }
             }
             if (btnAddObjectSensor.Text == "Update")
             {
                 model.ObjectSensorId = Convert.ToInt64(Session["objectsensorId"]);
                 bool status = obj.postObjectSensor(model);
                 if (status == true)
                 {
                     alert = AlertsClass.SuccessAdd;
                 }
                 else
                 {
                     alert = AlertsClass.ErrorWentWrong;
                 }
             }
         }
         else
         {
             alert = AlertsClass.ErrorRequired;
         }
         clearControls();
         ddlNAsensorBind();
         gridBind();
         allowStaticMethods("ALerts('" + alert + "');applyDatatable('.gvdObjectSensorClass');staticMethod('Disable');");
     }
     catch (Exception)
     { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); }
 }