protected void radbutSaveAbonentInfo_Click(object sender, EventArgs e) { UniversalEntity ue = new UniversalEntity(); NewFAbonent fa = new NewFAbonent(); NewFAbonentDO fado = new NewFAbonentDO(); ue = fado.RetrieveByOrderID(Utilities.ConvertToInt(hfODID.Value)); if (ue.Count > 0) { fa = (NewFAbonent)ue[0]; fa.PhysicalNumberJournal = tbNumberJournalPhysical.Text; fa.Address = tbAddress.Text; fa.Surname = tbClientSurname.Text; fa.DistrictID = Utilities.ConvertToInt(ddlDistrict.SelectedValue); fa.FirstName = tbClientName.Text; fa.LastName = tbClientLastName.Text; fa.Phone = tbPhone.Text; fa.NotPay = cbNotPay.Checked; //fa.RejectVodomer = cbRejectVodomer.Checked; fado.Update(fa, GetCurrentUser().ID); } _OrderID = Utilities.ConvertToInt(hfODID.Value); Bind(); }
//radbutDeleteAbonentInfo_Click protected void radbutDeleteAbonentInfo_Click(object sender, EventArgs e) { NewFAbonentDO fado = new NewFAbonentDO(); fado.Delete(Utilities.ConvertToInt(hfODID.Value), GetCurrentUser().ID); _OrderID = Utilities.ConvertToInt(hfODID.Value); Bind(); }
public void EditorMode() { User u = GetCurrentUser(); u.GetPermissions(); //проверяем наличие прав для редактировнаия if (u.ChekPermission("Editor")) { punAdonentEditor.Visible = true; gvJournal.Visible = false; gvJournal2.Visible = true; BindDistricts(); UniversalEntity ue = new UniversalEntity(); NewFAbonent fa = new NewFAbonent(); NewFAbonentDO fado = new NewFAbonentDO(); ue = fado.RetrieveByOrderID(_OrderID); if (ue.Count > 0) { fa = (NewFAbonent)ue[0]; tbNumberJournalPhysical.Text = fa.PhysicalNumberJournal; tbAddress.Text = fa.Address; tbClientSurname.Text = fa.Surname; ddlDistrict.SelectedValue = fa.DistrictID.ToString(); tbClientName.Text = fa.FirstName; tbClientLastName.Text = fa.LastName; tbPhone.Text = fa.Phone; cbNotPay.Checked = fa.NotPay; //cbRejectVodomer.Checked = fa.RejectVodomer; } NewFOrder fo = new NewFOrder(); NewFOrderDO fodDO = new NewFOrderDO(); ue = fodDO.RetrieveFOrderById(_OrderID); if (ue.Count > 0) { fo = (NewFOrder)ue[0]; cbDefectVodomer.Checked = fo.DefectVodomer; } } else { punAdonentEditor.Visible = false; gvJournal.Visible = true; gvJournal2.Visible = false; } }
protected void btOrder_Click(object sender, EventArgs e) { NewFAbonentDO faDO = new NewFAbonentDO(); NewFAbonent fa; UniversalEntity ue = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); ue = faDO.RetrieveByOrderID(id); if (ue.Count > 0) { fa = (NewFAbonent)ue[0]; using (DocX document = DocX.Load(Request.MapPath("~\\Templates/order.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); //VODOMER document.SaveAs(Request.MapPath("~\\Templates/outorder.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?order=1\"></iframe>"; } } }
protected void btOrder_Check_Click(object sender, EventArgs e) { NewFAbonentDO faDO = new NewFAbonentDO(); FOrderDO foDO = new FOrderDO(); FOrder fo; NewFAbonent fa; UniversalEntity ue = new UniversalEntity(); int id = Convert.ToInt32(hfODID.Value); ue = faDO.RetrieveByOrderID(id); FOrderDetailsDO fodDO = new FOrderDetailsDO(); //FOrderDetails fod; double sum = 0; //гривневая цена double getvat = 0; //гривневый ндс double uafin = 0; //гривневая итоговая сумма double sumrub = 0; //рублевая цена double getvatrub = 0; //рублвый ндс double finish = 0; //рублевая итоговая сумма //RetrieveFOrderByID (данные из FOrder + данные из NewFAbonent) if (ue.Count > 0) { fa = (NewFAbonent)ue[0]; ue = foDO.RetrieveFOrderById(id); //RetrieveFOrderByID (данные из FOrder + данные из NewFAbonent) if (ue.Count > 0) { fo = (FOrder)ue[0]; ue = fodDO.RetrieveFOrderDetailsByOrderID(id); //цикл с RetrieveFOrderDetailsByOrderID (данные из FOrderDetails + данные из FOrder) foreach (FOrderDetails fod in ue) { //гривневый счет sum += fod.Price; getvat = sum * 0.2; uafin = (sum + getvat); //рублевый счет sumrub += fod.Price; getvatrub = sumrub * 0.2; finish = (sumrub + getvatrub) + (sumrub + getvatrub); } using (DocX document = DocX.Load(Request.MapPath("~\\Templates/order_check.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("TYPE", fo.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", 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", (Utilities.GetVATRub(sumrub)).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/outorder_check.docx")); litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?ordercheck=1\"></iframe>"; } } } }
//генерация квитнации protected void btPay_Click(object sender, EventArgs e) { NewFAbonentDO faDO = new NewFAbonentDO(); FOrderDO foDO = new FOrderDO(); VodomerType vt = new VodomerType(); FOrder fo; NewFAbonent 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 = (NewFAbonent)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>"; } } } }
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(); NewFOrder fo = new NewFOrder(); NewFOrderDO fodo = new NewFOrderDO(); //StringBuilder sbl = new StringBuilder(); UniversalEntity ue = new UniversalEntity(); ue = fodo.RetrieveFOrderById(_OrderID); if (ue.Count > 0) { fo = (NewFOrder)ue[0]; 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(); NewFAbonent fa = new NewFAbonent(); NewFAbonentDO fado = new NewFAbonentDO(); ue = fado.RetrieveByOrderID(_OrderID); if (ue.Count > 0) { fa = (NewFAbonent)ue[0]; if (fa.NotPay) { cbPaid.Enabled = false; btActRubNew.Enabled = false; //btPay.Enabled = false; //btOrder.Enabled = false; //btOrderCheck.Enabled = false; btNewActCheckRub.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/>"); } litAbonentInfo2018.Text = sb.ToString(); } }
//Сохранение в базу 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(); } } }