示例#1
0
        public void InsertSOVoucherList(Hashtable ht)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                foreach (SOVoucherInfo oParam in ht.Keys)
                {
                    SOVoucherInfo newInfo = LoadSOVoucher(oParam);
                    if (newInfo == null)
                    {
                        InsertSOVoucher(oParam);
                    }
                    else
                    {
                        newInfo.VoucherID = oParam.VoucherID;
                        UpdateSOVoucher(newInfo);
                    }
                }
                scope.Complete();
            }
        }
示例#2
0
 private void map(SOVoucherInfo oParam, DataRow tempdr)
 {
     oParam.SysNo     = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.SOSysNo   = Util.TrimIntNull(tempdr["SOSysNo"]);
     oParam.VoucherID = Util.TrimNull(tempdr["VoucherID"]);
     oParam.Status    = Util.TrimIntNull(tempdr["Status"]);
 }
示例#3
0
        public int Update(SOVoucherInfo oParam)
        {
            string     sql = @"UPDATE SO_Voucher SET 
                            SOSysNo=@SOSysNo, VoucherID=@VoucherID, 
                            Status=@Status
                            WHERE SysNo=@SysNo";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo     = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramSOSysNo   = new SqlParameter("@SOSysNo", SqlDbType.Int, 4);
            SqlParameter paramVoucherID = new SqlParameter("@VoucherID", SqlDbType.NVarChar, 50);
            SqlParameter paramStatus    = new SqlParameter("@Status", SqlDbType.Int, 4);

            if (oParam.SysNo != AppConst.IntNull)
            {
                paramSysNo.Value = oParam.SysNo;
            }
            else
            {
                paramSysNo.Value = System.DBNull.Value;
            }
            if (oParam.SOSysNo != AppConst.IntNull)
            {
                paramSOSysNo.Value = oParam.SOSysNo;
            }
            else
            {
                paramSOSysNo.Value = System.DBNull.Value;
            }
            if (oParam.VoucherID != AppConst.StringNull)
            {
                paramVoucherID.Value = oParam.VoucherID;
            }
            else
            {
                paramVoucherID.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramSOSysNo);
            cmd.Parameters.Add(paramVoucherID);
            cmd.Parameters.Add(paramStatus);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
示例#4
0
        public int Insert(SOVoucherInfo oParam)
        {
            string     sql = @"INSERT INTO SO_Voucher
                            (
                            SOSysNo, VoucherID, Status
                            )
                            VALUES (
                            @SOSysNo, @VoucherID, @Status
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo     = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramSOSysNo   = new SqlParameter("@SOSysNo", SqlDbType.Int, 4);
            SqlParameter paramVoucherID = new SqlParameter("@VoucherID", SqlDbType.NVarChar, 50);
            SqlParameter paramStatus    = new SqlParameter("@Status", SqlDbType.Int, 4);

            paramSysNo.Direction = ParameterDirection.Output;
            if (oParam.SOSysNo != AppConst.IntNull)
            {
                paramSOSysNo.Value = oParam.SOSysNo;
            }
            else
            {
                paramSOSysNo.Value = System.DBNull.Value;
            }
            if (oParam.VoucherID != AppConst.StringNull)
            {
                paramVoucherID.Value = oParam.VoucherID;
            }
            else
            {
                paramVoucherID.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramSOSysNo);
            cmd.Parameters.Add(paramVoucherID);
            cmd.Parameters.Add(paramStatus);

            return(SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo));
        }
示例#5
0
        private SOVoucherInfo LoadSOVoucher(SOVoucherInfo oParam)
        {
            string  sql = "select * from so_voucher where sosysno=" + oParam.SOSysNo;
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                SOVoucherInfo newInfo = new SOVoucherInfo();
                map(newInfo, ds.Tables[0].Rows[0]);
                return(newInfo);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        public Hashtable LoadSOVoucherList(string VoucherID)
        {
            string  sql = "select * from so_voucher where voucherid = " + Util.ToSqlString(VoucherID);
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                Hashtable ht = new Hashtable();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    SOVoucherInfo oInfo = new SOVoucherInfo();
                    map(oInfo, dr);
                    ht.Add(oInfo, null);
                }
                return(ht);
            }
            else
            {
                return(null);
            }
        }
示例#7
0
 public int UpdateSOVoucher(SOVoucherInfo oParam)
 {
     return(new SOVoucherDac().Update(oParam));
 }
示例#8
0
 public int InsertSOVoucher(SOVoucherInfo oParam)
 {
     return(new SOVoucherDac().Insert(oParam));
 }