Ejemplo n.º 1
0
    protected void btn_VehicleGroup_Add_Click(object sender, EventArgs e)
    {
        try
        {
            if (!ValidateVehicleGroup())
            {
                return;
            }
            if (cblSelectVehicle.Items.Count > 0)
            {
                if (btn_VehicleGroup_Add.Text == "Add")
                {
                    foreach (ListItem obj in cblSelectVehicle.Items)
                    {
                        if (obj.Selected)
                        {
                            cmd = new MySqlCommand("insert into VehicleGroup (GroupName,VehicleID,UserName) values (@GroupName,@VehicleID,@UserName) ");
                            cmd.Parameters.Add("@GroupName", txtGroupName.Text.Trim());
                            cmd.Parameters.Add("@VehicleID", obj.Text.Trim());
                            cmd.Parameters.Add("@UserName", UserName);
                            vdm.insert(cmd);
                        }
                    }

                    UpdateVehicleGroupData();
                    ResetVehicleGroup();
                    lblGroupStatus.Text = "Record Added Successfully";
                }


                else
                {
                    cmd = new MySqlCommand("Delete from VehicleGroup where GroupName=@GroupName and UserName=@UN");
                    cmd.Parameters.Add("@GroupName", vehicleGroup);
                    cmd.Parameters.Add("@UN", UserName);
                    vdm.Delete(cmd);

                    foreach (ListItem obj in cblSelectVehicle.Items)
                    {
                        if (obj.Selected)
                        {
                            cmd = new MySqlCommand("insert into VehicleGroup (GroupName,VehicleID,UserName) values (@GroupName,@VehicleID,@UserName) ");
                            cmd.Parameters.Add("@GroupName", txtGroupName.Text);
                            cmd.Parameters.Add("@VehicleID", obj.Text);
                            cmd.Parameters.Add("@UserName", UserName);
                        }
                    }
                    vdm.insert(cmd);
                    btn_VehicleGroup_Add.Text = "Add";
                    MessageBox.Show("Successfully Groups Modified", this);
                    UpdateVehicleGroupData();
                    ResetVehicleGroup();
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 2
0
    protected void Onclickdelete(object sender, CommandEventArgs e)
    {
        GridViewRow row = gv_ML_Data.Rows[int.Parse(e.CommandArgument.ToString())];

        if (row != null)
        {
            cmd = new MySqlCommand("delete from MovingLoc where VehicleNo=@VN and UserName=@UN");
            cmd.Parameters.Add("@UN", UserName);
            cmd.Parameters.Add("@VN", row.Cells[2].Text);
            vdm.Delete(cmd);
            updateML_gridview();
        }
    }
Ejemplo n.º 3
0
 protected void btnDelete_OnClick(object sender, EventArgs e)
 {
     lblmsg.Text = "";
     cmd         = new MySqlCommand("delete from Routetable where RouteName=@RouteName and UserID=@UserID");
     cmd.Parameters.Add("@RouteName", txtRouteName.Text);
     cmd.Parameters.Add("@UserID", UserName);
     vdm.Delete(cmd);
     cmd = new MySqlCommand("delete from Routesubtable where SNo=@SNo");
     cmd.Parameters.Add("@SNo", RefSno);
     vdm.Delete(cmd);
     txtRouteName.Text = "";
     lblmsg.Text       = "Route Deleted Successfully";
     refresh();
     UpdateRoute();
     ScriptManager.RegisterStartupScript(Page, GetType(), "JsStatus", "ClearPolylines();", true);
 }
Ejemplo n.º 4
0
 protected void btnGeofenceDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (grdGeofence.SelectedIndex > -1)
         {
             cmd = new MySqlCommand("delete from GeofenseTable where  UserName=@UserName and Name=@Nme");
             cmd.Parameters.Add("@Nme", txt_Geofencename.Text);
             cmd.Parameters.Add("@UserName", UserName);
             vdm.Delete(cmd);
             MessageBox.Show("Deleted successfully", this);
             lblstatus.Text = "Deleted successfully";
             getGeofenseData();
             resetall();
         }
         else
         {
             MessageBox.Show("No row selected to delete the Location", this);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this);
     }
 }
Ejemplo n.º 5
0
 protected void btnDelete_OnClick(object sender, EventArgs e)
 {
     cmd = new MySqlCommand("delete from emailmgmt  where sno=@sno and UserID=@UserID");
     cmd.Parameters.Add("@UserID", UserName);
     cmd.Parameters.Add("@sno", Sno);
     vdm.Delete(cmd);
     Refresh();
     UpdateEmails();
     lblmsg.Text = "Deleted Successfully";
 }
Ejemplo n.º 6
0
 protected void btn_DeiselVal_Del_Click(object sender, EventArgs e)
 {
     try
     {
         if (grdVehicleExpences.SelectedIndex > -1)
         {
             cmd = new MySqlCommand("delete from inventory where  UserName=@UserName and Sno=@Sno");
             cmd.Parameters.Add("@UserName", UserName);
             cmd.Parameters.Add("@Sno", Sno);
             vdm.Delete(cmd);
             Refresh();
             UpdateDeisel();
             btn_DeiselVal_Add.Text = "Add";
             lblStatus.Text         = "Record Deleted Successfully";
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 7
0
 protected void btnDeleteAssignGeofence_Click(object sender, EventArgs e)
 {
     if (GrdAssignGeofence.SelectedIndex > -1)
     {
         try
         {
             cmd = new MySqlCommand("delete AssignGeofence where SlNo=@SlNo and UserName=@UserName");
             cmd.Parameters.Add("@SlNo", SlNo);
             cmd.Parameters.Add("@UserName", UserName);
             vdm.Delete(cmd);
             UpdateAssignGeofence();
             RefreshAssignGeofence();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, this);
         }
     }
     else
     {
         MessageBox.Show("No row selected to delete Driver Data", this);
     }
 }
Ejemplo n.º 8
0
    protected void btnalertSave_Click(object sender, EventArgs e)
    {
        long refno = 0;

        try
        {
            if (btnalertSave.Text == "Save")
            {
                cmd = new MySqlCommand("insert into alerts  (AlertType,EmailID,username) values (@alerttype,@emailid,@username)");
                cmd.Parameters.Add("@username", UserName);
                cmd.Parameters.Add("@alerttype", "Email");
                cmd.Parameters.Add("@emailid", ddlSelectEmail.SelectedItem.Value);
                //cmd.Parameters.Add("@usertype", ddlUserType.SelectedValue);
                refno = vdm.insertgetrefno(cmd);
                foreach (ListItem obj in ckbVehicles.Items)
                {
                    if (obj.Selected)
                    {
                        cmd = new MySqlCommand("insert into alert_subinfo (alert_sno,routecode) values(@Refno,@routeID)");
                        cmd.Parameters.Add("@Refno", refno);
                        cmd.Parameters.Add("@routeID", obj.Text);
                        vdm.insert(cmd);
                    }
                }
                Refresh();
                //foreach (ListItem li in chblZones.Items)
                //{
                //    if (li.Selected)
                //    {
                //        plants += li.Text + ",";
                //    }
                //}
                UpdateLogins();
                lblmsg.Text = "Record added Successfully";
            }
            else
            {
                cmd = new MySqlCommand("Delete from alert_subinfo where alert_sno=@Refno");
                cmd.Parameters.Add("@Refno", Session["reffno"]);
                vdm.Delete(cmd);
                cmd = new MySqlCommand("Update alerts set  EmailID=@emailid where sno=@Refno ");
                cmd.Parameters.Add("@Refno", Session["reffno"]);
                cmd.Parameters.Add("@emailid", ddlSelectEmail.SelectedItem.Value);
                //cmd.Parameters.Add("@loginid", txtLoginID.Text);
                //cmd.Parameters.Add("@pwd", txtPassword.Text.Trim());
                //cmd.Parameters.Add("@usertype", ddlUserType.SelectedValue);
                vdm.Update(cmd);
                foreach (ListItem obj in ckbVehicles.Items)
                {
                    if (obj.Selected)
                    {
                        cmd = new MySqlCommand("insert into alert_subinfo (alert_sno,routecode) values(@Refno,@routeID)");
                        cmd.Parameters.Add("@Refno", Session["reffno"]);
                        cmd.Parameters.Add("@routeID", obj.Text);
                        vdm.insert(cmd);
                    }
                }
                Refresh();
                UpdateLogins();
                btnalertSave.Text = "Save";
                lblmsg.Text       = "Record Updated Successfully";
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("PRIMARY"))
            {
                //lbl_nofifier.Text = "Oops..! Username alredy existed";
            }
            else
            {
                //lbl_nofifier.Text = "Oops..! Error occurred please try again";
            }
        }
    }
Ejemplo n.º 9
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        long refno = 0;

        try
        {
            if (btnSave.Text == "Save")
            {
                cmd = new MySqlCommand("insert into loginstable  (main_user,loginid, pwd,usertype,emailid,phonenumber,main_user_id) values (@main_user,@loginid,@pwd,@usertype,@emailid,@phonenumber,@main_user_id)");
                cmd.Parameters.Add("@main_user", UserName);
                cmd.Parameters.Add("@loginid", txtLoginID.Text);
                cmd.Parameters.Add("@pwd", txtPassword.Text.Trim());
                cmd.Parameters.Add("@usertype", ddlUserType.SelectedValue);
                cmd.Parameters.Add("@emailid", txt_emailid.Text.Trim());
                cmd.Parameters.Add("@phonenumber", txt_mobno.Text.Trim());
                cmd.Parameters.Add("@main_user_id", mainusrsno);
                refno = vdm.insertgetrefno(cmd);
                foreach (ListItem obj in ckbVehicles.Items)
                {
                    if (obj.Selected)
                    {
                        cmd = new MySqlCommand("insert into loginsconfigtable (Refno,VehicleID) values(@Refno,@VehicleID)");
                        cmd.Parameters.Add("@Refno", refno);
                        cmd.Parameters.Add("@VehicleID", obj.Text);
                        vdm.insert(cmd);
                    }
                }
                Refresh();
                UpdateLogins();
                lbl_nofifier.Text = "Record added Successfully";
            }
            else
            {
                DataTable prev_data = (DataTable)Session["dtallVehicles"];



                //cmd = new MySqlCommand("Delete from loginsconfigtable where Refno=@Refno");
                //cmd.Parameters.Add("@Refno", Sno);
                //vdm.Delete(cmd);
                cmd = new MySqlCommand("Update  loginstable  set  main_user=@main_user,pwd=@pwd,usertype=@usertype,emailid=@emailid,phonenumber=@phonenumber,main_user_id=@main_user_id where loginid=@loginid ");
                cmd.Parameters.Add("@main_user", UserName);
                cmd.Parameters.Add("@loginid", txtLoginID.Text);
                cmd.Parameters.Add("@pwd", txtPassword.Text.Trim());
                cmd.Parameters.Add("@usertype", ddlUserType.SelectedValue);
                cmd.Parameters.Add("@emailid", txt_emailid.Text.Trim());
                cmd.Parameters.Add("@phonenumber", txt_mobno.Text.Trim());
                cmd.Parameters.Add("@main_user_id", mainusrsno);
                vdm.Update(cmd);

                foreach (ListItem obj in ckbVehicles.Items)
                {
                    if (prev_data.Select("VehicleID='" + obj.Text + "'").Length > 0)
                    {
                        if (!obj.Selected)
                        {
                            cmd = new MySqlCommand("Delete from loginsconfigtable where Refno=@Refno and VehicleID=@vid");
                            cmd.Parameters.Add("@Refno", Sno);
                            cmd.Parameters.Add("@vid", obj.Text);
                            vdm.Delete(cmd);
                        }
                    }
                    else
                    {
                        if (obj.Selected)
                        {
                            cmd = new MySqlCommand("insert into loginsconfigtable (Refno,VehicleID) values(@Refno,@VehicleID)");
                            cmd.Parameters.Add("@Refno", Sno);
                            cmd.Parameters.Add("@VehicleID", obj.Text);
                            vdm.insert(cmd);
                        }
                    }
                }

                //foreach (ListItem obj in ckbVehicles.Items)
                //{
                //    if (obj.Selected)
                //    {
                //        cmd = new MySqlCommand("insert into loginsconfigtable (Refno,VehicleID) values(@Refno,@VehicleID)");
                //        cmd.Parameters.Add("@Refno", Sno);
                //        cmd.Parameters.Add("@VehicleID", obj.Text);
                //        vdm.insert(cmd);
                //    }
                //}
                Refresh();
                UpdateLogins();
                btnSave.Text      = "Save";
                lbl_nofifier.Text = "Record Updated Successfully";
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("PRIMARY"))
            {
                lbl_nofifier.Text = "Oops..! Username alredy existed";
            }
            else
            {
                lbl_nofifier.Text = "Oops..! Error occurred please try again";
            }
        }
    }
Ejemplo n.º 10
0
 protected void btnRouteSave_OnClick(object sender, EventArgs e)
 {
     try
     {
         lblmsg.Text = "";
         vdm         = new VehicleDBMgr();
         vdm.InitializeDB();
         string RouteName = txtRouteName.Text;
         //string BrachNames = chblselected.Items;
         //BrachNames = BrachNames.Substring(0, BrachNames.Length - 1);
         //string Ranks = context.Request["Ranks"];
         //string[] strBrachNames = BrachNames.Split('-');
         //Ranks = Ranks.Substring(0, Ranks.Length - 1);
         //string[] strRanks = Ranks.Split('-');
         //string strSno = context.Request["Sno"];
         //string[] SpltSno = strSno.Split('-');
         //int rank = 0;
         //int.TryParse(Ranks.ToString(), out rank);
         //string Username = context.Session["field1"].ToString();
         //string btnSave = context.Request["btnRouteSave"];
         if (btnRouteSave.Text == "Save")
         {
             cmd = new MySqlCommand("Insert into Routetable(RouteName,UserID) values(@RouteName,@UserID)");
             cmd.Parameters.Add("@RouteName", RouteName);
             cmd.Parameters.Add("@UserID", UserName);
             vdm.insert(cmd);
             cmd = new MySqlCommand("Select SNo from Routetable where RouteName=@RouteName and UserID=@UserID ");
             cmd.Parameters.Add("@RouteName", RouteName);
             cmd.Parameters.Add("@UserID", UserName);
             DataTable dt    = vdm.SelectQuery(cmd).Tables[0];
             int       Sno   = (int)dt.Rows[0]["Sno"];
             DataTable dtSno = (DataTable)Session["Branchdata"];
             int       i     = 0;
             foreach (ListItem str in chblselected.Items)
             {
                 foreach (DataRow dr in dtSno.Rows)
                 {
                     if (str.Text == dr["BranchID"].ToString())
                     {
                         //cmd = new MySqlCommand("Select BranchID from branchdata where UserName=@UserName and Sno=@Sno");
                         //cmd.Parameters.Add("@UserName", UserName);
                         //cmd.Parameters.Add("@Sno", SpltSno[i]);
                         //DataTable dtBranch = vdm.SelectQuery(cmd).Tables[0];
                         //string BranchID = dtBranch.Rows[0]["BranchID"].ToString();
                         cmd = new MySqlCommand("Insert into Routesubtable(SNo,LocationID,BranchName,Rank) values(@SNo,@LocationID,@BranchName,@Rank)");
                         cmd.Parameters.Add("@SNo", Sno);
                         cmd.Parameters.Add("@LocationID", dr["Sno"].ToString());
                         cmd.Parameters.Add("@BranchName", dr["BranchID"].ToString());
                         cmd.Parameters.Add("@Rank", i);
                         vdm.insert(cmd);
                         i++;
                     }
                 }
             }
             lblmsg.Text = "Route Saved Successfully";
             UpdateRoute();
             refresh();
         }
         else if (btnRouteSave.Text == "Edit")
         {
             vdm = new VehicleDBMgr();
             vdm.InitializeDB();
             cmd = new MySqlCommand("Update Routetable set RouteName=@RouteName where UserID=@UserID and SNo=@SNo");
             cmd.Parameters.Add("@RouteName", txtRouteName.Text);
             cmd.Parameters.Add("@UserID", UserName);
             cmd.Parameters.Add("@SNo", RefSno);
             vdm.insert(cmd);
             cmd = new MySqlCommand("Select SNo from Routetable where RouteName=@RouteName and UserID=@UserID ");
             cmd.Parameters.Add("@RouteName", txtRouteName.Text);
             cmd.Parameters.Add("@UserID", UserName);
             DataTable dt  = vdm.SelectQuery(cmd).Tables[0];
             int       Sno = (int)dt.Rows[0]["Sno"];
             cmd = new MySqlCommand("Delete from  Routesubtable where SNo=@SNo");
             cmd.Parameters.Add("@Sno", Sno);
             vdm.Delete(cmd);
             DataTable dtSno = (DataTable)Session["Branchdata"];
             int       i     = 0;
             foreach (ListItem str in chblselected.Items)
             {
                 foreach (DataRow dr in dtSno.Rows)
                 {
                     if (str.Text == dr["BranchID"].ToString())
                     {
                         //cmd = new MySqlCommand("Select BranchID from branchdata where UserName=@UserName and Sno=@Sno");
                         //cmd.Parameters.Add("@UserName", UserName);
                         //cmd.Parameters.Add("@Sno", SpltSno[i]);
                         //DataTable dtBranch = vdm.SelectQuery(cmd).Tables[0];
                         //string BranchID = dtBranch.Rows[0]["BranchID"].ToString();
                         cmd = new MySqlCommand("Insert into Routesubtable(SNo,LocationID,BranchName,Rank) values(@SNo,@LocationID,@BranchName,@Rank)");
                         cmd.Parameters.Add("@SNo", Sno);
                         cmd.Parameters.Add("@LocationID", dr["Sno"].ToString());
                         cmd.Parameters.Add("@BranchName", dr["BranchID"].ToString());
                         cmd.Parameters.Add("@Rank", i);
                         vdm.insert(cmd);
                         i++;
                     }
                 }
             }
             lblmsg.Text = "Route Modified Successfully";
             UpdateRoute();
             refresh();
         }
         ScriptManager.RegisterStartupScript(Page, GetType(), "JsStatus", "ClearPolylines();", true);
     }
     catch
     {
     }
 }
Ejemplo n.º 11
0
    protected void BtnCategory_Save_Click(object sender, EventArgs e)
    {
        if (btn_save.Text == "Save")
        {
            // StringBuilder object
            StringBuilder str = new StringBuilder();
            Dictionary <string, string> selectedvalues = new Dictionary <string, string>();
            cmd = new MySqlCommand("insert into location_groups (location_group_name,user_sno) values (@location_group_name,@user_sno)");
            cmd.Parameters.Add("@location_group_name", txt_groupname.Text);
            cmd.Parameters.Add("@user_sno", User_sno);
            long sno = vdm.insertScalar(cmd);
            // Select the checkboxes from the GridView control
            for (int i = 0; i < grdMylocation.Rows.Count; i++)
            {
                GridViewRow row       = grdMylocation.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

                if (isChecked)
                {
                    cmd = new MySqlCommand("insert into location_groups_mapping (location_group_sno,branch_sno) values (@location_group_sno,@branch_sno) ");
                    cmd.Parameters.Add("@location_group_sno", sno);
                    cmd.Parameters.Add("@branch_sno", grdMylocation.Rows[i].Cells[9].Text);
                    vdm.insert(cmd);
                    // Column 2 is the name column]
                    //selectedvalues.Add(grdMylocation.Rows[i].Cells[11].Text, grdMylocation.Rows[i].Cells[10].Text);

                    // str.Append(grdMylocation.Rows[i].Cells[2].Text);
                }
            }
        }
        else
        {
            GridViewRow gvr      = list_groups.SelectedRow;
            string      group_id = gvr.Cells[1].Text;
            if (group_id != "")
            {
                cmd = new MySqlCommand("update location_groups set location_group_name=@location_group_name,user_sno=@user_sno where sno=@sno");
                cmd.Parameters.Add("@location_group_name", txt_groupname.Text);
                cmd.Parameters.Add("@user_sno", User_sno);
                cmd.Parameters.Add("@sno", group_id);
                vdm.Update(cmd);

                cmd = new MySqlCommand("delete from location_groups_mapping where location_group_sno=@lgs");
                cmd.Parameters.Add("@lgs", group_id);
                vdm.Delete(cmd);
                for (int i = 0; i < grdMylocation.Rows.Count; i++)
                {
                    GridViewRow row       = grdMylocation.Rows[i];
                    bool        isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

                    if (isChecked)
                    {
                        cmd = new MySqlCommand("insert into location_groups_mapping (location_group_sno,branch_sno) values (@location_group_sno,@branch_sno) ");
                        cmd.Parameters.Add("@location_group_sno", group_id);
                        cmd.Parameters.Add("@branch_sno", grdMylocation.Rows[i].Cells[9].Text);
                        vdm.insert(cmd);
                        // Column 2 is the name column]
                        //selectedvalues.Add(grdMylocation.Rows[i].Cells[11].Text, grdMylocation.Rows[i].Cells[10].Text);

                        // str.Append(grdMylocation.Rows[i].Cells[2].Text);
                    }
                }
            }
        }
        FillCategoryName();

        BtnMyLocatoinRefresh_Click(null, null);
        // prints out the result
        // Response.Write(str.ToString());
    }