Revision | 60 (tree) |
---|---|
Time | 2021-10-09 07:22:17 |
Author | hemaxvi_soft |
Se agrego el código para completar el botón eliminar NumerosGanadoresWF
de tal forma que al realizar dicho proceso, los tickets ganadores y el detalle de dicho tickets regresen a su estado original.
@@ -335,9 +335,45 @@ | ||
335 | 335 | } |
336 | 336 | return res; |
337 | 337 | } |
338 | - | |
339 | - | |
340 | - public Boolean Delete(LoginDAL loginDAL) | |
338 | + public Boolean EditWiner(LoginDAL loginDAL) | |
339 | + { | |
340 | + ErrorCode = 0; | |
341 | + ErrorDescription = "Successful"; | |
342 | + SqlConnection con = new SqlConnection(); | |
343 | + SqlParameter parametros; | |
344 | + Boolean res = false; | |
345 | + try | |
346 | + { | |
347 | + dbm.DataSource = loginDAL.DataSource; dbm.DataBase = loginDAL.DataBaseName; dbm.User = loginDAL.UserName; dbm.Password = loginDAL.UserPassword; con = dbm.getConexion(dbm); | |
348 | + con.Open(); | |
349 | + SqlCommand cmd = new SqlCommand("TransactionsUpdateWiner", con); | |
350 | + | |
351 | + parametros = cmd.Parameters.Add("@TransactionID", SqlDbType.BigInt); | |
352 | + parametros.Value = TransactionID; | |
353 | + parametros = cmd.Parameters.Add("@LotteryName", SqlDbType.VarChar); | |
354 | + parametros.Value = lotteryName; | |
355 | + | |
356 | + parametros = cmd.Parameters.Add("@StartDate", SqlDbType.DateTime); | |
357 | + parametros.Value = Convert.ToDateTime(StartTime.ToShortDateString() + " 00:00:00"); | |
358 | + | |
359 | + parametros = cmd.Parameters.Add("@EndDate", SqlDbType.DateTime); | |
360 | + parametros.Value = Convert.ToDateTime(EndTime.ToShortDateString() + " 23:59:59"); | |
361 | + | |
362 | + cmd.CommandType = CommandType.StoredProcedure; | |
363 | + if (cmd.ExecuteNonQuery() > 0) | |
364 | + res = true; | |
365 | + con.Close(); | |
366 | + } | |
367 | + catch (Exception e) | |
368 | + { | |
369 | + errorDescription = "Error de SQL :" + e.Message; | |
370 | + errorCode = 0001; | |
371 | + } | |
372 | + return res; | |
373 | + } | |
374 | + | |
375 | + | |
376 | + public Boolean Delete(LoginDAL loginDAL) | |
341 | 377 | { |
342 | 378 | SqlConnection con = new SqlConnection(); |
343 | 379 | SqlParameter parametros; |
@@ -362,7 +398,68 @@ | ||
362 | 398 | return res; |
363 | 399 | } |
364 | 400 | |
401 | + public List<TransactionsDAL> SearchWiner(LoginDAL loginDAL, bool usedDate = false) | |
402 | + { | |
403 | + ErrorCode = 0; | |
404 | + ErrorDescription = "Successful"; | |
405 | + SqlConnection con = new SqlConnection(); | |
406 | + SqlParameter parametros; | |
407 | + SqlDataReader dr = null; | |
408 | + List<TransactionsDAL> transactionsList = new List<TransactionsDAL>(); | |
409 | + try | |
410 | + { | |
411 | + dbm.DataSource = loginDAL.DataSource; dbm.DataBase = loginDAL.DataBaseName; dbm.User = loginDAL.UserName; dbm.Password = loginDAL.UserPassword; con = dbm.getConexion(dbm); | |
412 | + con.Open(); | |
413 | + SqlCommand cmd = new SqlCommand("TransactionsSearchWiner", con); | |
365 | 414 | |
415 | + parametros = cmd.Parameters.Add("@LotteryName", SqlDbType.VarChar); | |
416 | + parametros.Value = lotteryName; | |
417 | + | |
418 | + parametros = cmd.Parameters.Add("@StartDate", SqlDbType.DateTime); | |
419 | + parametros.Value = Convert.ToDateTime(StartTime.ToShortDateString() + " 00:00:00"); | |
420 | + | |
421 | + parametros = cmd.Parameters.Add("@EndDate", SqlDbType.DateTime); | |
422 | + parametros.Value = Convert.ToDateTime(EndTime.ToShortDateString() + " 23:59:59"); | |
423 | + | |
424 | + cmd.CommandType = CommandType.StoredProcedure; | |
425 | + dr = cmd.ExecuteReader(); | |
426 | + if (dr.HasRows) | |
427 | + { | |
428 | + while (dr.Read()) | |
429 | + { | |
430 | + transactionsDAL = new TransactionsDAL(); | |
431 | + transactionsDAL.transactionID = dr.GetInt64(dr.GetOrdinal("TransactionID")); | |
432 | + transactionsDAL.branchID = dr.GetInt32(dr.GetOrdinal("BranchID")); | |
433 | + transactionsDAL.amount = dr.GetDecimal(dr.GetOrdinal("Amount")); | |
434 | + transactionsDAL.shiftID = dr.GetInt32(dr.GetOrdinal("ShiftID")); | |
435 | + transactionsDAL.date = dr.GetDateTime(dr.GetOrdinal("Date")); | |
436 | + transactionsDAL.transactionStatusID = dr.GetInt32(dr.GetOrdinal("TransactionStatusID")); | |
437 | + transactionsDAL.userID = dr.GetInt32(dr.GetOrdinal("UserID")); | |
438 | + transactionsDAL.commission = dr.GetDecimal(dr.GetOrdinal("Commission")); | |
439 | + transactionsDAL.partnerCommission = dr.GetDecimal(dr.GetOrdinal("PartnerCommission")); | |
440 | + transactionsDAL.totalGainAmount = dr.GetInt32(dr.GetOrdinal("TotalGainAmount")); | |
441 | + //transactionsDAL.branchName = dr.GetString(dr.GetOrdinal("BranchName")); | |
442 | + //transactionsDAL.transactionStatusName = dr.GetString(dr.GetOrdinal("TransactionStatusName")); | |
443 | + //transactionsDAL.shiftName = dr.GetString(dr.GetOrdinal("ShiftName")); | |
444 | + // transactionsDAL.userName = dr.GetString(dr.GetOrdinal("UserName")); | |
445 | + transactionsDAL.lotteryName = dr.GetString(dr.GetOrdinal("LotteryName")); | |
446 | + transactionsDAL.ticketID = dr.GetString(dr.GetOrdinal("TicketID")); | |
447 | + transactionsDAL.discount = dr.GetDecimal(dr.GetOrdinal("Discount")); | |
448 | + //transactionsDAL.codeName = dr.GetString(dr.GetOrdinal("CodeName")); | |
449 | + transactionsList.Add(transactionsDAL); | |
450 | + } | |
451 | + } | |
452 | + con.Close(); | |
453 | + } | |
454 | + catch (Exception e) | |
455 | + { | |
456 | + errorDescription = "Error de SQL :" + e.Message; | |
457 | + errorCode = 1; | |
458 | + } | |
459 | + | |
460 | + return transactionsList; | |
461 | + } | |
462 | + | |
366 | 463 | public List<TransactionsDAL> Search(LoginDAL loginDAL,bool usedDate = false) |
367 | 464 | { |
368 | 465 | ErrorCode = 0; |
@@ -460,6 +557,7 @@ | ||
460 | 557 | return transactionsList; |
461 | 558 | } |
462 | 559 | |
560 | + | |
463 | 561 | public List<TransactionsDAL> SearchStadistic(LoginDAL loginDAL) |
464 | 562 | { |
465 | 563 | ErrorCode = 0; |
@@ -18,10 +18,10 @@ | ||
18 | 18 | if (Session["DatosUsuario"] != null) |
19 | 19 | { |
20 | 20 | loginDAL = (LoginDAL)Session["DatosUsuario"]; |
21 | - | |
21 | + | |
22 | 22 | if (!IsPostBack) |
23 | 23 | { |
24 | - | |
24 | + | |
25 | 25 | InputFecha.Value = DateTime.Now.ToString("yyyy-MM-dd"); |
26 | 26 | GvNumbers.DataSource = null; |
27 | 27 | GvNumbers.DataBind(); |
@@ -33,7 +33,7 @@ | ||
33 | 33 | GvNumbers.Columns.RemoveAt(9); |
34 | 34 | } |
35 | 35 | else |
36 | - { | |
36 | + { | |
37 | 37 | menuUser.Style.Add("display", "none"); |
38 | 38 | } |
39 | 39 |
@@ -45,10 +45,10 @@ | ||
45 | 45 | { |
46 | 46 | Response.Redirect("InicioWF.aspx"); |
47 | 47 | } |
48 | - | |
49 | - | |
50 | 48 | |
51 | 49 | |
50 | + | |
51 | + | |
52 | 52 | } |
53 | 53 | |
54 | 54 | /**Inicio Botones Menu Usuario Vendedor**********************/ |
@@ -175,16 +175,30 @@ | ||
175 | 175 | |
176 | 176 | protected void GvNumbersRowDeleting(object sender, GridViewDeleteEventArgs e) |
177 | 177 | { |
178 | - if (e.RowIndex >= 0) | |
178 | + | |
179 | + try | |
179 | 180 | { |
180 | - Borrar(GvNumbers.Rows[e.RowIndex].Cells[0].Text); | |
181 | + if (e.RowIndex >= 0) | |
182 | + { | |
183 | + if (AnularGanadores(Convert.ToDateTime(GvNumbers.Rows[e.RowIndex].Cells[7].Text), GvNumbers.Rows[e.RowIndex].Cells[2].Text + " " + GvNumbers.Rows[e.RowIndex].Cells[8].Text)) | |
184 | + { | |
181 | 185 | |
182 | - //string title = "Estas seguro?"; | |
183 | - //string text = "Una vez Borrado, ¡no podrá recuperar este registro!"; | |
184 | - //ScriptManager.RegisterStartupScript(this, this.GetType(), null, "NotificacionYN('" + GvNumbers.Rows[e.RowIndex].Cells[0].Text + "','" + title + "','" + text + "','" + OpcionesNotificaciones.Borrar + "');", true); | |
185 | - //GvNumbers.DataSource = null; | |
186 | - //GvNumbers.DataBind(); | |
186 | + Borrar(GvNumbers.Rows[e.RowIndex].Cells[0].Text); | |
187 | + } | |
188 | + | |
189 | + //string title = "Estas seguro?"; | |
190 | + //string text = "Una vez Borrado, ¡no podrá recuperar este registro!"; | |
191 | + //ScriptManager.RegisterStartupScript(this, this.GetType(), null, "NotificacionYN('" + GvNumbers.Rows[e.RowIndex].Cells[0].Text + "','" + title + "','" + text + "','" + OpcionesNotificaciones.Borrar + "');", true); | |
192 | + //GvNumbers.DataSource = null; | |
193 | + //GvNumbers.DataBind(); | |
194 | + } | |
195 | + | |
187 | 196 | } |
197 | + catch (Exception) | |
198 | + { | |
199 | + | |
200 | + //throw; | |
201 | + } | |
188 | 202 | } |
189 | 203 | protected void GvNumbers_RowUpdating(object sender, GridViewUpdateEventArgs e) |
190 | 204 | { |
@@ -197,7 +211,7 @@ | ||
197 | 211 | protected void Borrar(string codigo) |
198 | 212 | { |
199 | 213 | WinNumbersDAL winNumbersDAL = new WinNumbersDAL(); |
200 | - // string result = "Congratulations!!!"; | |
214 | + // string result = "Congratulations!!!"; | |
201 | 215 | try |
202 | 216 | { |
203 | 217 |
@@ -205,7 +219,7 @@ | ||
205 | 219 | winNumbersDAL.Delete(loginDAL); |
206 | 220 | |
207 | 221 | Cargar(); |
208 | - // result = "Registro Eliminado exitosamente!"; | |
222 | + // result = "Registro Eliminado exitosamente!"; | |
209 | 223 | |
210 | 224 | } |
211 | 225 | catch (Exception ex) |
@@ -215,7 +229,42 @@ | ||
215 | 229 | winNumbersDAL = null; |
216 | 230 | |
217 | 231 | } |
232 | + protected bool AnularGanadores(DateTime fecha, string loteria) | |
233 | + { | |
234 | + bool respuesta = false; | |
235 | + TransactionsDAL transactionsDAL = new TransactionsDAL(); | |
236 | + List<TransactionsDAL> listTransactionsDAL = new List<TransactionsDAL>(); | |
237 | + // string result = "Congratulations!!!"; | |
238 | + try | |
239 | + { | |
240 | + transactionsDAL.LotteryName = loteria; | |
241 | + transactionsDAL.StartTime = fecha; | |
242 | + transactionsDAL.EndTime = fecha; | |
243 | + listTransactionsDAL = transactionsDAL.SearchWiner(loginDAL); | |
244 | + if (listTransactionsDAL.Count > 0) | |
245 | + { | |
246 | + foreach (TransactionsDAL item in listTransactionsDAL) | |
247 | + { | |
248 | + transactionsDAL.TransactionID = item.TransactionID; | |
249 | + transactionsDAL.LotteryName = item.LotteryName; | |
250 | + transactionsDAL.StartTime = fecha; | |
251 | + transactionsDAL.StartTime = fecha; | |
252 | + transactionsDAL.EditWiner(loginDAL); | |
253 | + } | |
218 | 254 | |
255 | + } | |
256 | + respuesta = true; | |
257 | + | |
258 | + } | |
259 | + catch (Exception ex) | |
260 | + { | |
261 | + ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Algo salio mal, mas detalles: '" + ex.Message + ");", true); | |
262 | + } | |
263 | + | |
264 | + return respuesta; | |
265 | + | |
266 | + } | |
267 | + | |
219 | 268 | //[WebMethod] |
220 | 269 | //public static string Borrar(string codigo) |
221 | 270 | //{ |
@@ -228,7 +277,7 @@ | ||
228 | 277 | // winNumbersDAL.Delete(loginDAL); |
229 | 278 | |
230 | 279 | // result = "Registro Eliminado exitosamente!"; |
231 | - | |
280 | + | |
232 | 281 | // } |
233 | 282 | // catch (Exception ex) |
234 | 283 | // { |
@@ -240,7 +289,7 @@ | ||
240 | 289 | // return result; |
241 | 290 | |
242 | 291 | //} |
243 | - | |
244 | - | |
292 | + | |
293 | + | |
245 | 294 | } |
246 | 295 | } |
\ No newline at end of file |