コード例 #1
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            if (txtID.Text == "" || txtID.Text == "Nueva")
            {
                MessageBox.Show("Para imprimir debe guardar la cotización.", "Verifique", MessageBox.Botones.Aceptar);
                return;
            }

            List <QuotationProduct> quotationProducts = new List <QuotationProduct>();

            foreach (CotizacionesDS.ProductosDTRow row in cotizacionesDS.ProductosDT)
            {
                QuotationProduct quotationProduct = new QuotationProduct();
                Product          product          = new Product();
                product.name = row.descripcion;
                quotationProduct.quantity = row.cantidad;
                quotationProduct.price    = row.precio;
                quotationProduct.Product  = product;
                quotationProducts.Add(quotationProduct);
            }


            string rutaPlantilla = AppDomain.CurrentDomain.BaseDirectory + "Plantillas\\Cotizacion.html";
            string rutaHTML      = AppDomain.CurrentDomain.BaseDirectory + "Documentos\\plantilla.html";
            string rutaPDF       = AppDomain.CurrentDomain.BaseDirectory + "Documentos\\Cotizacion.pdf";

            Directory.CreateDirectory(Path.GetDirectoryName(rutaPlantilla));
            Directory.CreateDirectory(Path.GetDirectoryName(rutaHTML));
            Directory.CreateDirectory(Path.GetDirectoryName(rutaPDF));

            Document.GenerarHTMLDesdePlantilla(rutaPlantilla, rutaHTML, Client, quotationProducts, decimal.Parse(txtTotal.Text));

            Document.GenerarPDFDesdeHTML(rutaHTML, rutaPDF);

            Process.Start(rutaPDF);

            int i = 1;

            foreach (CotizacionesDS.DocumentosDTRow row in cotizacionesDS.DocumentosDT)
            {
                string ruta = AppDomain.CurrentDomain.BaseDirectory + @"Documentos\\Documento" + i + ".pdf";
                Directory.CreateDirectory(Path.GetDirectoryName(ruta));
                File.WriteAllBytes(ruta, row.Document);
                Process.Start(ruta);
                i++;
            }
        }
コード例 #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Trim() == "")
            {
                MessageBox.Show("Escriba la descripción.", "Verifique", MessageBox.Botones.Aceptar);
                return;
            }
            if (cotizacionesDS.ProductosDT.Rows.Count == 0)
            {
                MessageBox.Show("Debe capturar al menos un producto", "Verifique", MessageBox.Botones.Aceptar);
                return;
            }
            if (Client == null)
            {
                MessageBox.Show("Capture el cliente", "Verifique", MessageBox.Botones.Aceptar);
                return;
            }
            if ((txtID.Text.Trim() == "" || txtID.Text == "Nueva"))
            {
                Quotation quotation = new Quotation();
                quotation.name     = txtNombre.Text.Trim();
                quotation.idClient = Client.idClient;
                quotation.sold     = chkVendida.Checked;
                quotation.active   = chkActivo.Checked;
                quotation.total    = decimal.Parse(txtTotal.Text);

                foreach (CotizacionesDS.ProductosDTRow row in cotizacionesDS.ProductosDT)
                {
                    QuotationProduct quotationProduct = new QuotationProduct();
                    quotationProduct.price     = row.precio;
                    quotationProduct.idProduct = row.idProducto;
                    quotationProduct.row       = row.renglon;
                    quotationProduct.quantity  = row.cantidad;
                    quotation.QuotationsProducts.Add(quotationProduct);
                }

                foreach (CotizacionesDS.DocumentosDTRow row in cotizacionesDS.DocumentosDT)
                {
                    Quotations.AgregarDocumento(ref quotation, row);
                }

                Quotations.CrearCotizacion(quotation);

                MessageBox.Show("Cotización creada correctamente.", "Usuario", MessageBox.Botones.Aceptar);
                Limpiar();
            }
            else
            {
                int id = 0;
                if (int.TryParse(txtID.Text.Trim(), out id) && id != 0)
                {
                    Quotation quotation = new Quotation();
                    quotation.id     = id;
                    quotation.sold   = chkVendida.Checked;
                    quotation.active = chkActivo.Checked;
                    Quotations.ActualizarCotizacion(quotation);
                    MessageBox.Show("Cotización Actualizada correctamente.", "Usuario", MessageBox.Botones.Aceptar);
                    Limpiar();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加 报价订单
        /// </summary>
        /// <param name="userId">操作员id</param>
        /// <param name="orderId">关联的流程订单id</param>
        /// <param name="remarks">备注</param>
        /// <param name="QuotationUserId">操作员id</param>
        /// <param name="expireTime">过期时间</param>
        /// <param name="bProductDetailModel">关联的产品模型</param>
        /// <returns>响应消息</returns>
        public BReturnModel AddQuotationOrder(Guid orderId, string remarks, Guid QuotationUserId, DateTime expireTime, IList <BProductDetailModel> bProductDetailModel)
        {
            var isHave = baseDal.GetListQuery(item => item.OrderId == orderId).Count();

            if (isHave > 0)
            {
                return(BReturnModel.ReturnError("orderId流程订单已经存在 对应的报价订单 请勿重复提交"));
            }
            var userOrderModel = userOrderDal.GetItemById(orderId);

            if (userOrderModel == null)
            {
                return(BReturnModel.ReturnError("未查询到 对应的流程订单"));
            }
            QuotationOrder quotationOrder = new QuotationOrder()
            {
                Id              = Guid.NewGuid(),
                CreateTime      = DateTime.Now,
                ExpireTime      = expireTime,
                Remarks         = remarks,
                OrderId         = orderId,
                QuotationUserId = QuotationUserId,
                Flag            = (int)BusinessOrderFlag.Undetermined,
                UserId          = userOrderModel.UserId
            };

            baseDal.Add(quotationOrder);
            foreach (var item in bProductDetailModel)
            {
                QuotationProduct quotationProduct = new QuotationProduct()
                {
                    Id               = Guid.NewGuid(),
                    Manufactor       = item.Manufactor,
                    Specifications   = item.Specifications,
                    QuotationOrderId = quotationOrder.Id,
                    Price            = item.Price,
                    Remarks          = item.Remarks,
                    ProductName      = item.ProductName,
                };
                quotationProductDal.Add(quotationProduct);


                foreach (var itemImg in item.ImgUrl)
                {
                    QuotationProductImg quotationProductImg = new QuotationProductImg()
                    {
                        Id                 = Guid.NewGuid(),
                        ImgUrl             = itemImg,
                        QuotationProductId = quotationProduct.Id
                    };

                    quotationProductImgDal.Add(quotationProductImg);
                }
            }
            UserOrder userOrder = new UserOrder()
            {
                Id               = orderId,
                Flag             = (int)OrderStateFlag.Offer,
                CurrentStateTime = DateTime.Now
            };

            userOrderDal.UpdateItemSelect(userOrder, new string[] { UserOrderPropertiesConfig.Flag, UserOrderPropertiesConfig.CurrentStateTime });
            int count = DBContent.SaveChanges();

            if (count > 0)
            {
                return(BReturnModel.ReturnOk());
            }

            return(BReturnModel.ReturnError());
        }