Beispiel #1
0
    protected void btnAssign_Click(object sender, EventArgs e)
    {
        int UserID   = 0;
        int VesselID = 0;
        int Res      = 0;

        if (lstUserList.SelectedIndex >= 0)
        {
            UserID = UDFLib.ConvertToInteger(lstUserList.SelectedValue);
        }

        //if(lstVessel.SelectedIndex >= 0)
        //    VesselID  = UDFLib.ConvertToInteger(lstVessel.SelectedValue);

        if (UserID > 0)
        {
            int[] Sel = lstVessel.GetSelectedIndices();
            if (Sel.Length > 0)
            {
                foreach (int i in Sel)
                {
                    VesselID = UDFLib.ConvertToInteger(lstVessel.Items[i].Value);
                    Res     += objUser.INSERT_User_Vessel_Assignment(UserID, VesselID, GetSessionUserID());
                }


                if (Res > 0)
                {
                    GridView1.DataBind();

                    string js = "alert('" + Res + " Vessel(s) assigned to the user');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", js, true);
                }
                else
                {
                    string js = "alert('Vessel is already assigned to the user!!');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", js, true);
                }
            }
            else //if no vessel is selected or assigned
            {
                string js = "alert('Select atleast one vessel');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", js, true);
            }
        }
    }