Ejemplo n.º 1
0
 public static void Import(BuyImportinvoiceContract importInvoiceDTO, BuyImportinvoiceDetailContract invoiceDetailDTO, SqlTransaction tran)
 {
     try
     {
         CatProductStoreContract productStoreDTO = new CatProductStoreContract();
         productStoreDTO.Importcode = importInvoiceDTO.Code;
         productStoreDTO.Importdate = importInvoiceDTO.Createdate;
         productStoreDTO.Storeid    = importInvoiceDTO.CatStoreid;
         productStoreDTO.Productid  = invoiceDetailDTO.Productid;
         productStoreDTO.Inventory  = invoiceDetailDTO.Quantity;
         productStoreDTO.Quantity   = invoiceDetailDTO.Quantity;
         productStoreDTO.Price      = invoiceDetailDTO.Price;
         productStoreDTO.Ordernum   = invoiceDetailDTO.Importinvoiceid.ToString();
         productStoreDT.Insert(productStoreDTO, tran);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 2
0
        public HttpResponseMessage Save(string catproductstoreJson)
        {
            string errMessage = string.Empty;

            try
            { CatProductStoreContract catproductstore = JsonConvert.DeserializeObject <CatProductStoreContract>(catproductstoreJson);
              businessRule.RegistInstants(catproductstore);
              if (catproductstore.Id == 0)
              {
                  businessRule.RegistRule("Insert");
                  if (businessRule.CheckRules(out errMessage))
                  {
                      return(Request.CreateResponse <string>(HttpStatusCode.OK, dta.Insert(catproductstore)));
                  }
                  else
                  {
                      return(handleBRFailed(errMessage));
                  }
              }
              else
              {
                  businessRule.RegistRule("Update");
                  if (businessRule.CheckRules(out errMessage))
                  {
                      return(Request.CreateResponse <string>(HttpStatusCode.OK, dta.Update(catproductstore)));
                  }
                  else
                  {
                      return(handleBRFailed(errMessage));
                  }
              } }
            catch (Exception e)
            {
                ExceptionHandler.Log(e);
                return(Request.CreateResponse <string>(HttpStatusCode.OK, "Có lỗi xảy ra trên chương trình."));
            }
        }