Esempio n. 1
0
        public OweDTO ShowDetail(string oweId)
        {
            OweDTO dto = null;

            using (con = new SqlConnection(connectionString))
            {
                con.Open();
                command = new SqlCommand("select  o.id,o.date,c.name,g.name,o.quantity,o.price,o.total,o.note from Owe o, Gas g,Customer c where o.customer=c.id and o.gas=g.id and o.stt='1' and o.id=@id", con);
                command.Parameters.AddWithValue("@id", oweId);
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    int    id       = reader.GetInt32(0);
                    string date     = reader.GetDateTime(1).ToString();
                    string customer = reader.GetString(2);
                    string gas      = reader.GetString(3);
                    double quantity = reader.GetDouble(4);
                    double price    = reader.GetDouble(5);
                    double total    = reader.GetDouble(6);
                    string note     = (reader.IsDBNull(7) == true)? "" : reader.GetString(7);
                    dto = new OweDTO(id.ToString(), date, customer, gas, (float)price, (float)quantity, (float)total, note);
                }
            }
            CloseConnection();
            return(dto);
        }
Esempio n. 2
0
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (addOwe == false)
     {
         addOwe detail = new addOwe();
         detail.Show();
         addOwe             = true;
         detail.FormClosed += AddOwe_Close;
         string id  = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         OweDTO dto = dao.ShowDetail(id);
         detail.Dto = dto;
         detail.ShowDetail();
     }
 }