Exemplo n.º 1
0
        public ResultModel GetSIbyInvoiceId(UserModel user, int invoiceId)
        {
            ResultModel result = new ResultModel();
            SqlDataReader dr = null;

            try
            {
                string sql = string.Format("select * from dbo.Inv_SI where InvoiceId = {0}", invoiceId);
                dr = SqlHelper.ExecuteReader(ConnectString, CommandType.Text, sql, null);

                SI si = new SI();

                if (dr.Read())
                {
                    int indexSIId = dr.GetOrdinal("SIId");
                    si.SIId = Convert.ToInt32(dr[indexSIId]);

                    int indexInvoiceId = dr.GetOrdinal("InvoiceId");
                    if (dr["InvoiceId"] != DBNull.Value)
                    {
                        si.InvoiceId = Convert.ToInt32(dr[indexInvoiceId]);
                    }

                    int indexChangeCurrencyId = dr.GetOrdinal("ChangeCurrencyId");
                    if (dr["ChangeCurrencyId"] != DBNull.Value)
                    {
                        si.ChangeCurrencyId = Convert.ToInt32(dr[indexChangeCurrencyId]);
                    }

                    int indexChangeRate = dr.GetOrdinal("ChangeRate");
                    if (dr["ChangeRate"] != DBNull.Value)
                    {
                        si.ChangeRate = Convert.ToDecimal(dr[indexChangeRate]);
                    }

                    int indexChangeBala = dr.GetOrdinal("ChangeBala");
                    if (dr["ChangeBala"] != DBNull.Value)
                    {
                        si.ChangeBala = Convert.ToDecimal(dr[indexChangeBala]);
                    }

                    int indexPayDept = dr.GetOrdinal("PayDept");
                    if (dr["PayDept"] != DBNull.Value)
                    {
                        si.PayDept = Convert.ToInt32(dr[indexPayDept]);
                    }

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = si;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
Exemplo n.º 2
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            SI si = new SI();

            int indexSIId = dr.GetOrdinal("SIId");
            si.SIId = Convert.ToInt32(dr[indexSIId]);

            int indexInvoiceId = dr.GetOrdinal("InvoiceId");
            if (dr["InvoiceId"] != DBNull.Value)
            {
                si.InvoiceId = Convert.ToInt32(dr[indexInvoiceId]);
            }

            int indexChangeCurrencyId = dr.GetOrdinal("ChangeCurrencyId");
            if (dr["ChangeCurrencyId"] != DBNull.Value)
            {
                si.ChangeCurrencyId = Convert.ToInt32(dr[indexChangeCurrencyId]);
            }

            int indexChangeRate = dr.GetOrdinal("ChangeRate");
            if (dr["ChangeRate"] != DBNull.Value)
            {
                si.ChangeRate = Convert.ToDecimal(dr[indexChangeRate]);
            }

            int indexChangeBala = dr.GetOrdinal("ChangeBala");
            if (dr["ChangeBala"] != DBNull.Value)
            {
                si.ChangeBala = Convert.ToDecimal(dr[indexChangeBala]);
            }

            int indexPayDept = dr.GetOrdinal("PayDept");
            if (dr["PayDept"] != DBNull.Value)
            {
                si.PayDept = Convert.ToInt32(dr[indexPayDept]);
            }

            return si;
        }