本文整理汇总了C#中Car.getCarEngine方法的典型用法代码示例。如果您正苦于以下问题:C# Car.getCarEngine方法的具体用法?C# Car.getCarEngine怎么用?C# Car.getCarEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car.getCarEngine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: insertCar
public int insertCar(Car car, string user)
{
int car_id = 0;
try
{
string query = "dbo.insertCar";
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("@bnd", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@mdl", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@year", System.Data.SqlDbType.Int);
cmd.Parameters.Add("@eng", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@fuel", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@pwr", System.Data.SqlDbType.Int);
cmd.Parameters.Add("@img", System.Data.SqlDbType.NVarChar, 500);
cmd.Parameters.Add("@usr", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output;
//set parameter values
cmd.Parameters["@bnd"].Value = car.getCarBrand();
cmd.Parameters["@mdl"].Value = car.getCarModel();
cmd.Parameters["@year"].Value = car.getCarYear();
cmd.Parameters["@eng"].Value = car.getCarEngine();
cmd.Parameters["@fuel"].Value = car.getCarFuel();
cmd.Parameters["@pwr"].Value = car.getCarHPowers();
cmd.Parameters["@img"].Value = car.getCarImage();
cmd.Parameters["@usr"].Value = user;
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
//read output value
car_id = Convert.ToInt32(cmd.Parameters["@id"].Value);
//car_id = (int)cmd.ExecuteScalar();
conn.Close();
}
catch (Exception ex)
{
// Log the exception.
ExceptionUtility.LogException(ex, "DB.cs");
}
return car_id;
}
示例2: addNewTable
private void addNewTable(Car car)
{
Table tbl = new Table();
tbl.Width = new Unit("100%");
tbl.Height = new Unit("100%");
//------------------row-----------------------
TableRow rw = new TableRow();
//---------------------cell--------------
TableCell cell = new TableCell();
cell.Width = 300;
LinkButton carTitle = new LinkButton();
carTitle.Font.Size = 20;
carTitle.Text = car.getCarBrand() + " " + car.getCarModel();
carTitle.Click += new EventHandler(LinkButton1_Click);
carTitle.ID = "Title" + car.getId().ToString();
carTitle.CssClass = "linkbtn";
cell.Controls.Add(carTitle);
rw.Cells.Add(cell);
//---------------------cell--------------
cell = new TableCell();
Panel div = new Panel();
div.Style.Add("float", "right");
Button btnEdit = new Button();
btnEdit.Click += new EventHandler(btnAddFuel_Click);
btnEdit.Text = "Редактирай";
btnEdit.Style.Add("margin-left", "15px");
btnEdit.Style.Add("margin-right", "15px");
btnEdit.ID = "Edit" + car.getId().ToString();
btnEdit.CssClass = "btn";
div.Controls.Add(btnEdit);
cell.Controls.Add(div);
rw.Cells.Add(cell);
//---------------------cell--------------
cell = new TableCell();
Panel div2 = new Panel();
div.Style.Add("float", "left");
Button btnDel = new Button();
btnDel.Click += new EventHandler(btnDel_Click);
btnDel.Text = "Изтрий";
btnDel.Style.Add("margin-left", "15px");
btnDel.Style.Add("margin-right", "15px");
btnDel.ID = "Delete" + car.getId().ToString();
btnDel.CssClass = "btn";
div2.Controls.Add(btnDel);
cell.Controls.Add(div2);
rw.Cells.Add(cell);
tbl.Controls.Add(rw);
//------------------row-----------------------
rw = new TableRow();
//---------------------cell--------------
cell = new TableCell();
cell.RowSpan = 5;
cell.Width = 300;
ImageButton img = new ImageButton();
img.ImageUrl = car.getCarImage();
img.Width = 300;
img.Height = 150;
img.Style.Add("min-height", "150px");
img.Style.Add("min-width", "100px");
img.ID = "Img" + car.getId().ToString();
img.ToolTip = "Виж история на автомобила";
img.Click += new ImageClickEventHandler(img_Click);
cell.Controls.Add(img);
rw.Cells.Add(cell);
//---------------------cell--------------
cell = new TableCell();
cell.ColumnSpan = 2;
cell.Style.Add("height", "10px");
Label carInfo = new Label();
carInfo.Font.Size = 10;
carInfo.Text = car.getCarFuel() + ", " + car.getCarEngine() + ", " + car.getCarHPowers() + " к.с., " + car.getCarYear();
cell.Controls.Add(carInfo);
rw.Cells.Add(cell);
//---------------------cell--------------
cell = new TableCell();
cell.ColumnSpan = 4;
//.........这里部分代码省略.........
示例3: updateCar
public bool updateCar(int carId, Car car)
{
bool update = false;
try
{
string query = "dbo.updateCar";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CarDiaryDB"].ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = query;
cmd.Connection = conn;
cmd.Parameters.Add("@bnd", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@mdl", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@year", System.Data.SqlDbType.Int);
cmd.Parameters.Add("@eng", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@fuel", System.Data.SqlDbType.NVarChar, 50);
cmd.Parameters.Add("@pwr", System.Data.SqlDbType.Int);
cmd.Parameters.Add("@img", System.Data.SqlDbType.NVarChar, 500);
cmd.Parameters.Add("@id", System.Data.SqlDbType.Int);
//set parameter values
cmd.Parameters["@bnd"].Value = car.getCarBrand();
cmd.Parameters["@mdl"].Value = car.getCarModel();
cmd.Parameters["@year"].Value = car.getCarYear();
cmd.Parameters["@eng"].Value = car.getCarEngine();
cmd.Parameters["@fuel"].Value = car.getCarFuel();
cmd.Parameters["@pwr"].Value = car.getCarHPowers();
cmd.Parameters["@img"].Value = car.getCarImage();
cmd.Parameters["@id"].Value = carId;
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
update = true;
conn.Close();
}
catch (Exception ex)
{
update = false;
// Log the exception.
ExceptionUtility.LogException(ex, "DB.cs");
}
return update;
}