public void EditorMode() { User u = GetCurrentUser(); u.GetPermissions(); if (u.ChekPermission("Editor")) { punAlternAbonentEditor.Visible = true; gvJournal.Visible = false; gvJournal2.Visible = true; BindDistricts(); UniversalEntity ue = new UniversalEntity(); AlternativeAbonent aa = new AlternativeAbonent(); AlternativeAbonentDO aado = new AlternativeAbonentDO(); ue = aado.RetrieveBySOrderID(_OrderID); if (ue.Count > 0) { aa = (AlternativeAbonent)ue[0]; stbNumberJournalPhysical.Text = aa.PhysicalNumberJournal; tbAddress.Text = aa.Address; stbClientSurname.Text = aa.Surname; stbClientName.Text = aa.FirstName; stbClientLastName.Text = aa.LastName; stbPhone.Text = aa.Phone; ddsDistrict.SelectedValue = aa.DistrictID.ToString(); } } else { punAlternAbonentEditor.Visible = false; gvJournal.Visible = true; gvJournal2.Visible = false; } }
protected void radbutDeleteAlternativeAbonentInfo_OnClick(object sender, EventArgs e) { AlternativeAbonentDO aado = new AlternativeAbonentDO(); aado.Delete(Utilities.ConvertToInt(hfODID.Value), GetCurrentUser().ID); _OrderID = Utilities.ConvertToInt(hfODID.Value); Bind(); }
public void Bind() { EditorMode(); cbSeld.Checked = false; cbSeld.Enabled = true; cbPaid.Checked = false; cbPaid.Enabled = true; tbPaymentDay.Enabled = true; tbPaymentDay.Text = DateTime.Now.ToShortDateString(); AlternativeOrder ao = new AlternativeOrder(); AlternativeOrderDO aodo = new AlternativeOrderDO(); UniversalEntity ue = new UniversalEntity(); ue = aodo.RetrieveSOrderById(_OrderID); if (ue.Count > 0) { ao = (AlternativeOrder)ue[0]; if (ao.DateOut != null) { cbSeld.Checked = true; cbSeld.Enabled = false; cbPaid.Checked = true; cbPaid.Enabled = false; } if (ao.IsPaid) { cbPaid.Checked = true; cbPaid.Enabled = false; cbSeld.Checked = true; cbSeld.Enabled = false; if (ao.PaymentDay.HasValue) { tbPaymentDay.Text = ao.PaymentDay.Value.ToShortDateString(); } tbPaymentDay.Enabled = false; } } hfODID.Value = _OrderID.ToString(); StringBuilder sb = new StringBuilder(); AlternativeAbonent aa = new AlternativeAbonent(); AlternativeAbonentDO aado = new AlternativeAbonentDO(); ue = aado.RetrieveBySOrderID(_OrderID); if (ue.Count > 0) { aa = (AlternativeAbonent)ue[0]; sb.AppendLine("<span>ФИО: " + aa.Surname + " " + aa.FirstName + " " + aa.LastName + "</span><br/>"); sb.AppendLine("<span>Номер по журналу: " + aa.PhysicalNumberJournal + "</span><br/>"); sb.AppendLine("<span>Тел. " + aa.Phone + "</span><br/>"); sb.AppendLine("<span>Адрес: " + aa.Address + "</span><br/>"); AlternAbonentInfo.Text = sb.ToString(); } }
protected void radbutSaveAlternativeAbonentInfo_OnClick(object sender, EventArgs e) { UniversalEntity ue = new UniversalEntity(); AlternativeAbonent aa = new AlternativeAbonent(); AlternativeAbonentDO aado = new AlternativeAbonentDO(); ue = aado.RetrieveBySOrderID(Utilities.ConvertToInt(hfODID.Value)); if (ue.Count > 0) { aa = (AlternativeAbonent)ue[0]; aa.PhysicalNumberJournal = stbNumberJournalPhysical.Text; aa.FirstName = stbClientName.Text; aa.Surname = stbClientSurname.Text; aa.LastName = stbClientLastName.Text; aa.Phone = stbPhone.Text; aa.Address = tbAddress.Text; aado.UpdateWithHistory(aa, GetCurrentUser().ID); } _OrderID = Utilities.ConvertToInt(hfODID.Value); Bind(); }
//генерация квитнации protected void btAlternativePay_Click(object sender, EventArgs e) { AlternativeAbonentDO aaDO = new AlternativeAbonentDO(); AlternativeOrderDO aoDO = new AlternativeOrderDO(); VodomerType vt = new VodomerType(); AlternativeOrder ao; AlternativeAbonent aa; UniversalEntity ue = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); ue = aaDO.RetrieveBySOrderID(id); Vodomer vod = new Vodomer(); VodomerDO vodDO = new VodomerDO(); AlternativeOrderDetailsDO aodDO = new AlternativeOrderDetailsDO(); AlternativeOrderDetails aods = new AlternativeOrderDetails(); //FOrderDetails fod; double sum = 0; //гривневая цена double getvat = 0; //гривневый ндс double uafin = 0; //гривневая итоговая сумма double sumrub = 0; //рублевая цена double dissum = 0; //цена демонтаж double instsum = 0; double getvatrub = 0; //рублевый ндс double finish = 0; //рублевая итоговая сумма if (ue.Count > 0) { aa = (AlternativeAbonent)ue[0]; ue = aoDO.RetrieveSOrderById(id); if (ue.Count > 0) { ao = (AlternativeOrder)ue[0]; ue = aodDO.RetrieveSOrderDetailsBySorderID(id); foreach (AlternativeOrderDetails fod in ue) { //гривневый счет /*sum += fod.Price; * getvat = sum * 0.2; * getvat = Math.Round(getvat, 2); * uafin = (sum + getvat);*/ //рублевый счет //sumrub += fod.ReplacementPrice; dissum += fod.DismantlingPrice; instsum += fod.InstallPrice; sumrub = dissum + instsum; } using (DocX document = DocX.Load(Request.MapPath("~\\Templates/payaltern.docx"))) { //DocXExtender.ReplaceFormatedText(document, "DDD", "дата"); document.ReplaceText("FIO", aa.FirstName + " " + aa.Surname + " " + aa.LastName, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("ADDRESS", aa.Address, false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); document.ReplaceText("PNONE", aa.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", ao.Prefix + ao.ID.ToString(), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //document.ReplaceText("VIEW", ao.WorkType, 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", sumrub.ToString("0.00"), false, System.Text.RegularExpressions.RegexOptions.IgnoreCase); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/alternativepay.docx")); litScriptS.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?alternativepay=Special\"></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 = "*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(); } } }