Exemple #1
0
 public bool AddProduct(ProductsDto productsDto)
 {
     var cn = new SqlConnection(GetConnection());
     SqlTransaction trx = null;
     var isInsert = false;
     try
     {
         cn.Open();
         trx = cn.BeginTransaction();
         string cmdText = " insert into Products(ProductName,ProductCategory,MemberAnaylst,OrganizationName,TenureId,StyleResearchId,StrategyId,FrequencyCall,FrequencyCallType,Logo,CreateUserId,CreateTimeStamp,ModifiedUserId,ModifiedTimeStamp) " +
                          "values('" + productsDto.ProductName + "'," + productsDto.ProductCategory + "," + productsDto.MemberAnaylst + ",'" + productsDto.OrganizationName + "'," + productsDto.TenureId + "," + productsDto.StyleResearchId + "," + productsDto.StrategyId + "," + productsDto.FrequencyCall + ",'" + productsDto.FrequencyCallType + "','" + productsDto.Logo + "'," + productsDto.CreateUserId + ", '" + DateTime.Now.ToString("yyyy-MM-dd") + "'," + productsDto.ModifiedUserId + ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "') select Scope_Identity();";
         var cmd = new SqlCommand(cmdText, cn) { Transaction = trx };
         var productId = Convert.ToInt32(cmd.ExecuteScalar());
         foreach (var documents in productsDto.ProductDocumentDtos)
             (new SqlCommand("insert into ProductDocument(ProductId,FileName,DocumentName) values( " + productId + ",'" + documents.FileName + "','" + documents.DocumentName + "')", cn) { Transaction = trx }).ExecuteNonQuery();
         trx.Commit();
         isInsert = true;
         cn.Close();
     }
     catch (Exception)
     {
         if (trx != null) trx.Rollback();
         cn.Close();
     }
     return isInsert;
 }
Exemple #2
0
 public bool UpdateProduct(ProductsDto productsDto)
 {
     var cn = new SqlConnection(GetConnection());
     SqlTransaction trx = null;
     var isUpdate = false;
     try
     {
         cn.Open();
         trx = cn.BeginTransaction();
         string cmdText = " update Products set ProductName='" + productsDto.ProductName + "',ProductCategory=" +
                          productsDto.ProductCategory + ",MemberAnaylst=" + productsDto.MemberAnaylst +
                          ",OrganizationName='" + productsDto.OrganizationName + "',TenureId=" +
                          productsDto.TenureId + ",StyleResearchId=" + productsDto.StyleResearchId +
                          ",StrategyId=" + productsDto.StrategyId + ",FrequencyCall=" + productsDto.FrequencyCall +
                          ",FrequencyCallType='" + productsDto.FrequencyCallType + "',ModifiedUserId=" +
                          productsDto.ModifiedUserId + ",ModifiedTimeStamp='" +
                          DateTime.Now.ToString("yyyy-MM-dd") + "'  where ProductId=" + productsDto.ProductId;
         var cmd = new SqlCommand(cmdText, cn) { Transaction = trx };
         cmd.ExecuteNonQuery();
         foreach (var documents in productsDto.ProductDocumentDtos)
             (new SqlCommand("insert into ProductDocument(ProductId,FileName,DocumentName) values( " + productsDto.ProductId + ",'" + documents.FileName + "','" + documents.DocumentName + "')", cn) { Transaction = trx }).ExecuteNonQuery();
         trx.Commit();
         isUpdate = true;
         cn.Close();
     }
     catch (Exception)
     {
         if (trx != null) trx.Rollback();
         cn.Close();
     }
     return isUpdate;
 }
Exemple #3
0
        public ProductsDto GetProductByPoductId(int productId)
        {
            var cn = new SqlConnection(GetConnection());
            var product = new ProductsDto();
            try
            {
                cn.Open();
                string cmdText = "select * from Products where ProductId=" + productId;
                var cmd = new SqlCommand(cmdText, cn);
                var dr = cmd.ExecuteReader();
                while (dr.Read())
                {

                    product.ProductId = Convert.ToInt32(dr["ProductId"]);
                    product.ProductName = Convert.ToString(dr["ProductName"]);
                    product.ProductCategory = dr.IsDBNull(2) ? 0 : Convert.ToInt32(dr["ProductCategory"]);
                    product.MemberAnaylst = dr.IsDBNull(3) ? 0 : Convert.ToInt32(dr["MemberAnaylst"]);
                    product.OrganizationName = Convert.ToString(dr["OrganizationName"]);
                    product.TenureId = dr.IsDBNull(5) ? 0 : Convert.ToInt32(dr["TenureId"]);
                    product.StyleResearchId = dr.IsDBNull(6) ? 0 : Convert.ToInt32(dr["StyleResearchId"]);
                    product.StrategyId = dr.IsDBNull(7) ? 0 : Convert.ToInt32(dr["StrategyId"]);
                    product.FrequencyCall = dr.IsDBNull(8) ? 0 : Convert.ToInt32(dr["FrequencyCall"]);
                    product.FrequencyCallType = Convert.ToString(dr["FrequencyCallType"]);
                }
                cn.Close();
            }
            catch (Exception)
            {
                cn.Close();
            }
            return product;
        }
Exemple #4
0
 public bool AddProduct(ProductsDto productsDto)
 {
     return _iMemberRepository.AddProduct(productsDto);
 }
Exemple #5
0
 public bool UpdateProduct(ProductsDto productsDto)
 {
     return _iMemberRepository.UpdateProduct(productsDto);
 }
 public bool AddProduct(ProductsDto productsDto)
 {
     return _iMemberHelper.AddProduct(productsDto);
 }
 public bool UpdateProduct(ProductsDto productsDto)
 {
     return _iMemberHelper.UpdateProduct(productsDto);
 }