//генерация квитнации protected void btPay_Click(object sender, EventArgs e) { FAbonentDO faDO = new FAbonentDO(); FOrderDO foDO = new FOrderDO(); VodomerType vt = new VodomerType(); FOrder fo; FAbonent fa; UniversalEntity ue = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); ue = faDO.RetrieveByOrderID(id); Vodomer vod = new Vodomer(); VodomerDO vodDO = new VodomerDO(); FOrderDetailsDO fodDO = new FOrderDetailsDO(); FOrderDetails fods = new FOrderDetails(); //FOrderDetails fod; double sum = 0; //гривневая цена double getvat = 0; //гривневый ндс double uafin = 0; //гривневая итоговая сумма double sumrub = 0; //рублевая цена double getvatrub = 0; //рублевый ндс double finish = 0; //рублевая итоговая сумма if (ue.Count > 0) { fa = (FAbonent)ue[0]; ue = foDO.RetrieveFOrderById(id); if (ue.Count > 0) { fo = (FOrder)ue[0]; ue = fodDO.RetrieveFOrderDetailsByOrderID(id); foreach (FOrderDetails fod in ue) { //гривневый счет sum += fod.Price; getvat = sum * 0.2; getvat = Math.Round(getvat, 2); uafin = (sum + getvat); //рублевый счет sumrub += fod.Price; getvatrub = sumrub * 0.2; getvatrub = Math.Round(getvatrub, 2); finish = (sumrub + getvatrub) + (sumrub + getvatrub); } using (DocX document = DocX.Load(Request.MapPath("~\\Templates/kvit.docx"))) { //DocXExtender.ReplaceFormatedText(document, "DDD", "дата"); document.ReplaceText("FIO", fa.Surname + " " + fa.FirstName + " " + fa.LastName, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ADDRESS", fa.Address, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("PNONE", fa.Phone, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("DATE", DateTime.Now.ToString("dd MMMM yyyy"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("NUMBER", fo.Prefix + fo.ID.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VIEW", fo.ActionType, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("DIAMETR", vt.Diameter.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("NOMZAVOD", vod.FactoryNumber.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("SUM", sum.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VAT", getvat.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ALL", uafin.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("CENA", sumrub.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("NDS", getvatrub.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VSEGO", finish.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/kvitfa.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?pay=Private\"></iframe>"; } } /* Vodomer vod = new Vodomer(); * VodomerDO vodDO = new VodomerDO(); * ue = vodDO.RetrieveVodomerById(id); * if (ue.Count > 0) * { * vod = (Vodomer)ue[0]; * ue = vodDO.RetrieveVodomerById(id); * } * using (DocX document = DocX.Load(Request.MapPath("~\\Templates/kvit.docx"))) * { * document.ReplaceText("NOMZAVOD", vod.FactoryNumber); * document.SaveAs(Request.MapPath("~\\Templates/kvitfa.docx")); * litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?pay=Private\"></iframe>"; * }*/ } }
public void Bind() { EditorMode(); cbSeld.Checked = false; cbSeld.Enabled = true; cbPaid.Checked = false; cbPaid.Enabled = true; cbRejectVodomer.Checked = false; cbRejectVodomer.Enabled = true; cbDefectVodomer.Checked = false; cbDefectVodomer.Enabled = true; tbPaymentDay.Enabled = true; tbPaymentDay.Text = DateTime.Now.ToShortDateString(); FOrder fo = new FOrder(); FOrderDO fodo = new FOrderDO(); //StringBuilder sbl = new StringBuilder(); UniversalEntity ue = new UniversalEntity(); ue = fodo.RetrieveFOrderById(_OrderID); if (ue.Count > 0) { fo = (FOrder)ue[0]; /*if (!fo.IsPaid) * { * btAct.Visible = false; * } * else * { * btAct.Visible = true; * }*/ if (fo.DateOut != null) { cbSeld.Checked = true; cbSeld.Enabled = false; cbPaid.Checked = true; cbPaid.Enabled = false; } if (fo.IsPaid) { cbPaid.Checked = true; cbPaid.Enabled = false; cbSeld.Checked = true; cbSeld.Enabled = false; if (fo.PaymentDay.HasValue) { tbPaymentDay.Text = fo.PaymentDay.Value.ToShortDateString(); } tbPaymentDay.Enabled = false; } if (fo.DefectVodomer) { cbDefectVodomer.Checked = true; cbDefectVodomer.Enabled = false; } } hfODID.Value = _OrderID.ToString(); StringBuilder sb = new StringBuilder(); FAbonent fa = new FAbonent(); FAbonentDO fado = new FAbonentDO(); ue = fado.RetrieveByOrderID(_OrderID); if (ue.Count > 0) { fa = (FAbonent)ue[0]; if (fa.NotPay) { cbPaid.Enabled = false; btActRub.Enabled = false; //btPay.Enabled = false; //btOrder.Enabled = false; //btOrderCheck.Enabled = false; btActCheckRub.Enabled = false; //btWithdrawalAct.Enabled = false; } sb.AppendLine("<span>ФИО: " + fa.Surname + " " + fa.FirstName + " " + fa.LastName + "</span><br/>"); sb.AppendLine("<span>номер по журналу: " + fa.PhysicalNumberJournal + "</span><br/>"); sb.AppendLine("<span>Тел.: " + fa.Phone + "</span><br/>"); sb.AppendLine("<span>Адрес: " + fa.Address + "</span><br/>"); if (fa.NotPay) { sb.AppendLine("<span style=\"color:red;font-size:18px;\">Без оплаты</span><br/>"); } litAbonentInfo.Text = sb.ToString(); } }