Пример #1
0
        /// <summary>아이템 타입별 수량 조회</summary>
        public List<BmItemQuantity> GetItemQuantityList(BmItemQuantity pDataRq)
        {
            try
            {
                #region SetQuery

                StringBuilder sbQuery = new StringBuilder("SELECT * FROM tbItemQuantity WHERE 1=1");

                if (pDataRq.Seq > 0)
                    sbQuery.AppendLine(" AND Seq = @Seq");
                if (pDataRq.ItemSeq > 0)
                    sbQuery.AppendLine(" AND ItemSeq = @ItemSeq");
                if (!string.IsNullOrEmpty(pDataRq.Type))
                    sbQuery.AppendLine(" AND Type = @Type");

                sbQuery.AppendLine(" ORDER BY ItemSeq, RegDt");

                #endregion SetQuery

                List<BmItemQuantity> result = new List<BmItemQuantity>();
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = sbQuery.ToString();

                #region Set Parameters

                if (pDataRq.Seq > 0)
                    cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;
                if (pDataRq.ItemSeq > 0)
                    cmd.Parameters.Add("@ItemSeq", SqlDbType.Int, 0).Value = pDataRq.ItemSeq;
                if (!string.IsNullOrEmpty(pDataRq.Type))
                    cmd.Parameters.Add("@Type", SqlDbType.VarChar, 100).Value = pDataRq.Type;

                #endregion Set Parameters

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    DataTable dt = new DataTable();

                    dt.Load(reader);
                    result = ConvertToBmItemQuantity(dt);
                }

                reader.Dispose();
                cmd.Dispose();

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>상품 수량 수정</summary>
        public bool UpdateItemQuantity(BmItemQuantity pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            var result = dac.UpdateItemQuantity(pDataRq);

                            scope.Complete();
                            return result;
                        }
                        catch (Exception ex)
                        {

                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                return false;
            }
        }
Пример #3
0
        /// <summary>아이템 타입별 수량 삭제</summary> 로그 등록 필요
        public bool DeleteItemQuantity(BmItemQuantity pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"DELETE tbItemQuantity WHERE Seq = @Seq";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;

                #endregion Set Parameters

                result = cmd.ExecuteNonQuery();

                cmd.Dispose();

                if (result == 1)
                {
                    WriteHistory(pDataRq, HistoryCommandType.DELETE);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        /// <summary>아이템 타입별 수량 Convert DataTable -> BmItemQuantity</summary>
        private List<BmItemQuantity> ConvertToBmItemQuantity(DataTable dt)
        {
            List<BmItemQuantity> list = new List<BmItemQuantity>();

            foreach (DataRow dr in dt.Rows)
            {
                BmItemQuantity data = new BmItemQuantity();

                data.Seq = (int)dr["Seq"];
                data.ItemSeq = (int)dr["ItemSeq"];
                data.Type = dr["Type"].ToString();
                data.Quantity = (int)dr["Quantity"];
                data.SalesCount = (int)dr["SalesCount"];
                data.State = (int)dr["State"];
                data.Registrant = dr["Registrant"].ToString();
                data.RegDt = (DateTime)dr["RegDt"];
                data.Modifyer = dr["Modifyer"].ToString();
                data.ModifyDt = string.IsNullOrEmpty(dr["ModifyDt"].ToString()) ? null : (DateTime?)dr["ModifyDt"];

                list.Add(data);
            }

            return list;
        }
Пример #5
0
        /// <summary>아이템 타입별 수량 수정</summary>
        public bool UpdateItemQuantity(BmItemQuantity pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"UPDATE tbItemQuantity SET
                                        Type = @Type,
                                        Quantity = @Quantity,
                                        SalesCount = @SalesCount,
                                        State = @State,
                                        Modifyer = @Modifyer,
                                        ModifyDt = dbo.getkordate()
                                    WHERE
                                        Seq = @Seq";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@Type", SqlDbType.VarChar, 100).Value = pDataRq.Type;
                cmd.Parameters.Add("@Quantity", SqlDbType.Int, 0).Value = pDataRq.Quantity;
                cmd.Parameters.Add("@SalesCount", SqlDbType.Int, 0).Value = pDataRq.SalesCount;
                cmd.Parameters.Add("@State", SqlDbType.Int, 0).Value = pDataRq.State;
                cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;
                cmd.Parameters.Add("@Modifyer", SqlDbType.VarChar, 20).Value = pDataRq.Modifyer;

                #endregion Set Parameters

                result = cmd.ExecuteNonQuery();

                cmd.Dispose();

                if (result == 1)
                {
                    WriteHistory(pDataRq, HistoryCommandType.UPDATE);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        /// <summary>아이템 타입별 수량 등록</summary>
        public bool InsertItemQuantity(BmItemQuantity pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"INSERT INTO tbItemQuantity
                                        (ItemSeq
                                        , Type
                                        , Quantity
                                        , SalesCount
                                        , State
                                        , Registrant
                                        )
                                    Values
                                        (@ItemSeq
                                        , @Type
                                        , @Quantity
                                        , @SalesCount
                                        , @State
                                        , @Registrant)
                                    SELECT @@Identity";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@ItemSeq", SqlDbType.Int, 0).Value = pDataRq.ItemSeq;
                cmd.Parameters.Add("@Type", SqlDbType.VarChar, 100).Value = pDataRq.Type;
                cmd.Parameters.Add("@Quantity", SqlDbType.Int, 0).Value = pDataRq.Quantity;
                cmd.Parameters.Add("@SalesCount", SqlDbType.Int, 0).Value = pDataRq.SalesCount;
                cmd.Parameters.Add("@State", SqlDbType.Int, 0).Value = pDataRq.State;
                cmd.Parameters.Add("@Registrant", SqlDbType.VarChar, 20).Value = pDataRq.Registrant;

                #endregion Set Parameters

                result = Convert.ToInt32(cmd.ExecuteScalar());

                cmd.Dispose();

                if (result > 0)
                {
                    pDataRq.Seq = result;
                    WriteHistory(pDataRq, HistoryCommandType.INSERT);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #7
0
 public BmItemQuantityPagingRq()
 {
     Item = new BmItemQuantity();
     Paging = new BmPaging();
 }