Пример #1
0
 private void ProductName_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         CostPrice.Focus();
     }
 }
Пример #2
0
        public HttpResponseMessage GetCostPrices()
        {
            var costPrices = new CostPrice().CostPrice_GetAll();

            if (costPrices != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, costPrices));
            }
            return(Request.CreateResponse(HttpStatusCode.NoContent, costPrices));
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            PriceRepository priceRepository = new PriceRepository();
            CostPrice       cost            = new CostPrice();

            cost.ProdCd = txtProdCd.Text;
            cost.Old    = product1.Cp;
            cost.New    = Convert.ToDecimal(txtNewCost.Text);
            if (priceRepository.ChangeCP(cost))
            {
                MessageBox.Show("Cost price Update successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Error on Saving. Please Contact System Admin For more help.", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        public HttpResponseMessage PutCostPrice(CPMaster costPrice)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = new CostPrice().CostPrice_Update(costPrice);

                    if (result != null || result != "")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Пример #5
0
        public HttpResponseMessage DeleteCostPrice(int pid)
        {
            var result = new CostPrice().CostPrice_GetById(pid);

            if (result.PID == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent, result));
            }
            try
            {
                result.PID = new CostPrice().CostPrice_Delete(pid);
                if (result.PID != 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }
                return(Request.CreateResponse(HttpStatusCode.NoContent, result));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, result));
            }
        }
Пример #6
0
        private void PriceInit(int productId, int customerId, int companyId, int departmentId)
        {
            var context    = new USOEntities();
            int PRODUCT_ID = productId;
            //法人id为40的测试数据
            //const int ORGANIZATION_ID_BRANCHCOMPANY = 16;//成都分公司
            //const int ORGANIZATION_ID_DEPARTMENT = 18;//邛崃经营部
            //const int CUSTOMER_ID = 40;
            //const decimal COST_PRICE = 100;
            //const decimal ACCT_PRICE = 110;
            //const decimal REDLINE_PRICE_BRACHCOMPANY = 120;
            //const decimal REDLINE_PRICE_DEPARTMENT = 130;
            //const decimal CUSTOMER_PRICE = 140;

            //法人id为41的测试数据
            int           ORGANIZATION_ID_BRANCHCOMPANY = companyId;    //成都分公司
            int           ORGANIZATION_ID_DEPARTMENT    = departmentId; //邛崃经营部
            int           CUSTOMER_ID = customerId;
            const decimal COST_PRICE  = 100;
            const decimal ACCT_PRICE  = 110;
            const decimal REDLINE_PRICE_BRACHCOMPANY = 120;
            const decimal REDLINE_PRICE_DEPARTMENT   = 130;
            const decimal CUSTOMER_PRICE             = 140;


            var product = context.Product.FirstOrDefault(p => p.Id == PRODUCT_ID);

            Assert.IsNotNull(product);

            var organizationBranchCompay =
                context.Organizations.FirstOrDefault(o => o.Id == ORGANIZATION_ID_BRANCHCOMPANY);

            Assert.IsNotNull(organizationBranchCompay);

            var organizationDepartment =
                context.Organizations.FirstOrDefault(o => o.Id == ORGANIZATION_ID_DEPARTMENT);

            Assert.IsNotNull(organizationDepartment);

            var costPrice = context.CostPrices.FirstOrDefault(c => c.ProductId == PRODUCT_ID);

            if (costPrice != null)
            {
                context.CostPrices.Attach(costPrice);
                costPrice.StandardCostCurrentMonth = COST_PRICE;
            }
            else
            {
                costPrice = new CostPrice()
                {
                    ProductId = PRODUCT_ID,
                    StandardCostCurrentMonth = COST_PRICE,
                    BusinessTime             = DateTime.UtcNow
                };
                context.CostPrices.Add(costPrice);
            }

            var redLinePriceBranchCompany = context.RedLinePrices.FirstOrDefault(r => r.ProductId == PRODUCT_ID && r.OrganizationId == ORGANIZATION_ID_BRANCHCOMPANY);
            var redLinePriceDepartment    = context.RedLinePrices.FirstOrDefault(r => r.ProductId == PRODUCT_ID && r.OrganizationId == ORGANIZATION_ID_DEPARTMENT);

            if (redLinePriceBranchCompany != null)
            {
                context.RedLinePrices.Attach(redLinePriceBranchCompany);
                redLinePriceBranchCompany.Price = REDLINE_PRICE_BRACHCOMPANY;
                redLinePriceBranchCompany.InternalAccountPrice = ACCT_PRICE;
            }
            else
            {
                redLinePriceBranchCompany = new RedLinePrice()
                {
                    ProductId            = PRODUCT_ID,
                    OrganizationId       = ORGANIZATION_ID_BRANCHCOMPANY,
                    InternalAccountPrice = ACCT_PRICE,
                    Price        = REDLINE_PRICE_BRACHCOMPANY,
                    BusinessTime = DateTime.UtcNow
                };
                context.RedLinePrices.Add(redLinePriceBranchCompany);
            }

            if (redLinePriceDepartment != null)
            {
                context.RedLinePrices.Attach(redLinePriceDepartment);
                redLinePriceDepartment.Price = REDLINE_PRICE_DEPARTMENT;
                redLinePriceDepartment.InternalAccountPrice = ACCT_PRICE;
            }
            else
            {
                redLinePriceDepartment = new RedLinePrice()
                {
                    ProductId            = PRODUCT_ID,
                    OrganizationId       = ORGANIZATION_ID_DEPARTMENT,
                    InternalAccountPrice = ACCT_PRICE,
                    Price        = REDLINE_PRICE_DEPARTMENT,
                    BusinessTime = DateTime.UtcNow
                };
                context.RedLinePrices.Add(redLinePriceDepartment);
            }

            var customerPrice = context.CustomerPricePolicies.FirstOrDefault(c => c.ProductId == PRODUCT_ID && c.OrganizationId == ORGANIZATION_ID_DEPARTMENT && c.CustomerType == CustomerType.CustomerId && c.TypeValue == customerId);

            if (customerPrice != null)
            {
                context.CustomerPricePolicies.Attach(customerPrice);
                customerPrice.Price = CUSTOMER_PRICE;
            }
            else
            {
                customerPrice = new CustomerPricePolicy()
                {
                    ProductId      = PRODUCT_ID,
                    OrganizationId = ORGANIZATION_ID_DEPARTMENT,
                    CustomerType   = CustomerType.CustomerId,
                    TypeValue      = CUSTOMER_ID,
                    Price          = CUSTOMER_PRICE,
                    EffectiveOn    = DateTime.UtcNow
                };
                context.CustomerPricePolicies.Add(customerPrice);
            }


            context.SaveChanges();
        }
Пример #7
0
        // GET: api/GetCostPrice/2
        public CPMaster GetCostPrice(int?Pid)
        {
            var costPrice = new CostPrice().CostPrice_GetById(Pid);

            return(costPrice);
        }