using System;
|
using System.Collections.Generic;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsGy_SteppedPriceCoefficientBill : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsGy_SteppedPriceCoefficientBillMain omodel = new Model.ClsGy_SteppedPriceCoefficientBillMain();
|
public List<Model.ClsGy_SteppedPriceCoefficientBillSub> DetailColl = new List<Model.ClsGy_SteppedPriceCoefficientBillSub>();
|
|
public ClsGy_SteppedPriceCoefficientBill()
|
{
|
base.MvarItemKeySub = "Gy_SteppedPriceCoefficientBillSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey = "Gy_SteppedPriceCoefficientBillMain";
|
base.MvarReportTitle = "阶梯工价系数单";
|
base.BillType = "GYSTPRICECOEFF"; // 需要根据实际的单据类型编码设置
|
base.HBillSubType = "GYSTPRICECOEFF";
|
}
|
|
#region 固定代码
|
|
~ClsGy_SteppedPriceCoefficientBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion
|
|
#region 自定义方法
|
|
// 修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.BeginTran();
|
|
// 更新主表
|
oCn.RunProc("Update Gy_SteppedPriceCoefficientBillMain set " +
|
"HBillNo = '" + omodel.HBillNo + "'" +
|
", HDate = '" + omodel.HDate.ToString("yyyy-MM-dd HH:mm:ss") + "'" +
|
", HYear = " + omodel.HYear.ToString() +
|
", HPeriod = " + omodel.HPeriod.ToString() +
|
", HRemark = '" + omodel.HRemark + "'" +
|
", HUpDater = '" + DBUtility.ClsPub.CurUserName + "'" +
|
", HUpDateDate = getdate()" +
|
// 自定义字段
|
", HProcID = " + omodel.HProcID.ToString() +
|
", HEmpID = " + omodel.HEmpID.ToString() +
|
", HDeptID = " + omodel.HDeptID.ToString() +
|
", HStockOrgID = " + omodel.HStockOrgID.ToString() +
|
" where HInterID = " + lngBillKey.ToString());
|
|
// 删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
|
sReturn = "修改单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw;
|
}
|
}
|
|
// 新增单据
|
public override bool AddBill(ref string sReturn)
|
{
|
try
|
{
|
// 得到mainid
|
omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
|
oCn.BeginTran();
|
|
// 插入主表
|
oCn.RunProc("Insert Into Gy_SteppedPriceCoefficientBillMain " +
|
"(HBillType, HBillSubType, HInterID, HBillNo, HDate" +
|
", HYear, HPeriod, HRemark, HMaker, HMakeDate, HCheckFlowID" +
|
", HProcID, HEmpID, HDeptID, HStockOrgID" +
|
") values('" +
|
this.BillType + "','" +
|
this.HBillSubType + "'," +
|
omodel.HInterID.ToString() + ",'" +
|
omodel.HBillNo + "','" +
|
omodel.HDate.ToString("yyyy-MM-dd HH:mm:ss") + "'," +
|
omodel.HYear.ToString() + "," +
|
omodel.HPeriod.ToString() + ",'" +
|
omodel.HRemark + "','" +
|
DBUtility.ClsPub.CurUserName + "',getdate()," +
|
omodel.HCheckFlowID.ToString() + "," +
|
omodel.HProcID.ToString() + "," +
|
omodel.HEmpID.ToString() + "," +
|
omodel.HDeptID.ToString() + "," +
|
omodel.HStockOrgID.ToString() +
|
")");
|
|
// 插入子表
|
foreach (Model.ClsGy_SteppedPriceCoefficientBillSub oSub in DetailColl)
|
{
|
string entryCloseDate = oSub.HEntryCloseDate.HasValue ?
|
oSub.HEntryCloseDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "NULL";
|
|
oCn.RunProc("Insert into Gy_SteppedPriceCoefficientBillSub " +
|
"(HInterID, HEntryID, HCloseMan, HEntryCloseDate, HCloseType, HRemark" +
|
", HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType" +
|
", HRelationQty, HRelationPrice, HSeq, HMinQty, HMaxQty" +
|
", HPriceCoefficient, HMaxPrice, HStockOrgID" +
|
") values(" +
|
omodel.HInterID.ToString() + "," +
|
oSub.HEntryID.ToString() + ",'" +
|
oSub.HCloseMan + "'," +
|
(entryCloseDate == "NULL" ? "NULL" : "'" + entryCloseDate + "'") + "," +
|
(oSub.HCloseType ? "1" : "0") + ",'" +
|
oSub.HRemark + "'," +
|
oSub.HSourceInterID.ToString() + "," +
|
oSub.HSourceEntryID.ToString() + ",'" +
|
oSub.HSourceBillNo + "','" +
|
oSub.HSourceBillType + "'," +
|
oSub.HRelationQty.ToString() + "," +
|
oSub.HRelationPrice.ToString() + "," +
|
oSub.HSeq.ToString() + "," +
|
oSub.HMinQty.ToString() + "," +
|
oSub.HMaxQty.ToString() + "," +
|
oSub.HPriceCoefficient.ToString() + "," +
|
oSub.HMaxPrice.ToString() + "," +
|
oSub.HStockOrgID.ToString() +
|
")");
|
}
|
|
sReturn = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw;
|
}
|
}
|
|
// 显示单据
|
public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
// 查询主表
|
DataSet Ds;
|
Ds = oCn.RunProcReturn("Select * from Gy_SteppedPriceCoefficientBillMain Where HInterID = " + lngBillKey.ToString(), "Gy_SteppedPriceCoefficientBillMain");
|
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
|
// 固定赋值===========================================
|
omodel.HYear = (int)DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
|
omodel.HPeriod = (int)DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
|
omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
|
omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
|
omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
|
omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
|
omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
|
omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
|
omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
|
omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
|
omodel.HBackDate = GetNullableDateTime(Ds.Tables[0].Rows[0]["HBackDate"]);
|
omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
|
omodel.HCheckDate = GetNullableDateTime(Ds.Tables[0].Rows[0]["HCheckDate"]);
|
omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
|
omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
|
omodel.HMakeDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HMakeDate"]);
|
omodel.HUpDateDate = GetNullableDateTime(Ds.Tables[0].Rows[0]["HUpDateDate"]);
|
omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
|
omodel.HCloseDate = GetNullableDateTime(Ds.Tables[0].Rows[0]["HCloseDate"]);
|
omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
|
omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
|
omodel.HDeleteDate = GetNullableDateTime(Ds.Tables[0].Rows[0]["HDeleteDate"]);
|
omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
|
//========================================================
|
|
// 自定义字段
|
omodel.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]);
|
omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
|
omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
|
omodel.HStockOrgID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HStockOrgID"]);
|
|
// 查询子表
|
DataSet DsSub;
|
DsSub = oCn.RunProcReturn("Select * from Gy_SteppedPriceCoefficientBillSub Where HInterID = " + lngBillKey.ToString() + " order by HEntryID ", "Gy_SteppedPriceCoefficientBillSub");
|
|
DetailColl.Clear(); // 清空
|
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsGy_SteppedPriceCoefficientBillSub oSub = new Model.ClsGy_SteppedPriceCoefficientBillSub();
|
|
// 固定赋值===============================================
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
|
oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
|
oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
|
oSub.HRelationQty = Convert.ToDecimal(DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]));
|
oSub.HRelationPrice = Convert.ToDecimal(DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationPrice"]));
|
oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
|
oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
|
oSub.HEntryCloseDate = GetNullableDateTime(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
//===================================================
|
|
// 自定义字段
|
oSub.HSeq = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSeq"]);
|
oSub.HMinQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMinQty"]);
|
oSub.HMaxQty = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaxQty"]);
|
oSub.HPriceCoefficient = Convert.ToDecimal(DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPriceCoefficient"]));
|
oSub.HMaxPrice = Convert.ToDecimal(DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMaxPrice"]));
|
oSub.HStockOrgID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HStockOrgID"]);
|
|
DetailColl.Add(oSub);
|
}
|
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw;
|
}
|
}
|
|
// 辅助方法:处理可空日期
|
private DateTime? GetNullableDateTime(object value)
|
{
|
if (value == DBNull.Value || value == null)
|
return null;
|
|
try
|
{
|
return Convert.ToDateTime(value);
|
}
|
catch
|
{
|
return null;
|
}
|
}
|
|
#endregion
|
|
#region 其他方法 - 根据需要添加
|
|
// 获取工序信息
|
public DataSet GetProcessInfo(int procID)
|
{
|
return oCn.RunProcReturn("select * from Gy_Process where HInterID = " + procID, "Process");
|
}
|
|
//// 获取员工信息
|
//public DataSet GetEmployeeInfo(int empID)
|
//{
|
// return oCn.RunProcReturn("select * from t_Emp where FItemID = " + empID, "Employee");
|
//}
|
|
//// 获取部门信息
|
//public DataSet GetDepartmentInfo(int deptID)
|
//{
|
// return oCn.RunProcReturn("select * from t_Department where FItemID = " + deptID, "Department");
|
//}
|
|
//// 获取组织信息
|
//public DataSet GetStockOrgInfo(int orgID)
|
//{
|
// return oCn.RunProcReturn("select * from t_Stock where FItemID = " + orgID, "StockOrg");
|
//}
|
|
#endregion
|
}
|
}
|