public bool Remove(CustomsClearence data)
        {
            SqlConnection oConn = null;

            try
            {
                oConn = ConnManager.OpenConn();
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            };

            bool result;

            try
            {
                result = Remove(data, oConn);
            }
            catch (Exception ex)
            {
                ConnManager.CloseConn(oConn);
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            }

            ConnManager.CloseConn(oConn);

            return(result);
        }
示例#2
0
        private void InsertCustomClearence(QuoteHeader quote, SqlConnection oConn)
        {
            try
            {
                CustomsClearence cc = new CustomsClearence();
                cc.CClearenceCreatedBy    = quote.QHeaderModifiedBy ?? quote.QHeaderCreatedBy;
                cc.CClearenceCreatedDate  = DateTime.Now;
                cc.CClearenceCurrencyCode = "USD";
                cc.CClearenceCurrencyRate = quote.QHeaderCurrencyRate;
                cc.CClearenceDate         = quote.QHeaderCreatedDate;
                cc.CClearenceMode         = 0;
                cc.QHeaderId = quote.QHeaderId;

                string sql = "INSERT INTO CustomsClearence ({0}) VALUES ({1}) " +
                             "SELECT SCOPE_IDENTITY()";

                EnumExtension.setListValues(cc, "CClearenceId", ref sql);

                SqlCommand cmd = new SqlCommand(sql, oConn);

                int keyGenerated = 0;
                keyGenerated = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            }
        }
        public CustomsClearence GetByQuote(int quoteId, int mode = 0)
        {
            SqlConnection oConn = null;

            try
            {
                oConn = ConnManager.OpenConn();
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            };

            CustomsClearence data = GetByQuote(quoteId, mode, oConn);

            ConnManager.CloseConn(oConn);

            return(data);
        }
        private bool Remove(CustomsClearence data, SqlConnection oConn)
        {
            string sql = "DELETE FROM CustomsClearence " +
                         " WHERE (CClearenceId = @id)";

            sql = String.Format(sql, data.CClearenceId);

            SqlCommand cmd = new SqlCommand(sql, oConn);

            cmd.Parameters.Add("@id", SqlDbType.Int).Value = data.CClearenceId;

            int number = Convert.ToInt32(cmd.ExecuteNonQuery());

            if (number > 0)
            {
                return(true);
            }

            return(false);
        }
        public CustomsClearence Add(CustomsClearence data)
        {
            SqlConnection oConn = null;

            try
            {
                oConn = ConnManager.OpenConn();
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            };

            string sql = "INSERT INTO CustomsClearence ({0}) VALUES ({1}) " +
                         "SELECT SCOPE_IDENTITY()";

            EnumExtension.setListValues(data, "CClearenceId", ref sql);

            SqlCommand cmd = new SqlCommand(sql, oConn);

            int keyGenerated = 0;

            try
            {
                keyGenerated = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                ConnManager.CloseConn(oConn);
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            }

            CustomsClearence returnData = Get(keyGenerated, oConn);

            ConnManager.CloseConn(oConn);

            return(returnData);
        }
        public CustomsClearence Update(CustomsClearence data)
        {
            SqlConnection oConn = null;

            try
            {
                oConn = ConnManager.OpenConn();
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            };

            string sql = "UPDATE CustomsClearence SET {0} WHERE CClearenceId = @id";

            EnumExtension.setUpdateValues(data, "CClearenceId", ref sql);

            SqlCommand cmd = new SqlCommand(sql, oConn);

            cmd.Parameters.Add("@id", SqlDbType.Int).Value = data.CClearenceId;

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ConnManager.CloseConn(oConn);
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);
                throw;
            }

            CustomsClearence returnData = Get(data.CClearenceId, oConn);

            ConnManager.CloseConn(oConn);

            return(returnData);
        }