public void r101Implementation(OrdersWaitingForPriceChangeModel instance) { // This is the placeholder for method implementation. if (Arguments.CommandArgument == "OrderDtlVw2") { //decimal total = (decimal)SqlText.ExecuteScalar("select isnull(Sum(SellingPrice * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", // instance.OrderHedID); //instance.TotalAmount = total; //int i = SqlText.ExecuteNonQuery("Update OrderHed Set TotalAmount=@total Where OrderHedID=@OrderHedID", // total, instance.OrderHedID); decimal total = (decimal)SqlText.ExecuteScalar("select isnull(Sum(SellingPrice * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); decimal proposedTotal = (decimal)SqlText.ExecuteScalar("select isnull(Sum(IIF(ProposedSellingPrice is null, SellingPrice,ProposedSellingPrice) * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); instance.TotalAmount = proposedTotal > 0 ? proposedTotal : total; string totalAmount = instance.TotalAmount.ToString(); int i = SqlText.ExecuteNonQuery("Update OrderHed Set TotalAmount=@totalAmount Where OrderHedID=@OrderHedID", instance.TotalAmount, instance.OrderHedID); } }
protected override void BeforeSqlAction(ActionArgs args, ActionResult result) { if (args.CommandName == "Insert" && args["Number"].Value == null) { String Quote_no = null; using (SqlText findPrice = new SqlText( "select dbo.GenerateNewQuotationNumber (@EnqID,1) as enq_no")) { findPrice.AddParameter("@EnqID", args["EnquiryID"].Value); Quote_no = Convert.ToString(findPrice.ExecuteScalar()); } args["Number"].NewValue = Quote_no; args["Number"].Modified = true; // args["CreatedByUserID"].NewValue = WindowsIdentity.GetCurrent().Name; // args["CreatedByUserID"].Modified = true; } // if (args["CreatedByUsername"].Value == null) if (args.CommandName == "Insert" && args["CreatedByUsername"].Value == null) { MembershipUser User = Membership.GetUser(); args["CreatedByUsername"].NewValue = User.UserName; args["CreatedByUsername"].Modified = true; // args["CreatedByUserID"].NewValue = WindowsIdentity.GetCurrent().Name; // args["CreatedByUserID"].Modified = true; } }
public string Customer_Validate(string CustCode) { using (SqlText sql = new SqlText(String.Format("select count(1) from Customer where Code = '{0}'", CustCode))) { string result = sql.ExecuteScalar().ToString(); return(result); } }
public string getUnitCode(string MatCode, string CustCode) { using (SqlText sql = new SqlText(String.Format("select top(1) isnull(UnitCode,'') from MaterialNumber where CustomerItemNumber = '{0}' and SoldtoParty = '{1}'", CustCode, MatCode))) { string result = sql.ExecuteScalar().ToString(); return(result); } }
public void r104Implementation(Contratado_Solicitud_VacacionesModel instance) { // This is the placeholder for method implementation. //string conStr = ConfigurationManager.ConnectionStrings["arhmexdb_DEV"].ToString(); int diasFinalesAutorizados = Convert.ToInt32(instance.Dias_Autorizados); using (SqlProcedure sql = new SqlProcedure("dbo.sp_Revision_De_Solicitud")) { sql.Command.CommandTimeout = 60 * 10; //Definición parametro especial para recibir el RETURN del SP sql.AddParameter("RetVal", 0); sql.Parameters["RetVal"].Direction = ParameterDirection.ReturnValue; sql.AddParameter("@Tipo_Prestacion_Id", 1); // PRESTACION TIPO VACACION sql.AddParameter("@Estado_Solicitud_Vacaciones", 4); // 4. Significa AUTORIZADO CON CAMBIOS sql.AddParameter("@Solicitud_Vacaciones_Key", instance.Solicitud_Vacaciones_Key); sql.AddParameter("@Dias_Autorizados", diasFinalesAutorizados); //sql.AddParameter("@Contratante_Id", instance.Contratante_Id); sql.AddParameter("@Contratado_Id", instance.Contratado_Id); sql.AddParameter("@Fecha_Solicitud", instance.Fecha_Solicitud); sql.AddParameter("@Dias_Solicitados", instance.Dias_Solicitados); sql.AddParameter("@Fecha_Inicio_Vacaciones", instance.Fecha_Inicio_Vacaciones); sql.AddParameter("@Fecha_Fin_Vacaciones", instance.Fecha_Fin_Vacaciones); sql.AddParameter("@Notas_Autorizacion_Rechazo", ""); /*Parametros de sistema**/ sql.AddParameter("@Creado_Por_Id", UserId); sql.AddParameter("@Transaccion_Id", DBNull.Value); sql.AddParameter("@Fijar_Bitacora", 1); sql.AddParameter("@Mostrar_Tablas_Sistema", 0); //cmd.Parameters.Add("@Mensaje_Sistema_Id", 1);//.Direction = ParameterDirection.Output; sql.AddParameter("@Mensaje_Sistema_Id", 1); sql.AddParameter("@Simular", 0); sql.AddParameter("@Trace", ""); //.Direction = ParameterDirection.Output; sql.AddParameter("@Debug", 0); sql.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Trace"].Direction = ParameterDirection.Output; //Definición de tamaños que soporten los tipos de datos de los parametros del salida del SP sql.Parameters["@Mensaje_Sistema_Id"].Size = 4; sql.Parameters["@Trace"].Size = 8000; sql.ExecuteNonQuery(); if (sql.Parameters["RetVal"].Value.ToString() != "1") { String ErrorMessage = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM dbo.Mensaje_Sistema WHERE Mensaje_Sistema_Id=" + sql.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(ErrorMessage); } else { Result.Continue(); } } // using (SqlProcedure sql = new SqlProcedure("dbo.sp_Revision_De_Solicitud")) } //public void r104Implementation(Contratado_Solicitud_VacacionesModel instance)
public void r107Implementation(Contratado_Solicitud_VacacionesModel instance) { using (SqlProcedure sql = new SqlProcedure("dbo.sp_Administrar_Solicitud_Vacaciones")) { sql.Command.CommandTimeout = 60 * 10; //Definición parametro especial para recibir el RETURN del SP sql.AddParameter("RetVal", 0); sql.Parameters["RetVal"].Direction = ParameterDirection.ReturnValue; sql.AddParameter("@Tipo_Operacion_Id", 1); // 1. Significa INSERT/CREACION NUEVO sql.AddParameter("@Contratado_Solicitud_Vacaciones_Id", 0); /// Este es el ID de la tabla de solicitudes. sql.AddParameter("@Solicitud_Vacaciones_Key", ""); sql.AddParameter("@Contratado_Id", instance.Contratado_Id); sql.AddParameter("@Fecha_Solicitud", instance.Fecha_Solicitud); sql.AddParameter("@Dias_Solicitados", instance.Dias_Solicitados); sql.AddParameter("@Fecha_Inicio_Vacaciones", instance.Fecha_Inicio_Vacaciones); sql.AddParameter("@Fecha_Fin_Vacaciones", instance.Fecha_Fin_Vacaciones); sql.AddParameter("@Estatus_Solicitud_Id", instance.Estatus_Solicitud_Id); sql.AddParameter("@Fecha_Autorizacion_Rechazo", DateTime.Today); sql.AddParameter("@Autorizado_Rechazado_Por_Id", UserId); sql.AddParameter("@Notas_Autorizacion_Rechazo", instance.Notas_Autorizacion_Rechazo); sql.AddParameter("@Dias_Autorizados", instance.Dias_Autorizados); sql.AddParameter("@Fecha_Inicio_Vacaciones_Autorizado ", instance.Fecha_Inicio_Vacaciones); sql.AddParameter("@Fecha_Fin_Vacaciones_Autorizado ", instance.Fecha_Fin_Vacaciones); sql.AddParameter("@HTML ", ""); /*Parametros de sistema**/ sql.AddParameter("@Creado_Por_Id", UserId); sql.AddParameter("@Transaccion_Id", DBNull.Value); sql.AddParameter("@Fijar_Bitacora", 1); sql.AddParameter("@Mostrar_Tablas_Sistema", 0); sql.AddParameter("@Mensaje_Sistema_Id", 1); sql.AddParameter("@Simular", 0); sql.AddParameter("@Trace", ""); sql.AddParameter("@Debug", 0); sql.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Trace"].Direction = ParameterDirection.Output; //Definición de tamaños que soporten los tipos de datos de los parametros del salida del SP sql.Parameters["@Mensaje_Sistema_Id"].Size = 4; sql.Parameters["@Trace"].Size = 8000; sql.ExecuteNonQuery(); if (sql.Parameters["RetVal"].Value.ToString() != "1") { String ErrorMessage = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM dbo.Mensaje_Sistema WHERE Mensaje_Sistema_Id=" + sql.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(ErrorMessage); } else { Result.Continue(); } } // using (SqlProcedure sql = new SqlProcedure("dbo.sp_Administrar_Solicitud_Vacaciones")) } // public void r107Implementation(Contratado_Solicitud_VacacionesModel instance)
public void r101Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (instance.OrderHedID != null) { int i = (int)SqlText.ExecuteScalar("Select isnull(Count(OrderDtlID),0) from OrderDtl Where OrderHedID=@OrderHedID", instance.OrderHedID); if (i > 0) { instance.IsOrderLinesCreated = true; } else { instance.IsOrderLinesCreated = false; } } if (instance.OrderDate != null) { instance.TargetReportingDate = Convert.ToDateTime(instance.OrderDate).AddDays(7); } if (instance.Owner == "YS,LAI") { instance.Owner = "YS.LAI"; } //if (instance[OrderHeaderDataField.UnPaidInvoices].Modified || // instance[OrderHeaderDataField.CreditLimit].Modified ) //{ // //Result.ShowModal("CustomerStatement", "editForm1", "Select", null); // if(instance.UnPaidInvoices > instance.CreditLimit) // { // instance.Exception = true; // instance.ExceptionDtl = "#Credit Limit Exceeded"; // } //} //if (instance[OrderHeaderDataField.TermsExceed].Modified) //{ // //Result.ShowModal("CustomerStatement", "editForm1", "Select", null); // if(instance.TermsExceed !=null && Convert.ToBoolean(instance.TermsExceed)) // { // instance.Exception = true; // instance.ExceptionDtl += " #Terms Exceeded"; // } //} //string filePath = @"D:\OldPC\Epicor\Epicor Docs\ConsultantRoadmap.pdf"; ////FileInfo file = new FileInfo(filePath); //WebClient test = new WebClient(); //byte[] data= test.DownloadData(filePath); //instance.ContentType = "application/pdf"; //instance.FileName = "ConsultantRoadmap.pdf"; //instance.Length = 489818; //UpdateFieldValue("Attachment", filePath); }
public void r102Implementation(OrderRelModel instance) { // This is the placeholder for method implementation. if (instance.OrderRelQty <= 0 && instance.FocrelQty <= 0) { // //instance.OrderRelQty = Convert.ToDecimal(instance[OrderRelDataField.OrderRelQty].OldValue); this.PreventDefault(); Result.Focus("OrderRelQty", "The OrderRelQty Or FOCRelQty must be greater than zero."); } if (instance.OrderRelQty > 0) { decimal RemainRelQty = (decimal)SqlText.ExecuteScalar("select a.OrderQty - isnull((Select Sum(b.OrderRelQty) from OrderRel b Where b.OrderDtlID=a.OrderDtlID and b.OrderRelID<>@OrderRelID),0) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID " , new { @OrderRelID = instance.OrderRelID, @OrderDtlID = instance.OrderDtlID }); if (RemainRelQty <= 0) { this.PreventDefault(); Result.Focus("OrderRelQty", "Available OrderRelQty is {0}", RemainRelQty); } else if (instance.OrderRelQty > RemainRelQty) { this.PreventDefault(); Result.Focus("OrderRelQty", "RelQty must be between 1 and {0}", RemainRelQty); } } if (instance.FocrelQty > 0) { decimal RemainFocQty = (decimal)SqlText.ExecuteScalar("select a.FOCQty - isnull((Select Sum(b.FOCRelQty) from OrderRel b Where b.OrderDtlID=a.OrderDtlID and b.OrderRelID<>@OrderRelID),0) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID " , new { @OrderRelID = instance.OrderRelID, @OrderDtlID = instance.OrderDtlID }); if (RemainFocQty <= 0) { this.PreventDefault(); Result.Focus("FocrelQty", "Available FOCQty is {0}", RemainFocQty); } else if (instance.FocrelQty > RemainFocQty) { this.PreventDefault(); Result.Focus("FocrelQty", "FOCQty must be between 1 and {0}", RemainFocQty); } } //if(Convert.ToBoolean(instance.OrderHedBulkOrder)) //{ // int i = SqlText.ExecuteNonQuery("Update OrderDtl set OrderQty=(OrderQty + @Qty) Where OrderDtlID=@OrderDtlID" // , new { @Qty = instance.OrderRelQty, @OrderDtlID = instance.OrderDtlID }); // //Result.ExecuteOnClient( // // "this.set_lastCommandName(null);" + // the action state machine is reset // // "this.goToView('grid1');" + // show 'grid1' // // "var dv=Web.DataView.find('grid1');" + // find specific master data view // // "if(dv)dv.refresh();"); // if the view is found then ask it to refresh //} }
public void r105Implementation(OrderRelModel instance) { // This is the placeholder for method implementation. decimal RemainRelQty = (decimal)SqlText.ExecuteScalar("select a.OrderQty - (Select Sum(isnull(b.OrderRelQty,0)) from OrderRel b Where b.OrderDtlID=a.OrderDtlID) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID ", new { @OrderDtlID = instance.OrderDtlID }); decimal RemainFocQty = (decimal)SqlText.ExecuteScalar("select a.FOCQty - isnull((Select Sum(b.FOCRelQty) from OrderRel b Where b.OrderDtlID=a.OrderDtlID ),0) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID ", new { @OrderDtlID = instance.OrderDtlID }); //if (RemainRelQty <= 0) //{ // PreventDefault(); //throw new Exception(string.Format("Available OrderRelQty is {0}", RemainRelQty)); instance.OrderRelQty = RemainRelQty; instance.FocrelQty = RemainFocQty; Result.ShowMessage("Available OrderRelQty is {0} And FOCRelQty is {1}", RemainRelQty, RemainFocQty); //} }
protected override void BeforeSqlAction(ActionArgs args, ActionResult result) { if (args.CommandName == "Insert" && args["Number"].Value == null) { String Enq_no = null; String type_prefix = null; using (SqlText findPrice = new SqlText( "select dbo.GenerateNewEnquiryNumber(@ID) as enq_no")) { findPrice.AddParameter("@ID", args["TypeID"].Value); Enq_no = Convert.ToString(findPrice.ExecuteScalar()); } args["Number"].NewValue = Enq_no; args["Number"].Modified = true; // args["CreatedByUserID"].NewValue = WindowsIdentity.GetCurrent().Name; // args["CreatedByUserID"].Modified = true; } // if (args["CreatedByUsername"].Value == null) if (args.CommandName == "Insert" && args["CreatedByUsername"].Value == null) { MembershipUser User = Membership.GetUser(); args["CreatedByUsername"].NewValue = User.UserName; args["CreatedByUsername"].Modified = true; // args["CreatedByUserID"].NewValue = WindowsIdentity.GetCurrent().Name; // args["CreatedByUserID"].Modified = true; } /* * if (args.CommandName == "Update" && args["ChangedByUsername"].Value == null) * * { * MembershipUser User = Membership.GetUser(); * args["ChangedByUsername"].NewValue = User.UserName; * args["ChangedByUsername"].Modified = true; * * // args["CreatedByUserID"].NewValue = WindowsIdentity.GetCurrent().Name; * // args["CreatedByUserID"].Modified = true; * * } */ }
public void r103Implementation(OrderRelModel instance) { // This is the placeholder for method implementation. if (instance.OrderRelQty <= 0 && instance.FocrelQty <= 0) { // //instance.OrderRelQty = Convert.ToDecimal(instance[OrderRelDataField.OrderRelQty].OldValue); this.PreventDefault(); Result.Focus("OrderRelQty", "The OrderRelQty Or FOCRelQty must be greater than zero."); } if (instance.OrderRelQty > 0) { decimal RemainRelQty = (decimal)SqlText.ExecuteScalar("select a.OrderQty - isnull((Select Sum(b.OrderRelQty) from OrderRel b Where b.OrderDtlID=a.OrderDtlID),0) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID ", new { @OrderDtlID = instance.OrderDtlID }); if (RemainRelQty <= 0) { this.PreventDefault(); Result.Focus("OrderRelQty", "Available OrderRelQty is {0}", RemainRelQty); } else if (instance.OrderRelQty > RemainRelQty) { this.PreventDefault(); Result.Focus("OrderRelQty", "RelQty must be between 1 and {0}", RemainRelQty); } } if (instance.FocrelQty > 0) { decimal RemainFocQty = (decimal)SqlText.ExecuteScalar("select a.FOCQty - isnull((Select Sum(b.FOCRelQty) from OrderRel b Where b.OrderDtlID=a.OrderDtlID ),0) as RemainRelQty from OrderDtl a where a.OrderDtlID=@OrderDtlID ", new { @OrderDtlID = instance.OrderDtlID }); if (RemainFocQty <= 0) { this.PreventDefault(); Result.Focus("FocrelQty", "Available FOCQty is {0}", RemainFocQty); } else if (instance.FocrelQty > RemainFocQty) { this.PreventDefault(); Result.Focus("FocrelQty", "FOCQty must be between 1 and {0}", RemainFocQty); } } if (instance.Seq == null) { int i = (int)SqlText.ExecuteScalar("Select Count(OrderRelID)+1 from OrderRel Where OrderDtlID=@OrderDtlID ", new { @OrderDtlID = instance.OrderDtlID }); instance.Seq = i; } }
public void r108Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (Arguments.Trigger.ToLower() == "orderdtl") { decimal total = (decimal)SqlText.ExecuteScalar("select isnull(Sum(SellingPrice * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); decimal proposedTotal = (decimal)SqlText.ExecuteScalar("select isnull(Sum(IIF(ProposedSellingPrice is null, SellingPrice,ProposedSellingPrice) * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); instance.TotalAmount = proposedTotal > 0?proposedTotal: total; string totalAmount = instance.TotalAmount.ToString(); int i = SqlText.ExecuteNonQuery("Update OrderHed Set TotalAmount=@totalAmount Where OrderHedID=@OrderHedID", instance.TotalAmount, instance.OrderHedID); } }
public void r100Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. string CompQry = string.Format("select isnull(Count(a.CompanyName),0) from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompCnt = (int)SqlText.ExecuteScalar(CompQry); if (CompCnt == 1) { string GetCompQry = string.Format("select a.CompanyID,a.CompanyName from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompInfo = SqlText.Execute(GetCompQry); if (CompInfo != null) { instance.CompanyID = (int)CompInfo[0]; instance.CompanyName = (string)CompInfo[1]; } } instance.OrderDate = DateTime.Now; instance.ReqShipDate = DateTime.Now; instance.TargetReportingDate = DateTime.Now.AddDays(7); instance.BulkOrder = false; instance.OrderType = "N"; instance.OrderStatusID = 1; instance.OrderStatusName = "Open"; //instance.PromotionID = 1; //instance.PromotionTitle = "None"; if (UserIsInRole("SalesPerson")) { instance.Owner = UserName.ToUpper(); if (UserName == "YS.LAI") { instance.CurUser = "******"; } else { instance.CurUser = UserName.ToUpper(); } } instance.Creator = UserName; instance.CreatedOn = DateTime.Now; }
public void r100Implementation(OrderHedModel instance) { // This is the placeholder for method implementation. string CompQry = string.Format("select isnull(Count(a.CompanyName),0) from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompCnt = (int)SqlText.ExecuteScalar(CompQry); if (CompCnt == 1) { string GetCompQry = string.Format("select a.CompanyID,a.CompanyName from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompInfo = SqlText.Execute(GetCompQry); if (CompInfo != null) { instance.CompanyID = (int)CompInfo[0]; instance.CompanyName = (string)CompInfo[1]; } } instance.OrderDate = DateTime.Now; instance.ReqShipDate = DateTime.Now; instance.BulkOrder = false; instance.OrderType = "Normal"; instance.OrderStatusID = 1; instance.OrderStatusName = "Open"; }
public void r102Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. //ActionArgs test = Arguments; //HttpContext http = Context; //http.Items["PageRequest_Current"]).Controller //http.Items["PageRequest_Current"]; Finsoft.Data.PageRequest page = (Finsoft.Data.PageRequest)Context.Items["PageRequest_Current"]; string viewName = page.View; if (page.View == "editForm1") { if (instance.CustSysRowID != null) { var custInfo = SqlText.Execute("select * from vwCustomer where SysRowID=@CustSysRowID", new { CustSysRowID = instance.CustSysRowID }); if (custInfo != null) { instance.CAddress1 = custInfo[5].ToString(); instance.CAddress2 = custInfo[6].ToString(); instance.CAddress3 = custInfo[7].ToString(); instance.CCity = custInfo[8].ToString(); instance.CState = custInfo[9].ToString(); instance.CZip = custInfo[10].ToString(); instance.CCountry = custInfo[11].ToString(); instance.CreditLimit = Convert.ToDecimal(custInfo[14]); instance.Balance = Convert.ToDecimal(custInfo[13]); instance.UnPaidInvoices = Convert.ToDecimal(custInfo[15]); instance.OutStandingOrders = Convert.ToDecimal(custInfo[16]); instance.UnPostedInvoices = Convert.ToDecimal(custInfo[17]); instance.AgeCurr = Convert.ToDecimal(custInfo[18]); instance.Age30 = Convert.ToDecimal(custInfo[19]); instance.Age60 = Convert.ToDecimal(custInfo[20]); instance.Age90 = Convert.ToDecimal(custInfo[21]); instance.Age120 = Convert.ToDecimal(custInfo[22]); instance.Age150 = Convert.ToDecimal(custInfo[23]); instance.TermsExceed = Convert.ToBoolean(custInfo[24]); instance.PhoneNum = custInfo[26].ToString(); instance.FaxNum = custInfo[27].ToString(); } } if (instance.ShipToSysRowID != null) { var shipInfo = SqlText.Execute("select * from vwShipTo where SysRowID=@ShipToSysRowID ", new { ShipToSysRowID = instance.ShipToSysRowID }); if (shipInfo != null) { instance.SAddress1 = shipInfo[6].ToString(); instance.SAddress2 = shipInfo[7].ToString(); instance.SAddress3 = shipInfo[8].ToString(); instance.SCity = shipInfo[9].ToString(); instance.SState = shipInfo[10].ToString(); instance.SZip = shipInfo[11].ToString(); instance.SCountry = shipInfo[12].ToString(); instance.SPhoneNum = shipInfo[14].ToString(); instance.SFaxNum = shipInfo[15].ToString(); } } int i = (int)SqlText.ExecuteScalar("Select isnull(Count(OrderDtlID),0) from OrderDtl Where OrderHedID=@OrderHedID", instance.OrderHedID); if (i > 0) { //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Static"); //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Static"); instance.IsOrderLinesCreated = true; } else { //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Auto"); //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Auto"); instance.IsOrderLinesCreated = false; } if (UserIsInRole("SalesPerson")) { if (UserName == "YS.LAI") { instance.CurUser = "******"; } else { instance.CurUser = UserName.ToUpper(); } } } }
public void r103Implementation(Administracion_GastoModel instance) { // This is the placeholder for method implementation. //PreventDefault(); string conStr = ConfigurationManager.ConnectionStrings["arhmexico"].ToString(); int ValorServicioId; int CiudadOrigenId; int CiudadDestinoId; int EstatusRegistroId; int EstatusGastoId; string DireccionOrigen; string DireccionDestino; string Comentarios; string NotasPago; int GastosFrecuentesId; int administracionGastoId; int esGastoConAutorizacion; bool pagado = false; int estatusRegistroId = 1; bool mostrarListaGastosFrecuentes = false; string mensajeSistema = ""; int motivoPagoId = 0; int medioPagoId = 0; int tipoComprobanteId = 0; int bancoId = 0; string numeroCuenta = ""; string clabe = ""; string aNombreCheque = ""; bool esUrgente = false; using (SqlConnection con = new SqlConnection(conStr)) { using (SqlCommand cmd = new SqlCommand("sp_Administrar_Gasto_Contratado", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 60 * 10; ValorServicioId = Convert.ToInt32(instance.Servicio_Id); if (ValorServicioId == Int32.MinValue) { ValorServicioId = 0; } DireccionOrigen = instance.Direccion_Origen; if (DireccionOrigen == null) { DireccionOrigen = "Sin Dirección Origen"; } DireccionDestino = instance.Direccion_Destino; if (DireccionDestino == null) { DireccionDestino = "Sin Dirección Destino"; } Comentarios = instance.Comentarios_Autorizacion_Rechazo; if (Comentarios == null) { Comentarios = "Sin Comentarios"; } CiudadOrigenId = Convert.ToInt32(instance.Ciudad_Origen_Id); if (CiudadOrigenId == Int32.MinValue) { CiudadOrigenId = 0; } CiudadDestinoId = Convert.ToInt32(instance.Ciudad_Destino_Id); if (CiudadDestinoId == Int32.MinValue) { CiudadDestinoId = 0; } EstatusGastoId = Convert.ToInt32(instance.Estatus_Gasto_Id); if (EstatusGastoId == Int32.MinValue) { EstatusGastoId = 5; // 5 = Pendiente } if (instance.Notas_Pago != null) { NotasPago = instance.Notas_Pago; } else { NotasPago = ""; } if (instance.Gastos_Frecuentes_Id != null) { GastosFrecuentesId = Convert.ToInt32(instance.Gastos_Frecuentes_Id); } else { GastosFrecuentesId = 0; } if (instance.Motivo_Pago_Id != null) { motivoPagoId = Convert.ToInt32(instance.Motivo_Pago_Id); } if (instance.Medio_Pago_Id != null) { medioPagoId = Convert.ToInt32(instance.Medio_Pago_Id); } if (instance.Tipo_Comprobante_Id != null) { tipoComprobanteId = Convert.ToInt32(instance.Tipo_Comprobante_Id); } if (instance.Banco_Id != null) { bancoId = Convert.ToInt32(instance.Banco_Id); } if (instance.Numero_Cuenta != null) { numeroCuenta = instance.Numero_Cuenta.ToString(); } if (instance.Clabe != null) { clabe = instance.Clabe.ToString(); } if (instance.A_Nombre_Cheque != null) { aNombreCheque = instance.A_Nombre_Cheque.ToString(); } if (instance.Es_Urgente != null) { esUrgente = Convert.ToBoolean(instance.Es_Urgente); } cmd.Parameters.AddWithValue("@Tipo_Operacion_Id", 1);// ES CREACIÓN NUEVO REGISTRO cmd.Parameters.AddWithValue("@Administracion_Gasto_Id", 0); cmd.Parameters.AddWithValue("@Contratado_Id", instance.Contratado_Id); cmd.Parameters.AddWithValue("@Tipo_Gasto_Id", instance.Tipo_Gasto_Id); cmd.Parameters.AddWithValue("@Monto_Gasto", instance.Monto_Gasto); cmd.Parameters.AddWithValue("@Fecha_Gasto", instance.Fecha_Gasto); cmd.Parameters.AddWithValue("@Latitud", instance.Latitud); cmd.Parameters.AddWithValue("@Longitud", instance.Longitud); cmd.Parameters.AddWithValue("@Direccion_Origen", DireccionOrigen); // cmd.Parameters.AddWithValue("@Direccion_Destino", DireccionDestino); // cmd.Parameters.AddWithValue("@Ciudad_Origen_Id", CiudadOrigenId); cmd.Parameters.AddWithValue("@Ciudad_Destino_Id", CiudadDestinoId); cmd.Parameters.AddWithValue("@Kilometraje", instance.Kilometraje); cmd.Parameters.AddWithValue("@Viaje_Redondo", instance.Viaje_Redondo); cmd.Parameters.AddWithValue("@Estatus_Gasto_Id", EstatusGastoId); // cmd.Parameters.AddWithValue("@Autorizado_Rechazado_Por_Id", UserId); // cmd.Parameters.AddWithValue("@Fecha_Autorizacion_Rechazo", instance.Fecha_Autorizacion_Rechazo); cmd.Parameters.AddWithValue("@Comentarios_Autorizacion_Rechazo", Comentarios); // //PAGO cmd.Parameters.AddWithValue("@Pagado", pagado); // cmd.Parameters.AddWithValue("@Fecha_Pago", DBNull.Value); // cmd.Parameters.AddWithValue("@Notas_Pago", NotasPago); // cmd.Parameters.AddWithValue("@Fecha_Confirmacion_Pago", DBNull.Value); // cmd.Parameters.AddWithValue("@Pago_Confirmado_Por_Id", UserId); //cmd.Parameters.AddWithValue("@Pago_Confirmado_Por_Id", instance.Pago_Confirmado_Por_Id); // cmd.Parameters.AddWithValue("@Estatus_Registro_Id", estatusRegistroId); // //cmd.Parameters.AddWithValue("@Servicio_Id", instance.Servicio_Id); cmd.Parameters.AddWithValue("@Servicio_Id", ValorServicioId); cmd.Parameters.AddWithValue("@Mostrar_Lista_Gastos_Frecuentes", mostrarListaGastosFrecuentes); cmd.Parameters.AddWithValue("@Gastos_Frecuentes_Id", GastosFrecuentesId); cmd.Parameters.AddWithValue("@Es_Gasto_Con_Autorizacion", 0); cmd.Parameters.AddWithValue("@Motivo_Pago_Id", motivoPagoId); cmd.Parameters.AddWithValue("@Tipo_Comprobante_Id", tipoComprobanteId); cmd.Parameters.AddWithValue("@Medio_Pago_Id", medioPagoId); cmd.Parameters.AddWithValue("@Banco_Id", bancoId); cmd.Parameters.AddWithValue("@Numero_Cuenta", numeroCuenta); cmd.Parameters.AddWithValue("@Clabe", clabe); cmd.Parameters.AddWithValue("@Nombre_Cheque", aNombreCheque); cmd.Parameters.AddWithValue("@Es_Urgente", esUrgente); /*Parametros de sistema**/ cmd.Parameters.AddWithValue("@Creado_Por_Id", UserId); cmd.Parameters.AddWithValue("@Transaccion_Id", DBNull.Value); cmd.Parameters.AddWithValue("@Fijar_Bitacora", 1); cmd.Parameters.AddWithValue("@Mostrar_Tablas_Sistema", 0); //cmd.Parameters.Add("@Mensaje_Sistema_Id", 1);//.Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@Mensaje_Sistema_Id", 1); cmd.Parameters.AddWithValue("@Simular", 0); cmd.Parameters.AddWithValue("@Trace", "");//.Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@Debug", 0); cmd.Parameters["@Administracion_Gasto_Id"].Direction = ParameterDirection.Output; cmd.Parameters["@Es_Gasto_Con_Autorizacion"].Direction = ParameterDirection.Output; cmd.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; cmd.Parameters["@Trace"].Direction = ParameterDirection.Output; cmd.Parameters["@Administracion_Gasto_Id"].Size = 4; cmd.Parameters["@Es_Gasto_Con_Autorizacion"].Size = 4; cmd.Parameters["@Mensaje_Sistema_Id"].Size = 4; cmd.Parameters["@Trace"].Size = 8000; con.Open(); cmd.ExecuteNonQuery(); //con.Close(); if (cmd.Parameters["@Mensaje_Sistema_Id"].Value.ToString() != "1") { mensajeSistema = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM [dbo].[Obtener_Mensaje_Sistema_V] WHERE Mensaje_Sistema_Id=" + cmd.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(mensajeSistema); }//if (spSql.Parameters["RetVal"].Value.ToString() != "1") else { administracionGastoId = Convert.ToInt32(cmd.Parameters["@Administracion_Gasto_Id"].Value.ToString()); esGastoConAutorizacion = Convert.ToInt32(cmd.Parameters["@Es_Gasto_Con_Autorizacion"].Value.ToString()); instance.Administracion_Gasto_Id = administracionGastoId; if (esGastoConAutorizacion == 1) { //En caso de que se haya creado con éxito, enviar la solicitud a los autorizadores using (SqlConnection con2 = new SqlConnection(conStr)) { using (SqlCommand cmd2 = new SqlCommand("sp_Administrar_Solicitud_Gasto", con)) { cmd2.CommandType = CommandType.StoredProcedure; cmd2.CommandTimeout = 60 * 10; cmd2.Parameters.AddWithValue("@Tipo_Operacion_Id", 1);// ES ALTA (Para enviar el correo a los autorizadores) cmd2.Parameters.AddWithValue("@Administracion_Gasto_Id", administracionGastoId); cmd2.Parameters.AddWithValue("@Solicitud_Gasto_Key", DBNull.Value); cmd2.Parameters.AddWithValue("@Fecha_Solicitud", DBNull.Value); cmd2.Parameters.AddWithValue("@Estatus_Solicitud_Id", 0); cmd2.Parameters.AddWithValue("@Fecha_Autorizacion_Rechazo", DBNull.Value); cmd2.Parameters.AddWithValue("@Autorizado_Rechazado_Por_Id", UserId); cmd2.Parameters.AddWithValue("@Notas_Autorizacion_Rechazo", DBNull.Value); cmd2.Parameters.AddWithValue("@Monto_Gasto_Autorizado", DBNull.Value); cmd2.Parameters.AddWithValue("@HTML", DBNull.Value); cmd2.Parameters.AddWithValue("@Mensaje_Sistema_Id", 1); cmd2.Parameters.AddWithValue("@Debug", 0); cmd2.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; cmd2.Parameters["@Mensaje_Sistema_Id"].Size = 4; con2.Open(); cmd2.ExecuteNonQuery(); con2.Close(); if (cmd2.Parameters["@Mensaje_Sistema_Id"].Value.ToString() != "1") { mensajeSistema = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM [dbo].[Obtener_Mensaje_Sistema_V] WHERE Mensaje_Sistema_Id=" + cmd2.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(mensajeSistema + " así que no se podrá enviar la solicitud a ningún autorizador."); Result.Refresh(); Result.RefreshChildren(); Result.Continue(); }//if (spSql.Parameters["RetVal"].Value.ToString() != "1") else { Result.ShowAlert("Guardado con éxito"); Result.Refresh(); /*Result.RefreshChildren(); * Result.Continue();*/ } //else if (spSql.Parameters["RetVal"].Value.ToString() != "1") } //using (SqlCommand cmd = new SqlCommand("sp_Administrar_Solicitud_Gasto", con)) } //using (SqlConnection con = new SqlConnection(conStr)) } //if(esGastoConAutorizacion == 1) //Result.ShowAlert("Creación Exitosa"); Result.Refresh(); Result.RefreshChildren(); Result.Continue(); } //else if (spSql.Parameters["RetVal"].Value.ToString() != "1") } // using (SqlCommand cmd = new SqlCommand("sp_Revision_De_Solicitud", con)) } // using (SqlConnection con = new SqlConnection(conStr)) }
public void r105Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (instance.OrderHedID != null) { if (instance.OrderDate != null) { instance.TargetReportingDate = Convert.ToDateTime(instance.OrderDate).AddDays(7); } //Atleast One OrderDtl Line should be there else dont submit int LnCnt = (int)SqlText.ExecuteScalar("Select Count(OrderdtlID) from OrderDtl Where OrderHedID=@OrderHedID" , instance.OrderHedID); if (LnCnt <= 0) { Result.ShowAlert("Requrie minimum one OrderDtl Line to Submit for Approval."); return; } //OrderQty should match with Sum(OrderRelQty) else dont Submit int UnMatchQtyCnt = (int)SqlText.ExecuteScalar("Select Count(UnMatchQty) as UnMatchQtyCnt from ( select OrderDtlID,a.OrderQty,isnull((Select Sum(x.OrderRelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0) as TotalRelQty,(a.OrderQty - isnull((Select Sum(x.OrderRelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0)) as UnMatchQty from OrderDtl a where a.OrderHedID=@OrderHedID ) as Y Where Y.UnMatchQty <> 0 " , instance.OrderHedID); if (UnMatchQtyCnt > 0) { Result.ShowAlert("OrderQty is not matching OrderRel Qty."); return; } //OrderFOCQty should match with Sum(OrderRelFOCQty) else dont Submit int UnMatchFOCQtyCnt = (int)SqlText.ExecuteScalar("Select Count(UnMatchQty) as UnMatchQtyCnt from ( select OrderDtlID,a.Focqty,isnull((Select Sum(x.FocrelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0) as TotalRelQty,(a.Focqty - isnull((Select Sum(x.FocrelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0)) as UnMatchQty from OrderDtl a where a.OrderHedID=@OrderHedID ) as Y Where Y.UnMatchQty <> 0 " , instance.OrderHedID); if (UnMatchFOCQtyCnt > 0) { Result.ShowAlert("Order FOCQty is not matching OrderRel FOCQty."); return; } instance.Exception = false; instance.ExceptionDtl = string.Empty; //1. Credit Limit Exception int creditEx = (int)SqlText.ExecuteScalar("select isnull(Case When a.UnPaidInvoices > a.CreditLimit2 Then 1 Else 0 End,0) From vwCustomer a inner join OrderHed b on a.SysRowID=b.CustSysRowID Where b.OrderHedID=@OrderHedID" , instance.OrderHedID); if (creditEx > 0) { instance.Exception = true; instance.ExceptionDtl = "CreditLimit"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, creditEx); } //2. Terms Exception int termsEx = (int)SqlText.ExecuteScalar("select isnull(Case When a.TermsExceed=1 Then 2 Else 0 End,0) From vwCustomer a inner join OrderHed b on a.SysRowID=b.CustSysRowID Where b.OrderHedID=@OrderHedID" , instance.OrderHedID); if (termsEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl)?"Terms":", Terms"; //int i=SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, termsEx); } //3. BasePrice Exception int basePriceEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 3 Else 0 End,0) from OrderDtl where ProposedBasePrice < BasePrice and OrderHedID=@OrderHedID" , instance.OrderHedID); if (basePriceEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "BasePrice" : ", BasePrice"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, basePriceEx); } //4. SellingPrice Exception int sellingPriceEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 4 Else 0 End,0) from OrderDtl where ProposedSellingPrice < SellingPrice and OrderHedID=@OrderHedID" , instance.OrderHedID); if (sellingPriceEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "SellingPrice" : ", SellingPrice"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, sellingPriceEx); } //5. FOC Qty Exception int focQtyEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 5 Else 0 End,0) from OrderDtl where FOCQty>0 and OrderHedID=@OrderHedID" , instance.OrderHedID); if (focQtyEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "FOCQty" : ", FOCQty"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, sellingPriceEx); } //6. FOC Part Item Exception int focPartItemEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 6 Else 0 End,0) from OrderDtl where (BasePrice<=1 Or SellingPrice <=1) and OrderHedID=@OrderHedID" , instance.OrderHedID); if (focPartItemEx > 0) { //instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "FOCPartItem" : ", FOCPartItem"; } //Approval //2 - Waiting For Price Change , 5 - Waiting For Lv1 Approval int ordStatus = (basePriceEx > 0 || sellingPriceEx > 0 || focQtyEx > 0 || focPartItemEx > 0) ? 2 : 5; string comm = (basePriceEx > 0 || sellingPriceEx > 0 || focQtyEx > 0 || focPartItemEx > 0) ? "Submitted For Price Change" : "Submitted For Approval"; SqlText.ExecuteNonQuery("Update OrderHed Set Exception=@Exception,ExceptionDtl=@ExceptionDtl,OrderStatusID=@OrderStatusID Where OrderHedID=@OrderHedID ", new { instance.Exception, instance.ExceptionDtl, @OrderHedID = instance.OrderHedID, @OrderStatusID = ordStatus }); SqlText.ExecuteNonQuery( "Insert into OrderStatusLog (OrderHedID,UserID,[Comment],[RejectReason],[OtherRemarks],[TranDate]) Values " + "(@OrderHedID,@UserID,@Comment,@RejectReason,@OtherRemarks,@TranDate) " , new { @OrderHedID = instance.OrderHedID, @UserID = UserId, @Comment = comm, @RejectReason = "", @OtherRemarks = "", @TranDate = DateTime.Now }); Result.ShowAlert("OrderNo : {0} {1}", instance.OrderHedID, comm); } else { Result.ShowAlert("Please Select Row!"); } Result.Refresh(); }
public void r101Implementation(Persona_DomicilioModel instance) { // This is the placeholder for method implementation. using (SqlProcedure sql = new SqlProcedure("dbo.sp_Creacion_Domicilio_Persona")) { sql.Command.CommandTimeout = 60 * 10; //Definición parametro especial para recibir el RETURN del SP sql.AddParameter("RetVal", 0); sql.Parameters["RetVal"].Direction = ParameterDirection.ReturnValue; //Definición de Parametros especificos del SP // //sql.AddParameter("@Producto_Nombre", instance.Producto_); sql.AddParameter("@Tipo_Operacion_Id", 1);// 1. INSERT sql.AddParameter("@Persona_Id", instance.Persona_Id); sql.AddParameter("@Calle", instance.Custom_Domicilio_Calle); sql.AddParameter("@Numero_Interior", instance.Custom_Domicilio_Numero_Interior); sql.AddParameter("@Numero_Exterior", instance.Custom_Domicilio_Numero_Exterior); sql.AddParameter("@Colonia", instance.Custom_Domicilio_Colonia); sql.AddParameter("@Ciudad_Id", instance.Custom_Domicilio_Ciudad_Id); sql.AddParameter("@Codigo_Postal_Id", instance.Custom_Domicilio_Codigo_Postal_Id); sql.AddParameter("@Entre_Calles", instance.Custom_Domicilio_Entre_Calles); sql.AddParameter("@Latitud", instance.Custom_Domicilio_Latitud); sql.AddParameter("@Longitud", instance.Custom_Domicilio_Longitud); sql.AddParameter("@Tipo_Domicilio_Id", instance.Tipo_Domicilio_Id); sql.AddParameter("@Es_Domicilio_Principal", instance.Es_Domicilio_Principal); //------------------------- //Definición de parámetros de Salida sql.AddParameter("@Persona_Domicilio_Id", instance.Persona_Domicilio_Id); sql.AddParameter("@Estatus_Registro_Id", 1); sql.AddParameter("@Domicilio_Id", 0); //Definición de parametros de Sistema sql.AddParameter("@Creado_Por_Id", UserId); sql.AddParameter("@Transaccion_Id", DBNull.Value); sql.AddParameter("@Fijar_Bitacora", 1); sql.AddParameter("@Mostrar_Tablas_Sistema", 0); sql.AddParameter("@Mensaje_Sistema_Id", 0); sql.AddParameter("@Simular", 0); sql.AddParameter("@Trace", ""); sql.AddParameter("@Debug", 0); //Definición de dirección para parametros de salida //sql.Parameters["@Persona_Domicilio_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Trace"].Direction = ParameterDirection.Output; //Definición de tamaños que soporten los tipos de datos de los parametros del salida del SP sql.Parameters["@Mensaje_Sistema_Id"].Size = 4; sql.Parameters["@Trace"].Size = 8000; sql.ExecuteNonQuery(); if (sql.Parameters["RetVal"].Value.ToString() != "1") { String ErrorMessage = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM dbo.Mensaje_Sistema WHERE Mensaje_Sistema_Id=" + sql.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(ErrorMessage); } else { Result.Continue(); } }// using (SqlProcedure sql = new SqlProcedure("dbo.sp_Creacion_Domicilio_Persona")) }
public void r105Implementation(PersonaModel instance) { // This is the placeholder for method implementation. using (SqlProcedure sql = new SqlProcedure("dbo.sp_Administrar_Persona_Contacto")) { sql.Command.CommandTimeout = 60 * 10; //Definición parametro especial para recibir el RETURN del SP sql.AddParameter("RetVal", 0); sql.Parameters["RetVal"].Direction = ParameterDirection.ReturnValue; //Definición de Parametros especificos del SP // //sql.AddParameter("@Producto_Nombre", instance.Producto_); sql.AddParameter("@Tipo_Operacion_Id", 1);// 1. INSERT sql.AddParameter("@Nombre", instance.Nombre); sql.AddParameter("@Apellido_Paterno", instance.Apellido_Paterno); sql.AddParameter("@Apellido_Materno", instance.Apellido_Materno); sql.AddParameter("@Segundo_Nombre", instance.Segundo_Nombre); sql.AddParameter("@Fecha_Nacimiento", instance.Fecha_Nacimiento); sql.AddParameter("@Maximo_Nivel_Escolaridad_Id", instance.Maximo_Nivel_Escolaridad_Id); sql.AddParameter("@Genero_Persona_Id", instance.Genero_Persona_Id); sql.AddParameter("@Correo_Personal", instance.Correo_Personal); sql.AddParameter("@Numero_Celular_Personal", instance.Numero_Celular_Personal); //------------------------- //Definición de parámetros de Salida sql.AddParameter("@Persona_Jefe_Id", instance.Persona_Id); //Definición de parametros de Sistema sql.AddParameter("@Creado_Por_Id", UserId); sql.AddParameter("@Transaccion_Id", DBNull.Value); sql.AddParameter("@Fijar_Bitacora", 1); sql.AddParameter("@Mostrar_Tablas_Sistema", 0); sql.AddParameter("@Mensaje_Sistema_Id", 0); sql.AddParameter("@Simular", 0); sql.AddParameter("@Trace", ""); sql.AddParameter("@Debug", 0); //Definición de dirección para parametros de salida //sql.Parameters["@Persona_Domicilio_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Mensaje_Sistema_Id"].Direction = ParameterDirection.Output; sql.Parameters["@Trace"].Direction = ParameterDirection.Output; //Definición de tamaños que soporten los tipos de datos de los parametros del salida del SP sql.Parameters["@Mensaje_Sistema_Id"].Size = 4; sql.Parameters["@Trace"].Size = 8000; sql.ExecuteNonQuery(); if (sql.Parameters["RetVal"].Value.ToString() != "1") { String ErrorMessage = SqlText.ExecuteScalar("SELECT Mensaje_Amigable_Usuario FROM dbo.Mensaje_Sistema WHERE Mensaje_Sistema_Id=" + sql.Parameters["@Mensaje_Sistema_Id"].Value.ToString()).ToString(); Result.ShowAlert(ErrorMessage); } else { Result.Continue(); } }// using (SqlProcedure sql = new SqlProcedure("dbo.sp_Administrar_Persona_Contacto")) /* * bool resultadoAdministrarPersonaContacto; * string mensajeSistema = ""; * int mensajeSistemaId = 0; * int tipoOperacionId = 1; * string nombre = instance.Nombre; * string apellidoPaterno = instance.Apellido_Paterno; * string apellidoMaterno = instance.Apellido_Materno; * string segundoNombre = instance.Segundo_Nombre; * DateTime fechaNacimiento = (DateTime)instance.Fecha_Nacimiento; * int maximoNivelEscolaridadId = (int)instance.Maximo_Nivel_Escolaridad_Id; * int generoPersonaId = (int)instance.Genero_Persona_Id; * string correoPersonal = instance.Correo_Personal; * string numeroCelularPersonal = instance.Numero_Celular_Personal; * int personaId = 0; * SharedBusinessRules sb = new SharedBusinessRules(); * * resultadoAdministrarPersonaContacto = sb.AdministrarPersonaContacto( * tipoOperacionId * , nombre * , apellidoPaterno * , apellidoMaterno * , segundoNombre * , fechaNacimiento * , maximoNivelEscolaridadId * , generoPersonaId * , correoPersonal * , numeroCelularPersonal * , out personaId * , out mensajeSistema * , out mensajeSistemaId * ); * if (resultadoAdministrarPersonaContacto) * { * //Result.ShowAlert(mensajeSistema); * Result.Continue(); * // Result.Refresh(); * }//if (resultadoAdministrarPersonaContacto) * else//if (!resultadoAdministrarPersonaContacto) * { * Result.ShowAlert(mensajeSistema); * }//if (!resultadoAdministrarPersonaContacto) */ }