Esempio n. 1
0
File: DB.cs Progetto: rgg1992/Test
    public bool addOtherCost(OtherCost input)
    {
        bool insert = false;
        try
        {
            string query = "dbo.addOtherCost";

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CarDiaryDB"].ToString());
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.CommandText = query;
            cmd.Connection = conn;

            //set up the parameters
            cmd.Parameters.Add("@car", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@cat", System.Data.SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@dat", System.Data.SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@mil", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@cost", System.Data.SqlDbType.Float);
            cmd.Parameters.Add("@not", System.Data.SqlDbType.NVarChar, 1000);

            //set parameter values
            cmd.Parameters["@car"].Value = input.getCar_id();
            cmd.Parameters["@cat"].Value = input.getCategory();
            cmd.Parameters["@dat"].Value = input.getDate();
            cmd.Parameters["@mil"].Value = input.getMileage();
            cmd.Parameters["@cost"].Value = input.getTotal_cost();
            cmd.Parameters["@not"].Value = input.getNotes();


            cmd.Connection = conn;
            conn.Open();

            cmd.ExecuteNonQuery();

            insert = true;

            conn.Close();
        }
        catch (Exception ex)
        {
            insert = false;
            // Log the exception.
            ExceptionUtility.LogException(ex, "DB.cs");
        }

        return insert;
    }
Esempio n. 2
0
    private void fillOtherRow(int count, OtherCost item)
    {
        Table tbl = new Table();

        tbl.Width = new Unit("100%");
        tbl.Height = new Unit("100%");
        tbl.Style.Add("min-width", "330px !important");

        //------------------row-----------------------
        TableRow rw = new TableRow();
        if (count % 2 == 0)
            rw.BackColor = System.Drawing.Color.White;
        else
            rw.BackColor = System.Drawing.Color.LightGray;
        //---------------------cell--------------
        TableCell cell = new TableCell();
        cell.Width = new Unit("10%");

        Label date = new Label();
        date.Width = new Unit("100%");
        date.Style.Add("text-align", "center");
        date.Font.Size = 10;
        date.Text = item.getDate();

        cell.Controls.Add(date);
        rw.Cells.Add(cell);

        //---------------------cell--------------
        cell = new TableCell();
        cell.Width = new Unit("15%");

        Label mileage = new Label();
        mileage.Width = new Unit("100%");
        mileage.Style.Add("text-align", "center");
        mileage.Font.Size = 10;
        mileage.Text = item.getMileage().ToString("0.##");

        cell.Controls.Add(mileage);
        rw.Cells.Add(cell);

        //---------------------cell--------------
        cell = new TableCell();
        cell.Width = new Unit("50%");

        Label category = new Label();
        category.Width = new Unit("100%");
        category.Style.Add("text-align", "center");
        category.Font.Size = 10;
        category.Text = item.getCategory();

        cell.Controls.Add(category);
        rw.Cells.Add(cell);

        //---------------------cell--------------
        cell = new TableCell();

        cell.Width = new Unit("10%");

        Label price = new Label();
        price.Width = new Unit("100%");
        price.Style.Add("text-align", "center");
        price.Font.Size = 10;
        price.Text = item.getTotal_cost().ToString("0.##");

        cell.Controls.Add(price);
        rw.Cells.Add(cell);

        //---------------------cell--------------
        cell = new TableCell();
        cell.Width = new Unit("8%");

        ImageButton delete = new ImageButton();
        //Image img = new Image();
        //img.ImageUrl = "~/delete.ico";
        //delete.BackgroundImage = img;
        delete.ImageUrl = "~/Images/delete.png";
        delete.Style.Add("height", "20px");
        delete.Style.Add("width", "20px");
        delete.ID = "DeleteOther" + item.getId();
        delete.Click += new ImageClickEventHandler(DeleteOtherCost_Click);
        delete.ToolTip = "Изтрий";

        cell.Controls.Add(delete);
        rw.Cells.Add(cell);

        //---------------------cell--------------
        cell = new TableCell();
        cell.Width = new Unit("7%");



        ImageButton notes = new ImageButton();
        notes.ImageUrl = "~/Images/icon_note.png";
        notes.Style.Add("height", "20px");
        notes.Style.Add("width", "20px");
        notes.ID = "Notes" + item.getId();
        //notes.Click += new ImageClickEventHandler(ShowNotes_Click);
        string noteText = item.getNotes();
        if (!noteText.Equals(""))
            notes.ToolTip = noteText;
        else
            notes.ToolTip = "Няма въведени записки за този разход";
        notes.Enabled = false;

        cell.Controls.Add(notes);
        rw.Cells.Add(cell);

        tbl.Controls.Add(rw);

        Panel2.Controls.Add(tbl);
    }