Esempio n. 1
0
        public string deleteString(string creator, string parameterId)
        {
            string          response = "";
            parameterDelete para     = new parameterDelete();

            try
            {
                para.creator     = new Guid(creator);
                para.parameterId = new Guid(parameterId);
                response         = delete(para);
            }
            catch (Exception ex)
            {
                response = ex.ToString();
            }

            return(response);
        }
Esempio n. 2
0
        public string delete(parameterDelete use)
        {
            string response = "Success";

            try
            {
                SqlConnection con = new SqlConnection(data);
                SqlCommand    cmd = new SqlCommand("DELETE FROM courseParameter WHERE parameterId = @parameterId", con);
                cmd.Parameters.AddWithValue("@parameterId", use.parameterId);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }catch (SqlException ex)
            {
                response = ex.ToString();
            }
            catch (Exception ex)
            {
                response = ex.ToString();
            }
            return(response);
        }
Esempio n. 3
0
        public string update(List <parameterClass> use)
        {
            string response = "";

            if (use.Count() <= 0)
            {
                return("UpdateNull");
            }

            SqlConnection con = new SqlConnection(data);
            SqlCommand    cmd = new SqlCommand("UPDATE courseParameter SET parameterOrder = @order, value = @value WHERE childId = @childId AND parameterId = @parameterId", con);

            con.Open();
            for (int i = 0; i < use.Count(); i++)
            {
                if (use[i].parameterId == null)
                {
                    //  Do Stuff
                    parametercreate para = new parametercreate();
                    para.childId       = use[i].childId;
                    para.creator       = use[i].creator;
                    para.type          = use[i].type;
                    use[i].parameterId = new Guid(create(para));
                }
                if (use[i].value == null || use[i].value.Length <= 0)
                {
                    continue;
                }

                //  Check if the status of the parameter is delete
                //  if the status is del or delete script will call delete function
                //  else it will just update
                if (use[i].status.Contains("del") || use[i].status.Contains("Del"))
                {
                    parameterDelete del = new parameterDelete();
                    del.creator     = use[i].creator;
                    del.parameterId = use[i].parameterId;
                    response       += delete(del) + " /n ";
                }
                else
                {
                    try
                    {
                        cmd.Parameters.AddWithValue("@value", use[i].value);
                        cmd.Parameters.AddWithValue("@order", Convert.ToInt32(use[i].order));
                        cmd.Parameters.AddWithValue("@childId", use[i].childId);
                        cmd.Parameters.AddWithValue("@parameterId", use[i].parameterId);
                        cmd.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        response += ex.ToString() + " /n ";
                    }
                    catch (Exception ex)
                    {
                        response += ex.ToString() + " /n ";
                    }
                }
            }
            con.Close();
            return(response);
        }