public object DeleteHcProductorderInfoById(object param) { Database db = DatabaseFactory.CreateDatabase(); object retObj = null; using (DbConnection connection = db.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { HcProductorderDAL hcProductorderDAL = new HcProductorderDAL(); HcProductorderEntity hcProductorderEntity = (HcProductorderEntity)param; retObj = (object)hcProductorderDAL.DeleteHcProductorderInfoById(hcProductorderEntity, db, transaction); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } return(retObj); }
public HcProductorderEntity GetSingleHcProductorderRecordById(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = "SELECT ID, orderId, productId, productQnty, productPrice, orderStatus, orderForUser, orderDate, updateBy, updateAt FROM HC_ProductOrder WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, param); HcProductorderEntity hcProductorderEntity = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { hcProductorderEntity = new HcProductorderEntity(); if (dataReader["ID"] != DBNull.Value) { hcProductorderEntity.Id = dataReader["ID"].ToString(); } if (dataReader["orderId"] != DBNull.Value) { hcProductorderEntity.Orderid = dataReader["orderId"].ToString(); } if (dataReader["productId"] != DBNull.Value) { hcProductorderEntity.Productid = dataReader["productId"].ToString(); } if (dataReader["productQnty"] != DBNull.Value) { hcProductorderEntity.Productqnty = dataReader["productQnty"].ToString(); } if (dataReader["productPrice"] != DBNull.Value) { hcProductorderEntity.Productprice = dataReader["productPrice"].ToString(); } if (dataReader["orderStatus"] != DBNull.Value) { hcProductorderEntity.Orderstatus = dataReader["orderStatus"].ToString(); } if (dataReader["orderForUser"] != DBNull.Value) { hcProductorderEntity.Orderforuser = dataReader["orderForUser"].ToString(); } if (dataReader["orderDate"] != DBNull.Value) { hcProductorderEntity.Orderdate = dataReader["orderDate"].ToString(); } if (dataReader["updateBy"] != DBNull.Value) { hcProductorderEntity.Updateby = dataReader["updateBy"].ToString(); } if (dataReader["updateAt"] != DBNull.Value) { hcProductorderEntity.Updateat = dataReader["updateAt"].ToString(); } } } return(hcProductorderEntity); }
public DataTable GetAllHcProductorderRecord(object param) { Database db = DatabaseFactory.CreateDatabase(); HcProductorderEntity obj = new HcProductorderEntity(); if (param != null) { obj = (HcProductorderEntity)param; } string sql = ""; if (!string.IsNullOrEmpty(obj.queryflag) && obj.queryflag == "distinct") { sql = @"SELECT DISTINCT A.orderId, '' as ID, A.orderStatus, A.orderForUser, A.orderDate FROM HC_ProductOrder A ,HC_Medicine B where 1=1 and A.productId = B.Id"; } else { sql = @"SELECT DISTINCT A.ID, A.orderId, A.productId,B.MedicineName, A.productQnty, A.productPrice, A.orderStatus, A.orderForUser, A.orderDate, A.updateBy, A.updateAt , B.ImageUrl FROM HC_ProductOrder A ,HC_Medicine B where 1=1 and A.productId = B.Id"; } if (!string.IsNullOrEmpty(obj.Orderid)) { sql += " And A.orderId = '" + obj.Orderid + "'"; } if (!string.IsNullOrEmpty(obj.Orderforuser)) { sql += " And A.orderForUser = '******'"; } if (!string.IsNullOrEmpty(obj.Productid)) { sql += " And A.productId = '" + obj.Productid + "'"; } if (!string.IsNullOrEmpty(obj.Orderdate)) { sql += " And A.orderDate = '" + obj.Orderdate + "'"; } sql += " Order by A.orderStatus asc"; DbCommand dbCommand = db.GetSqlStringCommand(sql); DataSet ds = db.ExecuteDataSet(dbCommand); return(ds.Tables[0]); }
public bool DeleteHcProductorderInfoById(HcProductorderEntity hcProductorderEntity, Database db, DbTransaction transaction) { string sql = "DELETE FROM HC_ProductOrder WHERE orderId=@orderId and orderforuser = @Orderforuser "; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "orderId", DbType.String, hcProductorderEntity.Orderid); db.AddInParameter(dbCommand, "Orderforuser", DbType.String, hcProductorderEntity.Orderforuser); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public bool UpdateHcProductorderInfo(HcProductorderEntity hcProductorderEntity, Database db, DbTransaction transaction) { string sql = "UPDATE HC_ProductOrder SET orderId= @Orderid, productId= @Productid, productQnty= @Productqnty, productPrice= @Productprice, orderStatus= @Orderstatus, orderForUser= @Orderforuser, orderDate= @Orderdate, updateBy= @Updateby, updateAt= @Updateat WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, hcProductorderEntity.Id); db.AddInParameter(dbCommand, "Orderid", DbType.String, hcProductorderEntity.Orderid); db.AddInParameter(dbCommand, "Productid", DbType.String, hcProductorderEntity.Productid); db.AddInParameter(dbCommand, "Productqnty", DbType.String, hcProductorderEntity.Productqnty); db.AddInParameter(dbCommand, "Productprice", DbType.String, hcProductorderEntity.Productprice); db.AddInParameter(dbCommand, "Orderstatus", DbType.String, hcProductorderEntity.Orderstatus); db.AddInParameter(dbCommand, "Orderforuser", DbType.String, hcProductorderEntity.Orderforuser); db.AddInParameter(dbCommand, "Orderdate", DbType.String, hcProductorderEntity.Orderdate); db.AddInParameter(dbCommand, "Updateby", DbType.String, hcProductorderEntity.Updateby); db.AddInParameter(dbCommand, "Updateat", DbType.String, hcProductorderEntity.Updateat); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public object SaveHcProductorderInfo(HcProductorderEntity hcProductorderEntity, Database db, DbTransaction transaction) { string sql = "INSERT INTO HC_ProductOrder ( orderId, productId, productQnty, productPrice, orderStatus, orderForUser, orderDate, updateBy, updateAt) output inserted.ID VALUES ( @Orderid, @Productid, @Productqnty, @Productprice, @Orderstatus, @Orderforuser, @Orderdate, @Updateby, @Updateat )"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Orderid", DbType.String, hcProductorderEntity.Orderid); db.AddInParameter(dbCommand, "Productid", DbType.String, hcProductorderEntity.Productid); db.AddInParameter(dbCommand, "Productqnty", DbType.String, hcProductorderEntity.Productqnty); db.AddInParameter(dbCommand, "Productprice", DbType.String, hcProductorderEntity.Productprice); db.AddInParameter(dbCommand, "Orderstatus", DbType.String, hcProductorderEntity.Orderstatus); db.AddInParameter(dbCommand, "Orderforuser", DbType.String, hcProductorderEntity.Orderforuser); db.AddInParameter(dbCommand, "Orderdate", DbType.String, hcProductorderEntity.Orderdate); db.AddInParameter(dbCommand, "Updateby", DbType.String, hcProductorderEntity.Updateby); db.AddInParameter(dbCommand, "Updateat", DbType.String, hcProductorderEntity.Updateat); //db.ExecuteNonQuery(dbCommand, transaction); //return true; var id = db.ExecuteScalar(dbCommand, transaction).ToString(); return(id); }