本文整理匯總了C#中Model.Model類的典型用法代碼示例。如果您正苦於以下問題:C# Model類的具體用法?C# Model怎麽用?C# Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Model類屬於Model命名空間,在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Add
/// <summary>
/// 新增
/// </summary>
/// <param name="model">要往數據庫中的添加的實體對象</param>
/// <returns>結果</returns>
public int Add(Model.Number_Card model)
{
int result = 0;
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append(@"insert into [Number_Card]( ");
strSql.Append(@"[JK_Number_Card],[JK_Number_Card_Id],[JK_NumberCard_DateTime],[JK_Number_Count],[JK_Member_id]) values (@jK_Number_Card,@jK_Number_Card_Id,@jK_NumberCard_DateTime,@jK_Number_Count,@jK_Member_id)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = new SqlParameter[] {
new SqlParameter("@jK_Number_Card", SqlDbType.NVarChar,50),
new SqlParameter("@jK_Number_Card_Id", SqlDbType.Int,4),
new SqlParameter("@jK_NumberCard_DateTime", SqlDbType.DateTime,8),
new SqlParameter("@jK_Number_Count", SqlDbType.Int,4),
new SqlParameter("@jK_Member_id", SqlDbType.Int,4)
};
parameters[0].Value = model.JK_Number_Card;
parameters[1].Value = model.JK_Number_Card_Id;
parameters[2].Value = model.JK_NumberCard_DateTime;
parameters[3].Value = model.JK_Number_Count;
parameters[4].Value = model.JK_Member_id;
result = Convert.ToInt32(DAL.SqlDataHelper.GetScalar(strSql.ToString(), parameters));
}
catch (Exception)
{
}
return result;
}
示例2: Add
/// <summary>
/// 添加部門
/// </summary>
/// <param name="model">部門對象</param>
/// <returns>結果對象</returns>
public Model.ResultModel Add(Model.T_Department dept)
{
ResultModel rm = new ResultModel();
Model.QueryDept qd = new QueryDept()
{
DeptName = dept.DeptName
};
var list = dal.Get(qd);
if (list.Count > 0)
{
rm.Result = false;
rm.Message = "部門名稱重複";
}
else
{
if (dal.Add(dept))
{
rm.Result = true;
rm.Message = "部門添加成功";
}
else
{
rm.Result = false;
rm.Message = "部門添加失敗";
}
}
return rm;
}
示例3: CreateUser
public int CreateUser(Model.User user)
{
var newUser = Container.Users.Add(new User { UserName = user.UserName });
Container.SaveChanges();
return newUser.UserId;
}
示例4: OrganAdd
public static int OrganAdd(Model.Organizational Organ)
{
SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@PID", SqlDbType.VarChar, 6) };
pars[0].Value = Organ.Name;
pars[1].Value = Organ.PID;
return SqlHelper.ExecuteProcess("pro_Organizational_Add", pars);
}
示例5: Add
/// <summary>
/// 新增
/// </summary>
/// <param name="model">要往數據庫中的添加的實體對象</param>
/// <returns>結果</returns>
public int Add(Model.Product_Info model)
{
int result = 0;
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append(@"insert into [Product_Info]( ");
strSql.Append(@"[JK_Titile],[jk_DateTime],[JK_Product_id],[JK_Product_img_src],[JK_Product_name],[JK_Product_datetime]) values (@jK_Titile,@jk_DateTime,@jK_Product_id,@jK_Product_img_src,@jK_Product_name,@jK_Product_datetime)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = new SqlParameter[] {
new SqlParameter("@jK_Titile", SqlDbType.NVarChar,50),
new SqlParameter("@jk_DateTime", SqlDbType.DateTime,8),
new SqlParameter("@jK_Product_id", SqlDbType.Int,4),
new SqlParameter("@jK_Product_img_src", SqlDbType.NVarChar,80),
new SqlParameter("@jK_Product_name", SqlDbType.NChar,10),
new SqlParameter("@jK_Product_datetime", SqlDbType.DateTime,8)
};
parameters[0].Value = model.JK_Titile;
parameters[1].Value = model.Jk_DateTime;
parameters[2].Value = model.JK_Product_id;
parameters[3].Value = model.JK_Product_img_src;
parameters[4].Value = model.JK_Product_name;
parameters[5].Value = model.JK_Product_datetime;
result = Convert.ToInt32(DAL.SqlDataHelper.GetScalar(strSql.ToString(), parameters));
}
catch (Exception)
{
}
return result;
}
示例6: Select
public Model.Client Select(Model.Client Client)
{
Model.Client cliente;
try
{
SqlCommand cmd = new SqlCommand("Select * From dbo.[client] Where client_id= " + Client.Client_id, db.Db());
SqlDataReader dr = cmd.ExecuteReader(); //CommandBehavior.CloseConnection
if (dr.Read())
{
cliente = new Model.Client();
cliente.Client_id = Convert.ToInt32(dr["client_id"].ToString());
cliente.Local_name = dr["local_name"].ToString();
cliente.Intl_name = dr["intl_name"].ToString();
cliente.Code = dr["code"].ToString();
cliente.Active = Convert.ToInt32(dr["active"]);
cliente.Multinational = Convert.ToInt32(dr["multinational"].ToString());
return cliente;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
}
示例7: Add
/// <summary>
/// 新增
/// </summary>
/// <param name="model">要往數據庫中的添加的實體對象</param>
/// <returns>結果</returns>
public int Add(Model.Applyforresale model)
{
int result = 0;
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append(@"insert into [Applyforresale]( ");
strSql.Append(@"[JK_Applyforresale],[JK_Applyforresale_DateTime],[JK_Applyforresale_Member_Id],[JK_Applforresale_Member_name]) values (@jK_Applyforresale,@jK_Applyforresale_DateTime,@jK_Applyforresale_Member_Id,@jK_Applforresale_Member_name)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = new SqlParameter[] {
new SqlParameter("@jK_Applyforresale", SqlDbType.NChar,10),
new SqlParameter("@jK_Applyforresale_DateTime", SqlDbType.DateTime,8),
new SqlParameter("@jK_Applyforresale_Member_Id", SqlDbType.Int,4),
new SqlParameter("@jK_Applforresale_Member_name", SqlDbType.NVarChar,50)
};
parameters[0].Value = model.JK_Applyforresale;
parameters[1].Value = model.JK_Applyforresale_DateTime;
parameters[2].Value = model.JK_Applyforresale_Member_Id;
parameters[3].Value = model.JK_Applforresale_Member_name;
result = Convert.ToInt32(DAL.SqlDataHelper.GetScalar(strSql.ToString(), parameters));
}
catch (Exception)
{
}
return result;
}
示例8: Select
public Model.Agency Select(Model.Agency agency)
{
Model.Agency ag;
try
{
SqlCommand cmd = new SqlCommand("Select * From dbo.[Agency] Where agency_id=" + agency.Agency_id, db.Db());
using(SqlDataReader dr = cmd.ExecuteReader())
{
ag = new Model.Agency();
if (dr.Read())
{
if (!dr.IsDBNull(0))
ag.Agency_id = dr.GetInt32(0);
if (!dr.IsDBNull(1))
ag.Name = dr.GetString(1);
}
return ag;
}
}
catch (Exception)
{
return null;
}
}
示例9: Add
public string Add(Model.Geospec geo)
{
string str = " INSERT INTO [FAMIS].[dbo].[Geospec] ([currency],[decimal_symbol],[date_format],[region_id],[country_id])" + Environment.NewLine;
str += " VALUES ('" +
geo.Currency + "','" +
geo.Decimal_symbol + "', '" +
geo.Date_format + "'," +
geo.Region_id + "," +
geo.Country_id + ")";
try
{
SqlCommand scmd = new SqlCommand(str, db.Db());
int iret = scmd.ExecuteNonQuery();
return iret.ToString() + " Record successfully saved";
}
catch (SqlException ex)
{
return "Error saving the record of: " + geo.Geospec_id + Environment.NewLine + " Erro: " + ex.Message.ToString();
throw;
}
finally
{
}
}
示例10: Select
public Model.Department Select(Model.Department Dep)
{
try
{
SqlCommand cmd = new SqlCommand("Select * From [FAMIS].[dbo].[Department] Where Department_id =" + Dep.Department_id, db.Db());
SqlDataReader dr = cmd.ExecuteReader();
Model.Department Department;
Department = new Model.Department();
while (dr.Read())
{
if (!dr.IsDBNull(0))
{
Department.Department_id = dr.GetInt32(0);
}
if (!dr.IsDBNull(1))
{
Department.Name = dr.GetString(1);
}
}
return Department;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例11: getBill
//獲取賬單信息
public DataSet getBill(string customer_id)
{
Model.Model model = new Model.Model();
DataSet dt = new DataSet();
dt = model.getBillInfor(customer_id);
return dt;
}
示例12: getCustomer
//獲得賬戶信息
public DataSet getCustomer(string username)
{
Model.Model model = new Model.Model();
DataSet dt = new DataSet();
dt = model.getCustomerInfor(username);
return dt;
}
示例13: getRecordBorrowTime
/// <summary>
/// 根據書籍編號和借閱人編號得到借閱時間
/// </summary>
/// <param name="book"></param>
/// <param name="viewer"></param>
/// <returns></returns>
public DateTime getRecordBorrowTime(Model.Book book, Model.Viewer viewer)
{
string strSql = "select borrow_date from [BorrowInfo] where [email protected]_id and [email protected]_id";
SqlParameter[] parameters ={
new SqlParameter ("@r_id",SqlDbType .VarChar,50),
new SqlParameter ("@b_id",SqlDbType.VarChar,50)
};
parameters[0].Value = viewer.Id;
parameters[1].Value = book.Id;
DataTable dt = SqlDbHelper.ExecuteDataTable(strSql.ToString(),
CommandType.Text, parameters);
string result ="";
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["borrow_date"] != null && dt.Rows[0]["borrow_date"].ToString() != "")
{
result = dt.Rows[0]["borrow_date"].ToString();
}
}
result = result.Split(' ')[0];
DateTime dateresult = new DateTime();
try
{
dateresult = DateTime.Parse(result);
} catch (FormatException e)
{
}
return dateresult;
}
示例14: Edit
public static void Edit(Model.Type type)
{
string sql = @"update LType" + type.Language.ToString() + " set name='" + type.Name + "' where id=" + type.Id.ToString()+
" update tblMenuType set OrderId=" + type.Order.ToString() + " where id=" + type.Id.ToString();
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, sql);
}
示例15: Add
/// <summary>
/// 添加代表
/// </summary>
/// <param name="behalf">代表對象</param>
/// <returns>結果對象</returns>
public Model.ResultModel Add(Model.T_Behalf behalf)
{
ResultModel rm = new ResultModel();
Model.QueryBehalf qb = new QueryBehalf()
{
Phone = behalf.Phone
};
var list = dal.Get(qb);
if (list.Count > 0)
{
rm.Result = false;
rm.Message = "代表手機號不能重複";
}
else
{
if (dal.Add(behalf))
{
rm.Result = true;
rm.Message = "代表添加成功";
}
else
{
rm.Result = false;
rm.Message = "代表添加失敗";
}
}
return rm;
}