Пример #1
0
        public async Task <OperationDetails> Create(OperatorDto operatorDto)
        {
            var _operator = await this._auow.OperatorManager.FindByEmailAsync(operatorDto.Email);

            if (_operator == null)
            {
                _operator = new ApplicationOperator {
                    Email = operatorDto.Email, UserName = operatorDto.Email
                };
                var _result = await this._auow.OperatorManager.CreateAsync(_operator, operatorDto.Password);

                if (_result.Errors.Count() > 0)
                {
                    return(new OperationDetails(false, _result.Errors.FirstOrDefault(), ""));
                }
                await this._auow.OperatorManager.AddToRoleAsync(_operator.Id, operatorDto.Role);

                await this._auow.SaveAsync();

                return(new OperationDetails(true, "Successfull registration", ""));
            }
            else
            {
                return(new OperationDetails(false, "Email is not unique", "Email"));
            }
        }
Пример #2
0
        public async Task <ActionResult> Registration(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationOperator {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #3
0
 void ReloadPriceCalculationSetting(bool refresh)
 {
     //load module settings
     if (refresh)
     {
         _PriceCalculationSetting = ApplicationOperator.GetPriceCalculationSetting();
     }
 }
Пример #4
0
        public void CreateInvoice(Order order)
        {
            if (order.OrderDetailDt == null)
            {
                return;
            }

            currentOrder = order;

            if (currentOrder == null)
            {
                return;
            }

            CreateDocument();
            document.UseCmykColor = true;

#if DEBUG
            // for debugging only...
            MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
            //document = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromFile("MigraDoc.mdddl");
#endif

            const bool             unicode   = true;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // Create a renderer for PDF that uses Unicode font encoding
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            // Save the PDF document...
            //string filename = "Invoice.pdf";
            //string filename = string.Format("Invoice - {0}-{1} - {2}.pdf",
            //    currentOrder.OrderDate.ToString("yyyy.MM.dd"), DateTime.Now.ToString("HH.mm.ss"), currentOrder.OrderID.ToString().ToUpper());

            string filename = string.Format("{0}.pdf", currentOrder.GetReportName());

#if DEBUG
            // I don't want to close the document constantly...
            //filename = "Invoice-" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf";
            //filename = string.Format("Invoice - {0}-{1} - {2}.pdf",
            //    currentOrder.OrderDate.ToString("yyyy.MM.dd"), DateTime.Now.ToString("HH.mm.ss"), currentOrder.OrderID.ToString().ToUpper());

            filename = string.Format("{0}.pdf", currentOrder.GetReportName());
#endif

            filename = string.Format("{0}\\{1}", ApplicationOperator.GetGeneralSetting().ReportPathSetting.ReportPath, filename);
            pdfRenderer.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SetValues();
            ApplicationOperator.SavePriceCalculationSetting(_Setting);

            if (SettingSaveChanged != null)
            {
                SettingSaveChanged();
            }
        }
Пример #6
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            wirMatrixGridComponent.Save();
            commissionInfoComponent.Save();
            ApplicationOperator.SaveGeneralSetting(generalSetting);

            if (SettingSaveChanged != null)
            {
                SettingSaveChanged();
            }
        }
Пример #7
0
        private void saveOrderSimpleButton_Click(object sender, EventArgs e)
        {
            if (dxValidationProvider.Validate())
            {
                SaveOrder();
                ApplicationOperator.SaveGeneralSetting(generalSetting);
                allowIncreaseCounter = true;

                if (SavedCalculation != null)
                {
                    SavedCalculation(Order);
                }
            }
        }
Пример #8
0
        public ApplicationOperator GetDoctorDetails(string userId)
        {
            ApplicationOperator applicationOperator = null;

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Configuration.ProxyCreationEnabled = true;
                ctx.Configuration.LazyLoadingEnabled   = true;
                applicationOperator = ctx.Users.Include(x => x.ApplicationClients).Include(x => x.Professtionals).FirstOrDefault(x => x.Id == userId);
                // applicationOperator = ctx.Users.FirstOrDefault(x => x.Id ==  userId);
                //applicationOperator.ApplicationClients = new ApplicationClient();
                //applicationOperator.ApplicationClients = ctx.ApplicationClients.Find(applicationOperator.Id);
            }

            return(applicationOperator);
        }
Пример #9
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            //if (ModelState.IsValid)
            //{

            // Note: For two factor authentication
            //var applicationOperator = new ApplicationOperator { UserName = model.UserName,  Email = model.Email, TwoFactorEnabled = true, EmailConfirmed = true, PhoneNumberConfirmed = true, PhoneNumber = ("+91" + model.PhoneNumber), IsActive = true, CreatedOn = DateTime.Now, RoleCD = model.RoleCD };

            var applicationOperator = new ApplicationOperator {
                UserName    = model.UserName,
                Email       = model.Email, TwoFactorEnabled = false, EmailConfirmed = true, PhoneNumberConfirmed = false,
                PhoneNumber = ("+91" + model.PhoneNumber), IsActive = true, CreatedOn = DateTime.Now, RoleCD = model.RoleCD
            };

            applicationOperator.ApplicationClients                  = new ApplicationClient();
            applicationOperator.ApplicationClients.OperatorId       = applicationOperator.Id;
            applicationOperator.ApplicationClients.ParentOperatorId = applicationOperator.Id;

            applicationOperator.Professtionals            = new Professtional();
            applicationOperator.Professtionals.OperatorId = applicationOperator.Id;

            var result = await UserManager.CreateAsync(applicationOperator, model.Password);

            if (result.Succeeded)
            {
                await SignInManager.SignInAsync(applicationOperator, isPersistent : false, rememberBrowser : false);

                // var signInStatus = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, true, true);

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                return(Json(new { result = result }, JsonRequestBehavior.AllowGet));
            }
            AddErrors(result);
            //}

            // If we got this far, something failed, redisplay form
            return(Json(new { result = result }, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
        public bool SaveDoctorProfile(DoctorProfileModel doctorProfileModel, string userId)
        {
            ApplicationOperator applicationOperator = null;

            using (var ctx = new ApplicationDbContext())
            {
                // applicationOperator = GetDoctorDetails(userId);

                ctx.Configuration.ProxyCreationEnabled = true;
                ctx.Configuration.LazyLoadingEnabled   = true;
                applicationOperator             = ctx.Users.Include(x => x.ApplicationClients).Include(x => x.Professtionals).FirstOrDefault(x => x.Id == userId);
                applicationOperator.PhoneNumber = doctorProfileModel.PhoneNumber;
                if (applicationOperator.ApplicationClients != null)
                {
                    applicationOperator.ApplicationClients.FirstName = doctorProfileModel.FirstName;
                    applicationOperator.ApplicationClients.LastName  = doctorProfileModel.LastName;
                }
                ctx.Entry(applicationOperator).CurrentValues.SetValues(applicationOperator);
                ctx.SaveChanges();
            }
            return(true);
        }
Пример #11
0
        public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Manage"));
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();

                if (info == null)
                {
                    return(View("ExternalLoginFailure"));
                }
                var user = new ApplicationOperator {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id.ToString(), info.Login);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                        return(RedirectToLocal(returnUrl));
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return(View(model));
        }
Пример #12
0
 public SettingControl()
 {
     InitializeComponent();
     generalSetting = ApplicationOperator.GetGeneralSetting();
 }
Пример #13
0
 void ReloadSetting()
 {
     generalSetting = ApplicationOperator.GetGeneralSetting();
 }
Пример #14
0
 public SettingCtrl()
 {
     InitializeComponent();
     _Setting = ApplicationOperator.GetPriceCalculationSetting();
 }
Пример #15
0
        void CreateCalculationSection()
        {
            // Each MigraDoc document needs at least one section.
            //Section section = this.document.AddSection();
            reportSection = this.document.AddSection();

            //// Put a logo in the header
            //Image image = section.Headers.Primary.AddImage("../../PowerBooks.png");
            //image.Height = "2.5cm";
            //image.LockAspectRatio = true;
            //image.RelativeVertical = RelativeVertical.Line;
            //image.RelativeHorizontal = RelativeHorizontal.Margin;
            //image.Top = ShapePosition.Top;
            //image.Left = ShapePosition.Right;
            //image.WrapFormat.Style = WrapStyle.Through;

            // Create footer
            //Paragraph paragraph = section.Footers.Primary.AddParagraph();
            //paragraph.AddText("PowerBooks Inc ท Sample Street 42 ท 56789 Cologne ท Germany");
            //paragraph.Format.Font.Size = 9;
            //paragraph.Format.Alignment = ParagraphAlignment.Center;

            //// Create the text frame for the address
            //this.addressFrame = section.AddTextFrame();
            //this.addressFrame.Height = "3.0cm";
            //this.addressFrame.Width = "7.0cm";
            //this.addressFrame.Left = ShapePosition.Left;
            //this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            //this.addressFrame.Top = "2.5cm";
            //this.addressFrame.RelativeVertical = RelativeVertical.Page;

            //// Put sender in address frame
            //Paragraph paragraph = this.addressFrame.AddParagraph();

            Paragraph paragraph = null;


            paragraph = reportSection.Headers.Primary.AddParagraph();
            paragraph.AddText(string.Format("Kalkulation {0}", currentOrder.OrderNumber));
            paragraph.Format.Font.Size = 15;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            paragraph = reportSection.AddParagraph();
            paragraph.AddText(currentOrder.OrderDate);
            paragraph.AddLineBreak();
            paragraph.AddText(string.Format("{0} {1}", currentOrder.CustomerName, currentOrder.CustomerSurname));
            paragraph.AddLineBreak();
            paragraph.AddText(currentOrder.CustomerAddress);
            paragraph.AddLineBreak();
            paragraph.AddText(string.Format("{0} {1}", currentOrder.CustomerZipcode, currentOrder.CustomerPlace));
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Left;


            ////Create the text frame for the order information.
            //TextFrame orderInfoFrame = section.AddTextFrame();
            //orderInfoFrame.Height = "3.0cm";
            //orderInfoFrame.Width = "10.0cm";
            //orderInfoFrame.Left = ShapePosition.Left;
            //orderInfoFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            //orderInfoFrame.Top = "5cm";
            //orderInfoFrame.RelativeVertical = RelativeVertical.Page;

            //// Put sender in address frame
            decimal quantityL = currentOrder.OilQuantity / ApplicationOperator.GetGeneralSetting().OilPriceSetting.DensityOfHeatOil;

            paragraph = reportSection.AddParagraph();
            paragraph.Format.SpaceBefore = "1cm";
            paragraph.AddText(string.Format("{0}   {1:n0} Kg / {2:n0} L", currentOrder.OilQualityName, currentOrder.OilQuantity, quantityL));
            paragraph.AddLineBreak();
            paragraph.AddText(string.Format("Einkaufspreis   {0:n2} CHF", currentOrder.OilPrice));
            paragraph.AddLineBreak();
            decimal oilFactorPrice = currentOrder.OilPrice * currentOrder.WIRFactor;

            paragraph.AddText(string.Format("Preis per 100 Kg ({0:n2} x {1:n2})   {2:n2} CHF", currentOrder.OilPrice, currentOrder.WIRFactor, oilFactorPrice));
            paragraph.Format.Font.Size = 8;
            paragraph.Format.Alignment = ParagraphAlignment.Left;

            //// Put sender in address frame
            //paragraph = this.addressFrame.AddParagraph("PowerBooks Inc ท Sample Street 42 ท 56789 Cologne");
            //paragraph.Format.Font.Name = "Times New Roman";
            //paragraph.Format.Font.Size = 7;
            //paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            paragraph = reportSection.AddParagraph();
            paragraph.Format.SpaceBefore = "0.5cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText("Kalkulation", TextFormat.Bold);
            //paragraph.AddTab();
            //paragraph.AddText("Cologne, ");
            //paragraph.AddDateField("dd.MM.yyyy");

            //paragraph = section.AddParagraph();
            //paragraph.Format.SpaceBefore = "2cm";

            DataRow[] orderItems       = null;
            Table     orderDetailTable = null;
            Row       headerRow        = null;

            for (int i = 1; i <= currentOrder.UnloadPlaceNumber; i++)
            {
                //paragraph = section.AddParagraph();
                //paragraph.Format.SpaceBefore = "2cm";

                // Create the item table
                orderDetailTable                     = reportSection.AddTable();
                orderDetailTable.Style               = "Table";
                orderDetailTable.Borders.Color       = TableBorder;
                orderDetailTable.Borders.Width       = 0.25;
                orderDetailTable.Borders.Left.Width  = 0.5;
                orderDetailTable.Borders.Right.Width = 0.5;
                orderDetailTable.Rows.LeftIndent     = 0;

                // Before you can add a row, you must define the columns
                Column column = orderDetailTable.AddColumn("1cm");
                column.Format.Alignment = ParagraphAlignment.Center;

                column = orderDetailTable.AddColumn("10cm");
                column.Format.Alignment = ParagraphAlignment.Left;

                column = orderDetailTable.AddColumn("2.5cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                column = orderDetailTable.AddColumn("2.5cm");
                column.Format.Alignment = ParagraphAlignment.Right;

                // Create the header of the table
                headerRow = orderDetailTable.AddRow();
                headerRow.HeadingFormat    = true;
                headerRow.Format.Alignment = ParagraphAlignment.Center;
                headerRow.Format.Font.Bold = true;
                headerRow.Shading.Color    = TableBlue;

                headerRow.Cells[0].AddParagraph("Pos.");
                headerRow.Cells[0].Format.Font.Bold  = true;
                headerRow.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
                headerRow.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
                //headerRow.Cells[0].MergeDown = 1;

                headerRow.Cells[1].AddParagraph("Zuschlag");
                headerRow.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                headerRow.Cells[2].AddParagraph("");
                headerRow.Cells[2].Format.Alignment = ParagraphAlignment.Right;
                headerRow.Cells[3].AddParagraph("Betrag");
                headerRow.Cells[3].Format.Alignment = ParagraphAlignment.Center;


                //headerRow.Cells[1].AddParagraph(string.Format("Unload Place No.{0}", i));
                //headerRow.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                //headerRow.Cells[1].MergeRight = 2;

                //headerRow = orderDetailTable.AddRow();
                //headerRow.HeadingFormat = true;
                //headerRow.Format.Alignment = ParagraphAlignment.Center;
                //headerRow.Format.Font.Bold = true;
                //headerRow.Shading.Color = TableBlue;
                //headerRow.Cells[1].AddParagraph("Zuschlag");
                //headerRow.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                //headerRow.Cells[2].AddParagraph("");
                //headerRow.Cells[2].Format.Alignment = ParagraphAlignment.Right;
                //headerRow.Cells[3].AddParagraph("Betrag");
                //headerRow.Cells[3].Format.Alignment = ParagraphAlignment.Center;

                orderDetailTable.SetEdge(0, 0, 4, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
                //this.table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);

                orderItems = currentOrder.OrderDetailDt.Select(string.Format("UnloadPlaceNumber={0}", i));

                if (orderItems == null || orderItems.Length == 0)
                {
                    Row emptyRow = orderDetailTable.AddRow();
                    emptyRow.Cells[0].AddParagraph("No items");
                    emptyRow.Cells[0].Format.Alignment = ParagraphAlignment.Center;
                    emptyRow.Cells[0].MergeRight       = 3;
                }
                //else
                //{
                //    FillOrderDetailContent(orderItems, orderDetailTable);
                //}

                FillOrderDetailContent(orderItems, orderDetailTable);
            }

            if (orderDetailTable == null)
            {
                return;
            }

            // Add an invisible row as a space line to the table
            Row orderTotalRow = orderDetailTable.AddRow();

            orderTotalRow.Borders.Visible = false;

            // Add the total price row
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph("Total Zuschläge");
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            orderTotalRow.Cells[3].AddParagraph(string.Format("{0:n2}", orderDetailSubSumPrice));
            orderTotalRow.Cells[3].Format.Font.Bold = true;

            ///
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph(string.Format("Abladestellen ({0:n2} x {1:n0})",
                                                              currentOrder.UnloadCost, currentOrder.UnloadPlace));
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            decimal unloadCost = currentOrder.UnloadCost * currentOrder.UnloadPlace;

            orderTotalRow.Cells[3].AddParagraph(unloadCost.ToString("n2"));
            orderTotalRow.Cells[3].Format.Font.Bold = true;


            ///
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph("VP für 100 kg in WIR");
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            decimal vpPer100KgInWir = currentOrder.OilPrice * currentOrder.WIRFactor;

            orderTotalRow.Cells[3].AddParagraph(string.Format("{0:n2}", vpPer100KgInWir));
            orderTotalRow.Cells[3].Format.Font.Bold = true;



            //orderTotalRow = orderDetailTable.AddRow();
            //orderTotalRow.Cells[0].Borders.Visible = false;
            //orderTotalRow.Cells[0].AddParagraph("Preis per 100 Kg");
            //orderTotalRow.Cells[0].Format.Font.Bold = true;
            //orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //orderTotalRow.Cells[0].MergeRight = 2;
            //orderTotalRow.Cells[3].AddParagraph(string.Format("{0:n2}", currentOrder.OilPrice * currentOrder.WIRFactor));
            //orderTotalRow.Cells[3].Format.Font.Bold = true;


            //orderTotalRow = orderDetailTable.AddRow();
            //orderTotalRow.Cells[0].Borders.Visible = false;
            //orderTotalRow.Cells[0].AddParagraph(string.Format("VP für 100 Kg ({0:n2} + {1:n2})",
            //    orderDetailSubSumPrice, (currentOrder.OilPrice * currentOrder.WIRFactor)));
            //orderTotalRow.Cells[0].Format.Font.Bold = true;
            //orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //orderTotalRow.Cells[0].MergeRight = 2;
            //orderTotalRow.Cells[3].AddParagraph(string.Format("{0:n2}", currentOrder.TotalPricePer100KG));
            //orderTotalRow.Cells[3].Format.Font.Bold = true;


            ///
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph("VP für 100 kg in CHF");
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            orderTotalRow.Cells[3].AddParagraph(string.Format("{0:n2}", currentOrder.OilPrice));
            orderTotalRow.Cells[3].Format.Font.Bold = true;


            ///Total I
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            decimal quantityDifferenceWir = 0;
            decimal oilQuantity           = 0;

            oilQuantity           = (currentOrder.OilQuantity / 100);
            quantityDifferenceWir = oilQuantity * (currentOrder.PartOfWIR / 100);
            orderTotalRow.Cells[0].AddParagraph(string.Format("Subtotal WIR ({0:n2} x {1:n0})",
                                                              vpPer100KgInWir, quantityDifferenceWir));
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            orderTotalRow.Cells[3].AddParagraph(currentOrder.Total1Price.ToString("n2"));
            orderTotalRow.Cells[3].Format.Font.Bold = true;

            ///Total II
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            decimal quantityDifferenceCHF = 0;

            oilQuantity           = (currentOrder.OilQuantity / 100);
            quantityDifferenceCHF = oilQuantity * (currentOrder.PartOfWIR / 100);
            quantityDifferenceCHF = oilQuantity - quantityDifferenceCHF;
            //orderTotalRow.Cells[0].AddParagraph(string.Format("Total II ({0:n2} + {1:n2})",
            //    currentOrder.Total1Price, unloadCost));
            //orderTotalRow.Cells[0].AddParagraph(string.Format("Total II ({0:n2} + {1:n2} + {2:n2})",
            //    currentOrder.Total2Price, unloadCost, orderDetailSubSumPrice));
            orderTotalRow.Cells[0].AddParagraph(string.Format("Subtotal CHF (({0:n2} x {1:n0}) + {2:n2} + {3:n2})",
                                                              new object[] { currentOrder.OilPrice, quantityDifferenceCHF, unloadCost, orderDetailSubSumPrice }));
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            //orderTotalRow.Cells[3].AddParagraph(currentOrder.Total2Price.ToString("n2"));
            orderTotalRow.Cells[3].AddParagraph((currentOrder.Total2CashPrice).ToString("n2"));
            orderTotalRow.Cells[3].Format.Font.Bold = true;

            ///
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph("Average (Subtotal WIR and Subtotal CHF)");
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            orderTotalRow.Cells[3].AddParagraph(((currentOrder.Total1Price + currentOrder.Total2CashPrice) / 2).ToString("n2"));
            orderTotalRow.Cells[3].Format.Font.Bold = true;

            ///
            orderTotalRow = orderDetailTable.AddRow();
            orderTotalRow.Cells[0].Borders.Visible = false;
            orderTotalRow.Cells[0].AddParagraph("Total (Subtotal WIR + Subtotal CHF)");
            orderTotalRow.Cells[0].Format.Font.Bold = true;
            orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            orderTotalRow.Cells[0].MergeRight       = 2;
            orderTotalRow.Cells[3].AddParagraph((currentOrder.Total1Price + currentOrder.Total2CashPrice).ToString("n2"));
            orderTotalRow.Cells[3].Format.Font.Bold = true;


            //orderTotalRow = orderDetailTable.AddRow();
            //orderTotalRow.Cells[0].Borders.Visible = false;
            //orderTotalRow.Cells[0].AddParagraph(string.Format("WIR Anteil ({0}% from Total I)", currentOrder.PartOfWIR));
            //orderTotalRow.Cells[0].Format.Font.Bold = true;
            //orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //orderTotalRow.Cells[0].MergeRight = 2;
            //orderTotalRow.Cells[3].AddParagraph(currentOrder.Total1WIRPrice.ToString("n2"));
            //orderTotalRow.Cells[3].Format.Font.Bold = true;


            //orderTotalRow = orderDetailTable.AddRow();
            //orderTotalRow.Cells[0].Borders.Visible = false;
            ////orderTotalRow.Cells[0].AddParagraph(string.Format("Bar Anteil ({0}% from Total II)", currentOrder.PartOfWIR));
            //orderTotalRow.Cells[0].AddParagraph(string.Format("Bar Anteil ({0:n2} + {1:n2})", currentOrder.Total1WIRPrice, unloadCost));
            //orderTotalRow.Cells[0].Format.Font.Bold = true;
            //orderTotalRow.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            //orderTotalRow.Cells[0].MergeRight = 2;
            //orderTotalRow.Cells[3].AddParagraph(currentOrder.Total2CashPrice.ToString("n2"));
            //orderTotalRow.Cells[3].Format.Font.Bold = true;
        }