//генерация рублевой квитанции protected void btUAPayRubles_Click(object sender, EventArgs e) { UAbonentDO uaDO = new UAbonentDO(); UOrderDO uoDO = new UOrderDO(); UOrder uo; UAbonent ua; UniversalEntity ue = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); ue = uaDO.RetrieveByOrderID(id); UOrderDetailsDO uodDO = new UOrderDetailsDO(); double sum = 0; double sumrub = 0; double nds = 0; double finalsum = 0; if (ue.Count > 0) { ua = (UAbonent)ue[0]; ue = uoDO.RetrieveUOrderById(id); if (ue.Count > 0) { uo = (UOrder)ue[0]; ue = uodDO.RetrieveUOrderDetailsByOrderID(id); foreach (UOrderDetails uod in ue) { sum += uod.PriceRub; // sumrub += (uod.Price) * 2; /*sumrub = sum; * nds = sumrub*0.2; * nds = Math.Round(nds, 2); * finalsum = (nds + sumrub) + (nds + sumrub);*/ } using (DocX document = DocX.Load(Request.MapPath("~\\Templates/payua.docx"))) { //DocXEntender.ReplaceFormatedText(document, "DDD", "дата"); document.ReplaceText("TITLE", ua.Title, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ADDRESS", ua.Address, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("PHONE", ua.Phone, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("DATE", DateTime.Now.ToString("dd MMMM yyyy"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("NNN", uo.ID.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VIEW", uo.ActionType, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("SUM", sum.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("VAT", Utilities.GetVAT(sum).ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("ALL", (sum + Utilities.GetVAT(sum)).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", Utilities.GetVATRubU(sumrub).ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VSEGO", sum.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/payrubles.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?uapayrub=Corporate\"></iframe>"; } } } }
//Сохранение в базу protected void lbSaveAll_Click(object sender, EventArgs e) { if (Session["Abonent"] != null) { SessionAbonent sa = (SessionAbonent)Session["Abonent"]; if (sa.Vodomer.Count == 0) { radWM.RadAlert("Необходимо добавить минимум 1 водомер.", null, null, "Предупреждение", ""); } else { if (sa.Type == (short)Abonent.Corporate) { UAbonent ua = sa.UAbon; UAbonentDO uado = new UAbonentDO(); int uid = uado.Create(ua); if (uid > 0) { sa.UAbon.ID = uid; Session["Abonent"] = sa; UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); uo.ActionType = "Определения метрологических характеристик водомера"; uo.UAbonentID = uid; uo.UserID = GetCurrentUser().ID; int uoid = uodo.Create(uo); if (uoid > 0) { hfOrder.Value = uoid.ToString(); UOrderDetails uod = new UOrderDetails(); UOrderDetailsDO uoddo = new UOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create1(v); uod.UOrderID = uoid; uod.VodomerID = vid; uod.StartValue = v.VodomerPreview.StartValue; int uodid = uoddo.Create(uod); } Response.Redirect("UJournal.aspx?id=" + uoid.ToString()); } } } if (sa.Type == (short)Abonent.Private) { FAbonent fa = sa.FAbon; FAbonentDO fado = new FAbonentDO(); int fid = fado.Create(fa); if (fid > 0) { sa.FAbon.ID = fid; Session["Abonent"] = sa; FOrder fo = new FOrder(); FOrderDO fodo = new FOrderDO(); fo.ActionType = "Определения метрологических характеристик водомера "; fo.FAbonentID = fid; fo.UserID = GetCurrentUser().ID; int foid = fodo.Create(fo); if (foid > 0) { hfOrder.Value = foid.ToString(); FOrderDetails fod = new FOrderDetails(); FOrderDetailsDO foddo = new FOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create1(v); fod.FOrderID = foid; fod.VodomerID = vid; fod.StartValue = v.VodomerPreview.StartValue; int uodid = foddo.Create(fod); } Response.Redirect("FJournal.aspx?id=" + foid.ToString()); } } } // LoadStep3(); } } }
//Генерация договора protected void btContract_Click(object sender, EventArgs e) { UniversalEntity ue = new UniversalEntity(); UniversalEntity uev = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); UAbonent ua = new UAbonent(); UAbonentDO uado = new UAbonentDO(); ue = uado.RetrieveByOrderID(id); UOrderDetailsDO uoddo = new UOrderDetailsDO(); VodomerTypeDO vtdo = new VodomerTypeDO(); VodomerType vt; UOrderDetails uod; if (ue.Count > 0) { double sum = 0; double sumvat = 0; string vodomer = string.Empty; ua = (UAbonent)ue[0]; ue = uoddo.RetrieveUOrderDetailsByOrderID(id); if (ue.Count > 0) { for (int i = 0; i < ue.Count; i++) { uod = (UOrderDetails)ue[i]; sum += uod.GetPriceWithVAT(); sumvat += uod.GetPriceVAT(); uev = vtdo.RetrieveVodomerTypeByVodomerId(uod.VodomerID); if (uev.Count > 0) { for (int j = 0; j < uev.Count; j++) { vt = (VodomerType)uev[j]; vodomer += "Поверить " + vt.Description + " Ø " + vt.Diameter.ToString() + " мм в количестве 1 шт., "; } } } } UOrder uo = new UOrder(); UOrderDO uoDO = new UOrderDO(); ue = uoDO.RetrieveUOrderById(id); if (ue.Count > 0) { uo = (UOrder)ue[0]; } if (ua.IsBudget) { //Для бюджетных организаций using (DocX document = DocX.Load(Request.MapPath("~\\Templates/noncommerce.docx"))) { //DocXExtender.ReplaceFormatedText(document, "DDD", "дата"); document.ReplaceText("NNN", uo.ID.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("DATE", RuDateAndMoneyConverter.DateToTextLong(uo.DateIn) + " г.", false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("TITLE", ua.Title, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VODOMER", vodomer, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("SUM", RuDateAndMoneyConverter.CurrencyToTxt(sum, true), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("NDS", RuDateAndMoneyConverter.CurrencyToTxt(sumvat, true), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("SSS", (sum).ToString("0.00") + " грн", false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("RS", ua.RS, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("BANK", ua.Bank, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("MFO", ua.MFO, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("OKPO", ua.OKPO, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ADDRESS", ua.Address, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("FACE", ua.ContactFace, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("CAUSE", ua.Cause, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("PHONE", ua.Phone, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //TAXTYPE document.ReplaceText("TAXTYPE", ua.TaxType, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/outnoncommerce.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?Commerce=1\"></iframe>"; } } else { //для небюджетных организаций using (DocX document = DocX.Load(Request.MapPath("~\\Templates/commerce.docx"))) { //DocXExtender.ReplaceFormatedText(document, "DDD", "дата"); document.ReplaceText("NNN", uo.ID.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("DATE", RuDateAndMoneyConverter.DateToTextLong(uo.DateIn) + " г.", false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("TITLE", ua.Title, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("VODOMER", vodomer, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("SUM", RuDateAndMoneyConverter.CurrencyToTxt(sum, true), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("NDS", RuDateAndMoneyConverter.CurrencyToTxt(sumvat, true), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("RS", ua.RS, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("BANK", ua.Bank, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("MFO", ua.MFO, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("OKPO", ua.OKPO, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ADDRESS", ua.Address, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("FACE", ua.ContactFace, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("CAUSE", ua.Cause, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("PHONE", ua.Phone, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("TAXTYPE", ua.TaxType, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/outcommerce.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?Commerce=0\"></iframe>"; } } } }
//Сохранение в базу protected void lbSaveAll_Click(object sender, EventArgs e) { if (Session["Abonent"] != null) { SessionAbonent sa = (SessionAbonent)Session["Abonent"]; if (sa.Vodomer.Count == 0) { SetMessege("Предупреждение", "Необходимо добавить минимум 1 водомер."); } else { if (sa.Type == (short)Abonent.Corporate) { UAbonent ua = sa.UAbon; UAbonentDO uado = new UAbonentDO(); int uid = uado.Create(ua); if (uid > 0) { sa.UAbon.ID = uid; Session["Abonent"] = sa; UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); uo.ActionType = "Поверка водомера."; uo.UAbonentID = uid; uo.UserID = GetCurrentUser().ID; int uoid = uodo.Create(uo); if (uoid > 0) { hfOrder.Value = uoid.ToString(); UOrderDetails uod = new UOrderDetails(); UOrderDetailsDO uoddo = new UOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create(v); uod.UOrderID = uoid; uod.VodomerID = vid; uod.StartValue = v.VodomerPreview.StartValue; int uodid = uoddo.Create(uod); } } } } if (sa.Type == (short)Abonent.Private) { FAbonent fa = sa.FAbon; FAbonentDO fado = new FAbonentDO(); int fid = fado.Create(fa); if (fid > 0) { sa.FAbon.ID = fid; Session["Abonent"] = sa; FOrder fo = new FOrder(); FOrderDO fodo = new FOrderDO(); fo.ActionType = "Поверка водомера."; fo.FAbonentID = fid; fo.UserID = GetCurrentUser().ID; int foid = fodo.Create(fo); if (foid > 0) { hfOrder.Value = foid.ToString(); FOrderDetails fod = new FOrderDetails(); FOrderDetailsDO foddo = new FOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create(v); fod.FOrderID = foid; fod.VodomerID = vid; fod.StartValue = v.VodomerPreview.StartValue; int uodid = foddo.Create(fod); } } } } //SetMessege("Статус", "Абонент и водомер успешно внесены в базу."); LoadStep3(); } } }
public static void GenerateBill(int id) { InitializeWorkbookBill(); ISheet sheet1 = hssfworkbook.GetSheet("s"); UniversalEntity ue = new UniversalEntity(); //UniversalEntity uev = new UniversalEntity(); UAbonent ua = new UAbonent(); UAbonentDO uado = new UAbonentDO(); UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); UOrderDetailsDO uodDO = new UOrderDetailsDO(); ue = uado.RetrieveByOrderID(id); string header = string.Empty; string actNumber = string.Empty; if (ue.Count > 0) { ua = (UAbonent)ue[0]; header += ua.Title + " \nюр адрес: " + ua.Address + " \n№ св. пл. НДС: " + ua.VATPay + " \n№ ИНН: " + ua.INN + " \nтел.: " + ua.Phone; } ue = uodo.RetrieveUOrderById(id); if (ue.Count > 0) { uo = (UOrder)ue[0]; sheet1.GetRow(4).GetCell(GetLetterNumber("aj")).SetCellValue(uo.ID); sheet1.GetRow(9).GetCell(GetLetterNumber("ai")).SetCellValue(RuDateAndMoneyConverter.DateToTextLongUA(uo.DateIn) + "р."); } ue = uodDO.RetrieveUOrderDetailsByOrderID(id); sheet1.GetRow(16).GetCell(6).SetCellValue(header); int count = ue.Count; double sum = 0; int row = 20; if (count <= 5) { CustomRetrieverDO crDO = new CustomRetrieverDO(); ue = crDO.RetrieveUActByOrderID5Low(id); if (ue.Count > 0) { for (int i = row; i < ue.Count + row; i++) { ArrayList al = (ArrayList)ue[i - row]; sheet1.GetRow(i).GetCell(GetLetterNumber("a")).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString())); sheet1.GetRow(i).GetCell(GetLetterNumber("ad")).SetCellValue("шт."); sheet1.GetRow(i).GetCell(GetLetterNumber("aj")).SetCellValue(al[4].ToString()); sheet1.GetRow(i).GetCell(GetLetterNumber("ap")).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sheet1.GetRow(i).GetCell(GetLetterNumber("av")).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sum += Convert.ToDouble(al[3]); } } } else { CustomRetrieverDO crDO = new CustomRetrieverDO(); ue = crDO.RetrieveUActByOrderID5High(id); if (ue.Count > 0) { for (int i = row; i < ue.Count + row; i++) { ArrayList al = (ArrayList)ue[i - row]; //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row]; sheet1.GetRow(i).GetCell(GetLetterNumber("a")).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}", al[0].ToString())); sheet1.GetRow(i).GetCell(GetLetterNumber("ad")).SetCellValue("шт."); sheet1.GetRow(i).GetCell(GetLetterNumber("aj")).SetCellValue(al[3].ToString()); sheet1.GetRow(i).GetCell(GetLetterNumber("ap")).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sheet1.GetRow(i).GetCell(GetLetterNumber("av")).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sum += Convert.ToDouble(al[2]); } } } /*int row = 20; * double sum = 0; * * * * * * if (ue.Count > 0) * { * for (int i = row; i < ue.Count + row; i++) * { * UOrderDetails u = (UOrderDetails)ue[i - row]; * * sheet1.GetRow(i).GetCell(GetLetterNumber("a")).SetCellValue("Определения метрологических характеристик водомера "); * sheet1.GetRow(i).GetCell(GetLetterNumber("ad")).SetCellValue("шт."); * sheet1.GetRow(i).GetCell(GetLetterNumber("aj")).SetCellValue("1"); * sheet1.GetRow(i).GetCell(GetLetterNumber("ap")).SetCellValue(u.Price.ToString("0.00")); * sheet1.GetRow(i).GetCell(GetLetterNumber("av")).SetCellValue(u.Price.ToString("0.00")); * sum += u.Price; * } * }*/ sheet1.GetRow(31).GetCell(GetLetterNumber("av")).SetCellValue(sum.ToString("0.00")); sheet1.GetRow(32).GetCell(GetLetterNumber("av")).SetCellValue(Utilities.GetVAT(sum).ToString("0.00")); sheet1.GetRow(33).GetCell(GetLetterNumber("av")).SetCellValue((sum + Utilities.GetVAT(sum)).ToString("0.00")); sheet1.GetRow(35).GetCell(GetLetterNumber("a")).SetCellValue("Загальна сума, що підлягає оплаті: " + UADateAndMoneyConverter.CurrencyToTxt((sum + Utilities.GetVAT(sum)), true)); //Загальна сума, що підлягає оплаті //Force excel to recalculate all the formula while open sheet1.ForceFormulaRecalculation = true; WriteToFileB(); }
public static void GenerateUAct(int id) { UniversalEntity ue = new UniversalEntity(); UAbonent ua = new UAbonent(); UAbonentDO uado = new UAbonentDO(); UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); UOrderDetailsDO uodDO = new UOrderDetailsDO(); ue = uado.RetrieveByOrderID(id); string header = string.Empty; string actNumber = string.Empty; if (ue.Count > 0) { ua = (UAbonent)ue[0]; header += ua.Title + " \nюр адрес: " + ua.Address + " \n№ св. пл. НДС: " + ua.VATPay + " \n№ ИНН: " + ua.INN + " \nтел.: " + ua.Phone; } ue = uodo.RetrieveUOrderById(id); if (ue.Count > 0) { uo = (UOrder)ue[0]; if (uo.DateOut.HasValue) { actNumber = " г. Донецк АКТ № " + uo.ID + " от ____________________" + DateTime.Now.Year.ToString() + " г."; } else { actNumber = " г. Донецк АКТ № " + uo.ID + " от ____________________" + DateTime.Now.Year.ToString() + " г."; } } ue = uodDO.RetrieveUOrderDetailsByOrderID(id); InitializeWorkbook(); ISheet sheet1 = hssfworkbook.GetSheet("s"); sheet1.GetRow(11).GetCell(0).SetCellValue(" по договору (письму) № " + uo.ID + " от ____________________" + DateTime.Now.Year.ToString() + " г."); sheet1.GetRow(41).GetCell(0).SetCellValue(" по договору (письму) № " + uo.ID + " от ____________________" + DateTime.Now.Year.ToString() + " г."); //create cell on rows, since rows do already exist,it's not necessary to create rows again. sheet1.GetRow(2).GetCell(3).SetCellValue(header); sheet1.GetRow(32).GetCell(3).SetCellValue(header); sheet1.GetRow(9).GetCell(0).SetCellValue(actNumber); sheet1.GetRow(39).GetCell(0).SetCellValue(actNumber); int rowC = 44; int row = 14; double sum = 0; int count = ue.Count; if (count <= 5) { CustomRetrieverDO crDO = new CustomRetrieverDO(); ue = crDO.RetrieveUActByOrderID5Low(id); if (ue.Count > 0) { for (int i = row; i < ue.Count + row; i++) { ArrayList al = (ArrayList)ue[i - row]; //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row]; sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1); sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString())); sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция"); sheet1.GetRow(i).GetCell(3).SetCellValue("шт."); sheet1.GetRow(i).GetCell(4).SetCellValue(al[4].ToString()); sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sheet1.GetRow(rowC).GetCell(0).SetCellValue(i - row + 1); sheet1.GetRow(rowC).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString())); sheet1.GetRow(rowC).GetCell(2).SetCellValue("калькуляция"); sheet1.GetRow(rowC).GetCell(3).SetCellValue("шт."); sheet1.GetRow(rowC).GetCell(4).SetCellValue(al[4].ToString()); sheet1.GetRow(rowC).GetCell(5).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sheet1.GetRow(rowC).GetCell(6).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00")); sum += Convert.ToDouble(al[3]); rowC++; } } } else { CustomRetrieverDO crDO = new CustomRetrieverDO(); ue = crDO.RetrieveUActByOrderID5High(id); if (ue.Count > 0) { for (int i = row; i < ue.Count + row; i++) { ArrayList al = (ArrayList)ue[i - row]; //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row]; sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1); sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}", al[0].ToString())); sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция"); sheet1.GetRow(i).GetCell(3).SetCellValue("шт."); sheet1.GetRow(i).GetCell(4).SetCellValue(al[3].ToString()); sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[1]).ToString("0.00")); sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[2]).ToString("0.00")); sheet1.GetRow(rowC).GetCell(0).SetCellValue(i - row + 1); sheet1.GetRow(rowC).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}", al[0].ToString())); sheet1.GetRow(rowC).GetCell(2).SetCellValue("калькуляция"); sheet1.GetRow(rowC).GetCell(3).SetCellValue("шт."); sheet1.GetRow(rowC).GetCell(4).SetCellValue(al[3].ToString()); sheet1.GetRow(rowC).GetCell(5).SetCellValue(Convert.ToDouble(al[1]).ToString("0.00")); sheet1.GetRow(rowC).GetCell(6).SetCellValue(Convert.ToDouble(al[2]).ToString("0.00")); sum += Convert.ToDouble(al[2]); rowC++; } } } /*int rowC = 44; * int row = 14; * double sum = 0; * if (ue.Count > 0) * { * for (int i = row; i < ue.Count + row; i++) * { * UOrderDetails u = (UOrderDetails)ue[i - row]; * * sheet1.GetRow(i).GetCell(0).SetCellValue(i - row+1); * sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString())); * sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция"); * sheet1.GetRow(i).GetCell(3).SetCellValue("шт."); * sheet1.GetRow(i).GetCell(4).SetCellValue("1"); * sheet1.GetRow(i).GetCell(5).SetCellValue(u.Price.ToString("0.00")); * sheet1.GetRow(i).GetCell(6).SetCellValue(u.Price.ToString("0.00")); * * sheet1.GetRow(rowC).GetCell(0).SetCellValue(i - row + 1); * sheet1.GetRow(rowC).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString())); * sheet1.GetRow(rowC).GetCell(2).SetCellValue("калькуляция"); * sheet1.GetRow(rowC).GetCell(3).SetCellValue("шт."); * sheet1.GetRow(rowC).GetCell(4).SetCellValue("1"); * sheet1.GetRow(rowC).GetCell(5).SetCellValue(u.Price.ToString("0.00")); * sheet1.GetRow(rowC).GetCell(6).SetCellValue(u.Price.ToString("0.00")); * * sum += u.Price; * rowC++; * } * }*/ sheet1.GetRow(19).GetCell(6).SetCellValue(sum.ToString("0.00")); sheet1.GetRow(20).GetCell(6).SetCellValue(Utilities.GetVAT(sum).ToString("0.00")); sheet1.GetRow(21).GetCell(6).SetCellValue((sum + Utilities.GetVAT(sum)).ToString("0.00")); sheet1.GetRow(49).GetCell(6).SetCellValue(sum.ToString("0.00")); sheet1.GetRow(50).GetCell(6).SetCellValue(Utilities.GetVAT(sum).ToString("0.00")); sheet1.GetRow(51).GetCell(6).SetCellValue((sum + Utilities.GetVAT(sum)).ToString("0.00")); /* sheet1.GetRow(2).GetCell(1).SetCellValue(300); * sheet1.GetRow(3).GetCell(1).SetCellValue(500050); * sheet1.GetRow(4).GetCell(1).SetCellValue(8000); * sheet1.GetRow(5).GetCell(1).SetCellValue(110); * sheet1.GetRow(6).GetCell(1).SetCellValue(100); * sheet1.GetRow(7).GetCell(1).SetCellValue(200); * sheet1.GetRow(8).GetCell(1).SetCellValue(210); * sheet1.GetRow(9).GetCell(1).SetCellValue(2300); * sheet1.GetRow(10).GetCell(1).SetCellValue(240); * sheet1.GetRow(11).GetCell(1).SetCellValue(180123); * sheet1.GetRow(12).GetCell(1).SetCellValue(150);*/ //Force excel to recalculate all the formula while open sheet1.ForceFormulaRecalculation = true; WriteToFile(); }
//Сохранение в базу protected void lbSaveAll_Click(object sender, EventArgs e) { if (Session["Abonent"] != null) { SessionAbonent sa = (SessionAbonent)Session["Abonent"]; if (sa.Vodomer.Count == 0) { radWM.RadAlert("Необходимо добавить минимум 1 водомер.", null, null, "Предупреждение", ""); } else { if (sa.Type == (short)Abonent.Corporate) { UAbonent ua = sa.UAbon; UAbonentDO uado = new UAbonentDO(); int uid = uado.Create(ua); if (uid > 0) { sa.UAbon.ID = uid; Session["Abonent"] = sa; UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); uo.ActionType = "*377;08;1;1 Опр. метр. хар."; uo.UAbonentID = uid; uo.UserID = GetCurrentUser().ID; int uoid = uodo.Create(uo); if (uoid > 0) { hfOrder.Value = uoid.ToString(); UOrderDetails uod = new UOrderDetails(); UOrderDetailsDO uoddo = new UOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create1(v); uod.UOrderID = uoid; uod.VodomerID = vid; uod.StartValue = v.VodomerPreview.StartValue; int uodid = uoddo.Create(uod); } Response.Redirect("UJournal.aspx?id=" + uoid.ToString()); } } } if (sa.Type == (short)Abonent.Private) { NewFAbonent fa = sa.FAbon; NewFAbonentDO fado = new NewFAbonentDO(); int fid = fado.Create(fa); if (fid > 0) { sa.FAbon.ID = fid; Session["Abonent"] = sa; NewFOrder fo = new NewFOrder(); NewFOrderDO fodo = new NewFOrderDO(); fo.ActionType = "*377;08;1;0 Проведение периодической поверки счетчика"; fo.FAbonentID = fid; fo.UserID = GetCurrentUser().ID; int foid = fodo.Create(fo); if (foid > 0) { hfOrder.Value = foid.ToString(); FOD2018 fod = new FOD2018(); FOrderDetails2018DO foddo = new FOrderDetails2018DO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create1(v); fod.FOrderID = foid; fod.VodomerID = vid; fod.StartValue = v.VodomerPreview.StartValue; int uodid = foddo.CreateFOrderDetails(fod); } Response.Redirect("FJournal2018.aspx?id=" + foid.ToString()); } } } if (sa.Type == (short)Abonent.Special) { AlternativeAbonent sab = sa.AlternativeAbon; AlternativeAbonentDO sabo = new AlternativeAbonentDO(); int fid = sabo.Create(sab); if (fid > 0) { sa.AlternativeAbon.ID = fid; Session["Abonent"] = sa; AlternativeOrder so = new AlternativeOrder(); AlternativeOrderDO sod = new AlternativeOrderDO(); so.WorkType = "*377;09;1;1 Снятие/установка водомеров."; so.SAbonentID = fid; so.UserID = GetCurrentUser().ID; int soid = sod.CreateSOrder(so); if (soid > 0) { hfOrder.Value = soid.ToString(); AlternativeOrderDetails sd = new AlternativeOrderDetails(); AlternativeOrderDetailsDO sodDO = new AlternativeOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create1(v); sd.SOrderID = soid; sd.VodomerID = vid; sd.StartValue = v.VodomerPreview.StartValue; int uodid = sodDO.Create(sd); } Response.Redirect("SJournal.aspx?id=" + soid.ToString()); } } } // LoadStep3(); } } }
//Сохранение в базу protected void lbSaveAll_Click(object sender, EventArgs e) { if (Session["Abonent"] != null) { SessionAbonent sa = (SessionAbonent)Session["Abonent"]; if (sa.Vodomer.Count == 0) { SetMessege("Предупреждение", "Необходимо добавить минимум 1 водомер."); } else { if (sa.Type == (short)Abonent.Corporate) { UAbonent ua = sa.UAbon; UAbonentDO uado = new UAbonentDO(); int uid = uado.Create(ua); if (uid > 0) { sa.UAbon.ID = uid; Session["Abonent"] = sa; UOrder uo = new UOrder(); UOrderDO uodo = new UOrderDO(); uo.ActionType = "Определения метрологических характеристик водомера."; uo.UAbonentID = uid; uo.UserID = GetCurrentUser().ID; int uoid = uodo.Create(uo); if (uoid > 0) { hfOrder.Value = uoid.ToString(); UOrderDetails uod = new UOrderDetails(); UOrderDetailsDO uoddo = new UOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create(v); uod.UOrderID = uoid; uod.VodomerID = vid; uod.StartValue = v.VodomerPreview.StartValue; int uodid = uoddo.Create(uod); } } } } if (sa.Type == (short)Abonent.Private) { NewFAbonent fa = sa.FAbon; NewFAbonentDO fado = new NewFAbonentDO(); int fid = fado.Create(fa); if (fid > 0) { sa.FAbon.ID = fid; Session["Abonent"] = sa; FOrder2018 fo = new FOrder2018(); FOrder2018DO fodo = new FOrder2018DO(); fo.ActionType = "Определения метрологических характеристик водомера."; fo.FAbonentID = fid; fo.UserID = GetCurrentUser().ID; int foid = fodo.CreateFOrder(fo); if (foid > 0) { hfOrder.Value = foid.ToString(); FOD2018 fod = new FOD2018(); FOrderDetails2018DO foddo = new FOrderDetails2018DO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create(v); fod.FOrderID = foid; fod.VodomerID = vid; fod.StartValue = v.VodomerPreview.StartValue; int uodid = foddo.CreateFOrderDetails(fod); } } } } if (sa.Type == (short)Abonent.Special) { AlternativeAbonent sab = sa.AlternativeAbon; AlternativeAbonentDO sabo = new AlternativeAbonentDO(); int fid = sabo.Create(sab); if (fid > 0) { sa.AlternativeAbon.ID = fid; Session["Abonent"] = sa; AlternativeOrder so = new AlternativeOrder(); AlternativeOrderDO sod = new AlternativeOrderDO(); so.WorkType = "Снятие/установка водомеров."; so.SAbonentID = fid; so.UserID = GetCurrentUser().ID; int soid = sod.CreateSOrder(so); if (soid > 0) { hfOrder.Value = soid.ToString(); AlternativeOrderDetails sd = new AlternativeOrderDetails(); AlternativeOrderDetailsDO sodDO = new AlternativeOrderDetailsDO(); VodomerDO vdo = new VodomerDO(); foreach (Vodomer v in sa.Vodomer) { int vid = vdo.Create(v); sd.SOrderID = soid; sd.VodomerID = vid; sd.StartValue = v.VodomerPreview.StartValue; int uodid = sodDO.Create(sd); } } } } //SetMessege("Статус", "Абонент и водомер успешно внесены в базу."); LoadStep3(); } } }