Esempio n. 1
0
    protected void Addartifact_Click(object sender, EventArgs e)
    {
        bool        inset       = false;
        Addartifact addArtifact = new Addartifact();

        addArtifact.artNum    = txtArtNum.Text.ToString();
        addArtifact.artName   = txtArtName.Text.ToString();
        addArtifact.toolid    = Convert.ToInt32(lbltoolid.Text);
        addArtifact.createdby = Convert.ToInt32(lbluserid.Text);
        addArtifact.desc      = txtArtdesc.Text.ToString();
        addArtifact.esthour   = Convert.ToInt32(txtEsthour.Text);
        user = DstumDAL.getUserdetails(Context.User.Identity.Name);

        try
        {
            inset = DstumDAL.insertArtifact(addArtifact, user.userid);
        }
        catch (Exception ex)
        {
        }
        if (inset == true)
        {
            Response.Write(@"<script language='javascript'>window.alert('Artifact Added successfully \n .');window.location='Default.aspx';</script>");
            //     Response.Write(@"<script language='javascript'>alert('Artifact Added successfully \n .');</script>");
            //    Response.Redirect("~/Default.aspx");
            //    UpdatePanel1.Update();
        }
        else
        {
            Response.Write(@"<script language='javascript'>alert('some error is occurs \n .');</script>");
        }
    }
Esempio n. 2
0
    public static bool insertArtifact(Addartifact addArtifact, int userid)
    {
        try
        {
            bool inserted = false;

            String query = "insert into artifact(ArtifactID, ArtifactName, [desc], est_hour, lock_hour, toolid, comments, status, createdfor) " +
                           " values(@artid, @artname, @artdesc, @esthour, 0, @toolid, ' ', 'In progress', @userid)";


            cmd = new SqlCommand(query, conn);



            cmd.Parameters.AddWithValue("@artid", addArtifact.artNum);
            cmd.Parameters.AddWithValue("@artname", addArtifact.artName);
            cmd.Parameters.AddWithValue("@artdesc", addArtifact.desc);
            cmd.Parameters.AddWithValue("@esthour", addArtifact.esthour);
            cmd.Parameters.AddWithValue("@toolid", addArtifact.toolid);
            cmd.Parameters.AddWithValue("@userid", userid);


            conn.Open();
            int dr = cmd.ExecuteNonQuery();
            if (dr > 0)
            {
                inserted = true;
            }
            conn.Close();
            return(inserted);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            conn.Close();
        }
    }