public bool UpdateSOrder(AlternativeOrder ent) { bool success = true; AlternativeOrderDAO entDAO = new AlternativeOrderDAO(); sc = new SqlCommand("UpdateSOrder"); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.Add("@ID", ent.ID); sc.Parameters.Add("@IsPaid", ent.IsPaid); sc.Parameters.Add("@UserID", ent.UserID); if (ent.DateOut == null) { sc.Parameters.Add("@DateOut", DBNull.Value); } else { sc.Parameters.Add("@DateOut", ent.DateOut); } if (ent.PaymentDay == null) { sc.Parameters.Add("@PaymentDay", DBNull.Value); } else { sc.Parameters.Add("@PaymentDay", ent.PaymentDay.Value); } //addParameters(ent); success = entDAO.updateEntity(sc); return(success); }
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(); } }
public int CreateSOrder(AlternativeOrder ent) { int createid = 0; AlternativeOrderDAO entDAO = new AlternativeOrderDAO(); sc = new SqlCommand("CreateSOrder"); sc.CommandType = CommandType.StoredProcedure; addParametres(ent); createid = entDAO.createEntity(sc); return(createid); }
public override UniversalEntity createEntity() { UniversalEntity ue = new UniversalEntity(); while (dr.Read()) { AlternativeOrder ent = new AlternativeOrder(); ent = createEntityFromReader(dr); ue.Add(ent); } return(ue); }
public AlternativeOrder createEntityFromReader(SqlDataReader dr) { AlternativeOrder ent = new AlternativeOrder(); if (!dr.IsDBNull(dr.GetOrdinal("ID"))) { ent.ID = Convert.ToInt32(dr["ID"]); } if (!dr.IsDBNull(dr.GetOrdinal("SAbonentID"))) { ent.SAbonentID = Convert.ToInt32(dr["SAbonentID"]); } if (!dr.IsDBNull(dr.GetOrdinal("WorkType"))) { ent.WorkType = dr["WorkType"].ToString(); } if (!dr.IsDBNull(dr.GetOrdinal("UserID"))) { ent.UserID = Convert.ToInt32(dr["UserID"]); } if (!dr.IsDBNull(dr.GetOrdinal("DateIn"))) { ent.DateIn = Convert.ToDateTime(dr["DateIn"]); } if (!dr.IsDBNull(dr.GetOrdinal("DateOut"))) { ent.DateOut = Convert.ToDateTime(dr["DateOut"]); } if (!dr.IsDBNull(dr.GetOrdinal("PaymentDay"))) { ent.PaymentDay = Convert.ToDateTime(dr["PaymentDay"]); } if (!dr.IsDBNull(dr.GetOrdinal("Prefix"))) { ent.Prefix = dr["Prefix"].ToString(); } return(ent); }
protected void lbSaveAll_Click(object sender, EventArgs e) { string errorMessage = string.Empty; bool ok = true; foreach (GridViewRow r in gvJournal.Rows) { if (string.IsNullOrEmpty((r.FindControl("litEndValue") as Literal).Text) && cbSeld.Checked) { errorMessage += "Необходимо заполнить конечные показания водомеров. <br/>"; ok = false; cbPaid.Checked = true; break; } } if (cbPaid.Checked && string.IsNullOrEmpty(tbPaymentDay.Text)) { ok = false; cbSeld.Checked = true; errorMessage += "Необходимо заполнить дату оплаты. <br/>"; } else { AlternativeOrder ao = new AlternativeOrder(); AlternativeOrderDO aodo = new AlternativeOrderDO(); ao.ID = Convert.ToInt32(hfODID.Value); ao.IsPaid = cbPaid.Checked; ao.UserID = GetCurrentUser().ID; ao.PaymentDay = Convert.ToDateTime(tbPaymentDay.Text); if (cbSeld.Checked) { ao.DateOut = DateTime.Now; } bool rez = aodo.UpdateSOrder(ao); _OrderID = ao.ID; Bind(); } }
void addParametres(AlternativeOrder ent) { AddParametresToSqlCommand(ent, ref sc); }
void AddParametresToSqlCommand(AlternativeOrder ent, ref SqlCommand sc) { sc.Parameters.Add("@SAbonentID", ent.SAbonentID); sc.Parameters.Add("@WorkType", ent.WorkType); sc.Parameters.Add("@UserID", ent.UserID); }
//Сохранение в базу 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(); } } }