本文整理匯總了C#中XBase.Data.DBHelper.TransactionManager.BeginTransaction方法的典型用法代碼示例。如果您正苦於以下問題:C# TransactionManager.BeginTransaction方法的具體用法?C# TransactionManager.BeginTransaction怎麽用?C# TransactionManager.BeginTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XBase.Data.DBHelper.TransactionManager
的用法示例。
在下文中一共展示了TransactionManager.BeginTransaction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Add
public static int Add(XBase.Model.Office.SellReport.UserProductInfo model)
{
int num = 0;
string sqlstr = "insert into officedba.UserProductInfo(CompanyCD,productNum,productName,price,bref,memo) values(@CompanyCD,@productNum,@productName,@price,@bref,@memo)";
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
SqlParameter[] param = {
new SqlParameter("@CompanyCD",SqlDbType.VarChar,50),
new SqlParameter("@productNum",SqlDbType.VarChar,50),
new SqlParameter("@productName",SqlDbType.VarChar,200),
new SqlParameter("@price",SqlDbType.Decimal),
new SqlParameter("@bref",SqlDbType.VarChar,500),
new SqlParameter("@memo",SqlDbType.VarChar,1000)
};
param[0].Value = model.CompanyCD;
param[1].Value = model.productNum;
param[2].Value = model.productName;
param[3].Value = model.price;
param[4].Value = model.bref;
param[5].Value = model.memo;
try
{
num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr, param);
tran.Commit();
}
catch
{
tran.Rollback();
}
return num;
}
示例2: UpdateOrder
/// <summary>
/// 更新銷售委托代銷單
/// </summary>
/// <returns></returns>
public static bool UpdateOrder(Hashtable ht, SellChannelSttlModel sellChannelSttlModel, List<SellChannelSttlDetailModel> sellChannelSttlDetailModellist, out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
if (IsUpdate(sellChannelSttlModel.SttlNo))
{
string strSql = "delete from officedba.SellChannelSttlDetail where [email protected] and [email protected]";
SqlParameter[] paras = { new SqlParameter("@SttlNo", sellChannelSttlModel.SttlNo), new SqlParameter("@CompanyCD", sellChannelSttlModel.CompanyCD) };
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
UpdateOrderInfo(ht,sellChannelSttlModel, tran);
SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras);
InsertOrderDetail(sellChannelSttlDetailModellist, tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "非製單狀態的未提交審批、審批未通過或撤銷審批單據不可修改!";
}
return isSucc;
}
示例3: SaveExpensesApply
/// <summary>
/// 添加費用申請單
/// </summary>
/// <param name="expApplyModel"></param>
/// <param name="expDetailModelList"></param>
/// <param name="strMsg"></param>
/// <returns></returns>
public static bool SaveExpensesApply(ExpensesApplyModel expApplyModel, List<ExpDetailsModel> expDetailModelList,out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
//判斷單據編號是否存在
if (NoIsExist(expApplyModel.ExpCode,expApplyModel.CompanyCD))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
int expID;
expID = InsertExpensesApply(expApplyModel, tran);
InsertExpensesDetails(expDetailModelList, expID,tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "該編號已被使用,請輸入未使用的編號!";
}
return isSucc;
}
示例4: SaveReimbursement
/// <summary>
/// 保存費用報銷單
/// </summary>
/// <param name="reimbModel"></param>
/// <param name="reimbDetailList"></param>
/// <param name="strMsg"></param>
public static bool SaveReimbursement(ReimbursementModel reimbModel, List<ReimbDetailsModel> reimbDetailList, out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
//判斷單據編號是否存在
if (NoIsExist(reimbModel.ReimbNo, reimbModel.CompanyCD))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
int reimbID;
reimbID = InsertReimbursement(reimbModel, tran);
InsertReimbDetails(reimbDetailList, reimbID, tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "該編號已被使用,請輸入未使用的編號!";
}
return isSucc;
}
示例5: SaveOrder
/// <summary>
/// 保存銷售委托代銷單
/// </summary>
/// <returns></returns>
public static bool SaveOrder(Hashtable ht, SellChannelSttlModel sellChannelSttlModel, List<SellChannelSttlDetailModel> sellChannelSttlDetailModellist, out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
//判斷單據編號是否存在
if (NoIsExist(sellChannelSttlModel.SttlNo))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
InsertOrderInfo(ht,sellChannelSttlModel, tran);
InsertOrderDetail(sellChannelSttlDetailModellist, tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "該編號已被使用,請輸入未使用的編號!";
}
return isSucc;
}
示例6: AddSubBudgetInfo
public static int AddSubBudgetInfo(SubBudgetModel subBudgetModel, XBase.Common.UserInfoUtil userinfo)
{
StringBuilder sqlstr = new StringBuilder();
sqlstr.Append("insert into officedba.SubBudget(CompanyCD,projectid,BudgetName) values(@CompanyCD,@projectid,@BudgetName)");
SqlParameter[] param = {
new SqlParameter("@CompanyCD",SqlDbType.VarChar,50),
new SqlParameter("@projectid",SqlDbType.Int),
new SqlParameter("@BudgetName",SqlDbType.VarChar,200)
};
param[0].Value = userinfo.CompanyCD;
param[1].Value = subBudgetModel.Projectid;
param[2].Value = subBudgetModel.BudgetName;
TransactionManager tran = new TransactionManager();
int num = 0;
tran.BeginTransaction();
try
{
num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr.ToString(), param);
tran.Commit();
}
catch
{
tran.Rollback();
}
return num;
}
示例7: EditTable
/// <summary>
/// 修改自定義表單
/// </summary>
/// <param name="model"></param>
/// <param name="sonModel"></param>
/// <param name="strMsg"></param>
/// <returns></returns>
public static bool EditTable(CustomTableModel model, List<StructTable> sonModel, out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
string strSql = "delete from defdba.StructTable where [email protected] ";
SqlParameter[] paras = { new SqlParameter("@TableID", model.ID) };
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
EidtCustomTable(model, tran);
SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras);
AddStructTable(sonModel, Convert.ToInt32(model.ID), tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
return isSucc;
}
示例8: EditSubBudget
public static int EditSubBudget(SubBudgetModel subBudgetModel, XBase.Common.UserInfoUtil userinfo)
{
StringBuilder sqlstr = new StringBuilder();
sqlstr.Append("update officedba.SubBudget set [email protected],[email protected] where [email protected]");
SqlParameter[] param = {
new SqlParameter("@BudgetName",SqlDbType.VarChar,200),
new SqlParameter("@projectid",SqlDbType.Int,4),
new SqlParameter("@ID",SqlDbType.Int)
};
param[0].Value = subBudgetModel.BudgetName;
param[1].Value = subBudgetModel.Projectid;
param[2].Value = subBudgetModel.ID;
TransactionManager tran = new TransactionManager();
int num = 0;
tran.BeginTransaction();
try
{
num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr.ToString(), param);
tran.Commit();
}
catch
{
tran.Rollback();
}
return num;
}
示例9: Update
public static int Update(XBase.Model.Office.SellReport.UserProductInfo model)
{
int num = 0;
string sqlstr = "update officedba.UserProductInfo set [email protected],[email protected],[email protected],[email protected],[email protected] where [email protected]";
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
SqlParameter[] param = {
new SqlParameter("@CompanyCD",SqlDbType.VarChar,50),
new SqlParameter("@productNum",SqlDbType.VarChar,50),
new SqlParameter("@productName",SqlDbType.VarChar,200),
new SqlParameter("@price",SqlDbType.Decimal),
new SqlParameter("@bref",SqlDbType.VarChar,500),
new SqlParameter("@memo",SqlDbType.VarChar,1000),
new SqlParameter("@id",SqlDbType.Int,4)
};
param[0].Value = model.CompanyCD;
param[1].Value = model.productNum;
param[2].Value = model.productName;
param[3].Value = model.price;
param[4].Value = model.bref;
param[5].Value = model.memo;
param[6].Value = model.id;
try
{
num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr, param);
tran.Commit();
}
catch
{
tran.Rollback();
}
return num;
}
示例10: AddTable
/// <summary>
/// 添加自定義表單
/// </summary>
/// <returns></returns>
public static int AddTable(CustomTableModel model, List<StructTable> sonModel, out string strMsg)
{
int TableID = 0;
strMsg = "";
//判斷單據編號是否存在
if (!Exists(model.CompanyCD, model.CustomTableName))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
TableID = AddCustomTable(model, tran);
AddStructTable(sonModel, TableID, tran);
tran.Commit();
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
strMsg = "該表名已被使用,請輸入未使用的表名!";
}
return TableID;
}
示例11: SaveBatchRule
/// <summary>
/// 保存批次規則設置
/// </summary>
/// <param name="model">BachNoRuleSet實體</param>
/// <param name="strMsg">返回信息</param>
/// <returns>規則ID</returns>
public static int SaveBatchRule(BatchNoRuleSet model, out string strMsg)
{
int ruleID = 0;
strMsg = "";
StringBuilder strSql = new StringBuilder();
if (!IsExisted(model.CompanyCD))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
strSql.AppendLine(" insert into officedba.BatchRule ");
strSql.AppendLine(" (CompanyCD,RuleName,RulePrefix,RuleDateType,RuleNoLen,LastNo,RuleExample,");
strSql.AppendLine(" Remark,IsDefault,UsedStatus,ModifiedDate,ModifiedUserID) values");
strSql.AppendLine(" (@CompanyCD,@RuleName,@RulePrefix,@RuleDateType,@RuleNoLen,@LastNo,@RuleExample,");
strSql.AppendLine(" @Remark,@IsDefault,@UsedStatus,getdate(),@ModifiedUserID)");
strSql.AppendLine(" ;select @@IDENTITY ");
SqlParameter[] param = {
new SqlParameter("@CompanyCD",model.CompanyCD),
new SqlParameter("@RuleName",model.RuleName),
new SqlParameter("@RulePrefix",model.RulePrefix),
new SqlParameter("@RuleDateType",model.RuleDateType),
new SqlParameter("@RuleNoLen",model.RuleNoLen),
new SqlParameter("@LastNo",model.LastNo),
new SqlParameter("@RuleExample",model.RuleExample),
new SqlParameter("@Remark",model.Remark),
new SqlParameter("@IsDefault",model.IsDefault),
new SqlParameter("@UsedStatus",model.UsedStatus),
new SqlParameter("@ModifiedUserID",model.ModifiedUserID)
};
foreach (SqlParameter para in param)
{
if (para.Value == null)
{
para.Value = DBNull.Value;
}
}
ruleID = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), param));
tran.Commit();
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
strMsg = "保存失敗,已存在批次規則!";
}
return ruleID;
}
示例12: Update
/// <summary>
/// 更新銷售計劃
/// </summary>
/// <returns></returns>
public static bool Update(Hashtable ht,SellPlanModel sellPlanModel, SellPlanDetailModel sellPlanDetailModel, string strDetailAction, out string strMsg)
{
bool isSucc = false;//是否添加成功
strMsg = "";
if (IsUpdate(sellPlanModel.PlanNo))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
UpdateOrder(sellPlanModel, tran);
#region 拓展屬性
GetExtAttrCmd(sellPlanModel, ht, tran);
#endregion
//明細操作的類型
switch (strDetailAction)
{
case "1"://無操作
break;
case "2"://添加新明細
InsertOrderDetail(sellPlanDetailModel, tran);
break;
case "3"://更新明細
UpdateOrderDetail(sellPlanDetailModel, tran);
break;
case "4"://刪除明細
DelOrderDetail(sellPlanDetailModel, tran);
break;
default:
break;
}
tran.Commit();
strMsg = "保存成功!";
isSucc = true;
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "非製單狀態的未提交審批、審批未通過或撤銷審批計劃不可修改!";
}
return isSucc;
}
示例13: SaveTableModel
/// <summary>
/// 保存模板
/// </summary>
/// <param name="tbModel">ModuleTableModel模板實體</param>
/// <param name="strMsg"></param>
public static int SaveTableModel(ModuleTableModel tbModel, out string strMsg)
{
StringBuilder strSql = new StringBuilder();
strMsg = "";
int tbID = 0;
if (!IsRepeatedModule(tbModel.TableID, "0"))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
strSql.AppendLine(" insert into defdba.ModuleTable (CompanyCD,ModuleContent,TableID,ModuleType,UseStatus)");
strSql.AppendLine(" values(@CompanyCD,@ModuleContent,@TableID,@ModuleType,@UseStatus)");
strSql.AppendLine(" ;select @@IDENTITY ");
SqlParameter[] param = {
new SqlParameter("@CompanyCD",tbModel.CompanyCD ),
new SqlParameter("@ModuleContent",tbModel.ModuleContent ),
new SqlParameter("@TableID",tbModel.TableID ),
new SqlParameter("@ModuleType",tbModel.ModuleType ),
new SqlParameter("@UseStatus",tbModel.UseStatus )
};
foreach (SqlParameter para in param)
{
if (para.Value == null)
{
para.Value = DBNull.Value;
}
}
tbID = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), param));
tran.Commit();
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
strMsg = "保存失敗,該表的模板已定義!";
}
return tbID;
}
示例14: InsertSellChance
/// <summary>
/// 添加銷售機會及階段
/// </summary>
/// <param name="sellChanceModel">銷售機會表實體</param>
/// <param name="sellChancePushModel">銷售階段表實體</param>
/// <returns>是否添加成功</returns>
public static bool InsertSellChance(Hashtable ht,SellChanceModel sellChanceModel, SellChancePushModel sellChancePushModel)
{
bool isSucc = false;//是否添加成功
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
int sellChID = InsertChanece(tran, sellChanceModel);
//若是設置了手機提醒 則插入以下信息
if (sellChanceModel.IsMobileNotice == "1")
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into officedba.NoticeHistory(");
strSql.Append(" CompanyCD,SourceFlag,SourceID,PlanNoticeDate ) ");
strSql.Append(" values(@CompanyCD, @SourceFlag,@SourceID,@PlanNoticeDate ) ");
SqlParameter[] param = {
new SqlParameter("@CompanyCD",sellChanceModel.CompanyCD),
new SqlParameter("@SourceFlag","4"),
new SqlParameter("@SourceID",sellChID),
new SqlParameter("@PlanNoticeDate",sellChanceModel.RemindTime)
};
SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), param);//.ExecuteTransWithCommand(commN);
}
//拓展屬性
GetExtAttrCmd(sellChanceModel,ht, tran);
InsertPush(tran, sellChancePushModel);
tran.Commit();
isSucc = true;
}
catch (Exception ex)
{
tran.Rollback();
isSucc = false;
throw ex;
}
return isSucc;
}
示例15: Insert
/// <summary>
/// 添加新單據
/// </summary>
/// <returns></returns>
public static bool Insert(VoucherTemplateModel voucherTemplateModel, List<VoucherTemplateDetailModel> voucherTemplateDetailModelList, out string strMsg, out int Id)
{
bool isSucc = false;//是否添加成功
strMsg = "";
Id = 0;
//判斷單據編號是否存在
if (NoIsExist(voucherTemplateModel.TemNo))
{
if (IsTypeUsed(voucherTemplateModel.TemType.ToString(), voucherTemplateModel.CompanyCD))
{
TransactionManager tran = new TransactionManager();
tran.BeginTransaction();
try
{
InsertVoucherTemplate(voucherTemplateModel, tran, out Id);
InsertVoucherTemplateDetail(voucherTemplateDetailModelList, tran);
tran.Commit();
isSucc = true;
strMsg = "保存成功!";
}
catch (Exception ex)
{
tran.Rollback();
strMsg = "保存失敗,請聯係係統管理員!";
throw ex;
}
}
else
{
isSucc = false;
strMsg = "該模板類型已存在,請選擇其他未使用的模板類型!";
}
}
else
{
isSucc = false;
strMsg = "該編號已被使用,請輸入未使用的編號!";
}
return isSucc;
}