private bool fncGuardar() { string str1 = "1"; string str2 = "1"; string sSQL = ""; string sSQL2 = ""; string sSQL3 = ""; string sSQL4 = ""; string sSQL5 = ""; string sSQL6 = ""; //if (fncValidar() == false) // return false; List <SqlParameter> pars = new List <SqlParameter>(); List <SqlParameter> pars2 = new List <SqlParameter>(); List <SqlParameter> pars3 = new List <SqlParameter>(); //RadWindow.Alert(new DialogParameters() //{ // Content = "Producto Guardado \n\n o Exitosamente del sistema", // Header = "GGGC" // // IconContent = ""; //}); // RadMessageBox.Show(this, "My Message", "Window title", //MessageBoxButton.OK, MessageBoxImage.Information); try { string strOrderID = strFolioOrden; string strCustomerID = customerInfo.CustomerID; string strPrefix = "P"; string strSufix = "S"; long lngTicks = DateTime.Now.Ticks; string strCustomer = customerInfo.Name; string strInvoiceNumber = txtPlacas.Text.Trim(); string strPaymentConditionID = "0"; string strDeliveryMetodID = "0"; DateTime dteInvoiceDate = Convert.ToDateTime(customerInfo.Date); //customerInfo.Date.ToString("d"); DateTime dteReceptionDate = customerInfo.DueDate; DateTime dteDueDate = DateTime.Now; DateTime dteAccountingDate = DateTime.Now; decimal decDiscount = 0; int intOrderQty = 0; decimal decSubtotal = 0; decimal decTax = 0; decimal decTotal = 0; decimal decRaiting = 0; int intQuarterID = 0; int intCompanyID = Convert.ToInt32(customerInfo.CompanyID); byte bytStoreID = Convert.ToByte(GlobalModule.ActualStoreID); byte bytRevisioNumber = 0; string strComments = customerInfo.Observaciones; int intUserID = GlobalModule.ActualUserID; string strLocalIP = GlobalModule.GetLocalIP(); string strPublicIP = GlobalModule.getPublicIP(); string strSystemInfo = GlobalModule.GetSystemInfo(); string strUserInfo = GlobalModule.GetUserInfo(); DateTime dteInsertDate = DateTime.Now; DateTime dteModifiedDate = DateTime.Now; DateTime dteLastUpDate = DateTime.Now; byte bytStatusID = 0; byte bytDeleteFlag = 0; Guid guidRowID = Guid.NewGuid(); int zero = 0; if (customerInfo.Observaciones == null) { strComments = ""; } // Detail // m_items, supplierInfo //string strCodigo = this.txtCodigo.Text.Trim(); //string strID = this.txtID.Text.Trim(); //string strDesc = this.txtDescripcion.Text.Trim(); //string strGUID = Guid.NewGuid().ToString(); //string strObs = "obs"; //string strMarca = "MMRF"; //int productID = Convert.ToInt32(this.txtID.Text); //double decRin = 0.0; //byte bytCero = 0; //bool blnCentralesOK = false; //bool blnSucursalesOK = false; //bool b1 = false, b2 = false, b3 = false, b4 = false, b5 = false, b6 = false, b7 = false, b8 = false, b9 = false, b10 = false, b11 = false, b12 = false, b13 = false, b14 = false, b15 = false; //string strLinea = cboLine.SelectedValue.ToString(); //switch (strLinea) //{ // case "1": // strLinea = "02001"; // break; // default: // strLinea = "02001"; // break; //} if (true) { //_idEmpresa = 2;//datos.BaseDatos.SelectMaxID("idEmpresa", "Empresas"); //_idSucursal = 6; sSQL = "INSERT INTO mto_SalesOrderHeader ([OrderID], [CustomerID], [Customer], [EmployeeID], [RFC], [InvoiceNumber], [Prefix],[Sufix],[Ticks], [PaymentConditionID],[DeliveryMethodID],[OrderDate],[DueDate],[RequiredDate], [AccountingDate], [Discount],[OrderQty],[Subtotal],[Tax],[Total],[Raiting],[QuarterID], [CompanyID], [DepartmentID], [VehiculoID], [Vehiculo], [Placas], [Kilometraje], [StoreID],[RevisionNumber],[Comments],[UserID],[LocalIP], [PublicIP],[SystemInfo], [UserInfo],[InsertDate],[ModifiedDate], [LastUpdate], [StatusID],[DeletedFlag],[RowID]) " + "VALUES (@OrderID, @CustomerID, @Customer, @EmployeeID, @Rfc, @InvoiceNumber, @Prefix, @Sufix, @Ticks, @PaymentConditionID, @DeliveryMethodID, @OrderDate, @DueDate, @RequiredDate, @AccountingDate, @Discount, @OrderQty, @Subtotal, @Tax, @Total, @Raiting, @QuarterID, @CompanyID, @DepartmentID, @VehicleID, @Vehiculo, @Placas, @kilometraje, @StoreID, @RevisionNumber,@Comments, @UserID, @LocalIP, @PublicIP, @SystemInfo, @UserInfo, @InsertDate, @ModifiedDate, @LastUpdate, @StatusID, @DeletedFlag, @RowID )"; } else { //sSQL = "UPDATE Empresas SET Nombre = @Nombre, RFC = @RFC, Calle = @Calle, NumExt = @NumExt, NumInt = @NumInt, Colonia = @Colonia, " + // "Localidad = @Localidad, Municipio = @Municipio, Estado = @Estado, Pais = @Pais, CP = @CP, Referencia = @Referencia, ModoPrueba = @ModoPrueba, RutaTrabajo = @RutaTrabajo WHERE (idEmpresa = " + _idEmpresa + ")"; } //, , , ,, , , , , , , , , , , @RowID )"; pars.Clear(); pars.Add(new SqlParameter("@OrderID", strOrderID)); pars.Add(new SqlParameter("@CustomerID", strCustomerID)); pars.Add(new SqlParameter("@Customer", strCustomer)); pars.Add(new SqlParameter("@EmployeeID", zero)); pars.Add(new SqlParameter("@Rfc", "")); pars.Add(new SqlParameter("@InvoiceNumber", "")); pars.Add(new SqlParameter("@Prefix", strPrefix)); pars.Add(new SqlParameter("@Sufix", strSufix)); pars.Add(new SqlParameter("@Ticks", lngTicks)); pars.Add(new SqlParameter("@PaymentConditionID", strPaymentConditionID)); pars.Add(new SqlParameter("@DeliveryMethodID", strDeliveryMetodID)); pars.Add(new SqlParameter("@OrderDate", dteInvoiceDate)); //pars.Add(new SqlParameter("@ReceptionDate", dteReceptionDate)); pars.Add(new SqlParameter("@DueDate", dteDueDate)); pars.Add(new SqlParameter("@RequiredDate", dteDueDate)); pars.Add(new SqlParameter("@AccountingDate", dteAccountingDate)); pars.Add(new SqlParameter("@Discount", decDiscount)); pars.Add(new SqlParameter("@OrderQty", intOrderQty)); pars.Add(new SqlParameter("@Subtotal", decSubtotal)); pars.Add(new SqlParameter("@Tax", decTax)); pars.Add(new SqlParameter("@Total", decTotal)); pars.Add(new SqlParameter("@Raiting", decRaiting)); pars.Add(new SqlParameter("@QuarterID", intQuarterID)); pars.Add(new SqlParameter("@CompanyID", intCompanyID)); pars.Add(new SqlParameter("@DepartmentID", Convert.ToInt32(customerInfo.SucursalID))); pars.Add(new SqlParameter("@VehicleID", Convert.ToInt32(customerInfo.VehiculoID))); pars.Add(new SqlParameter("@Vehiculo", customerInfo.Vehiculo)); pars.Add(new SqlParameter("@Placas", customerInfo.Placas)); pars.Add(new SqlParameter("@Kilometraje", zero)); pars.Add(new SqlParameter("@StoreID", bytStoreID)); pars.Add(new SqlParameter("@RevisionNumber", bytRevisioNumber)); pars.Add(new SqlParameter("@Comments", strComments)); pars.Add(new SqlParameter("@UserID", intUserID)); pars.Add(new SqlParameter("@LocalIP", strLocalIP)); pars.Add(new SqlParameter("@PublicIP", strPublicIP)); pars.Add(new SqlParameter("@SystemInfo", strSystemInfo)); pars.Add(new SqlParameter("@UserInfo", strUserInfo)); pars.Add(new SqlParameter("@InsertDate", dteInsertDate)); pars.Add(new SqlParameter("@ModifiedDate", dteModifiedDate)); pars.Add(new SqlParameter("@LastUpdate", dteLastUpDate)); pars.Add(new SqlParameter("@DeletedFlag", bytDeleteFlag)); pars.Add(new SqlParameter("@StatusID", bytStatusID)); pars.Add(new SqlParameter("@RowID", guidRowID)); // pars2.Clear(); AccesoDatos sCen = new AccesoDatos(6); sCen.BaseDatos.Ejecuta(sSQL, pars.ToArray()); pars.Clear(); //Agregar registros del detalle decimal cantidad = 0, valorUnitario = 0, importe = 0; string descripcion, unidad, codigo, obs; int productID = 0; int intZero = 0; int intFilas = m_items.Count; for (int i = 0; i < intFilas; i++) { productID = m_items[i].ProductID; codigo = m_items[i].CodeID; descripcion = m_items[i].ItemName; obs = m_items[i].Observ; cantidad = m_items[i].Quantity; importe = m_items[i].UnitPrice; if (obs == null) { obs = ""; } sSQL2 = "INSERT INTO mto_SalesOrderDetail ([SalesOrderID],[SalesOrderDetailID],[ProductID], [CodeID], [ProductDescription], [Comments], [UnitID], [OrderQty], [RejectedQty],[Qty] ,[Discount],[UnitPrice],[ModifiedDate],[LastUpdate],[RowID]) " + "VALUES (@OrderID, @OrderDetailID, @ProductID, @CodeID, @ProductDescription, @Comments, @UnitID, @OrderQty, @RejectedQty, @Qty, @Discount, @UnitPrice, @ModifiedDate, @LastUpdate, @RowID )"; pars.Clear(); pars.Add(new SqlParameter("@OrderID", strOrderID)); pars.Add(new SqlParameter("@OrderDetailID", i + 1)); pars.Add(new SqlParameter("@ProductID", productID)); pars.Add(new SqlParameter("@CodeID", codigo)); pars.Add(new SqlParameter("@ProductDescription", descripcion)); pars.Add(new SqlParameter("@Comments", obs)); pars.Add(new SqlParameter("@UnitID", intZero)); pars.Add(new SqlParameter("@OrderQty", cantidad)); pars.Add(new SqlParameter("@RejectedQty", intZero)); pars.Add(new SqlParameter("@Qty", cantidad)); pars.Add(new SqlParameter("@Discount", intZero)); pars.Add(new SqlParameter("@UnitPrice", importe)); pars.Add(new SqlParameter("@ModifiedDate", dteModifiedDate)); pars.Add(new SqlParameter("@LastUpdate", DateTime.Now)); pars.Add(new SqlParameter("@RowID", Guid.NewGuid())); sCen.BaseDatos.Ejecuta(sSQL2, pars.ToArray()); pars.Clear(); //datos.BaseDatos.Ejecuta(sSQL, pars.ToArray()); } //sCen.BaseDatos.Ejecuta(sSQL2, pars.ToArray()); //pars.Clear(); sCen.BaseDatos.Ejecuta("UPDATE mtto_Config SET SalesOrderID = SalesOrderID + 1", pars.ToArray()); //Application.Current.Dispatcher.Invoke(new Action(() => updateLabel("Guardando en Servidor LRG..."))); //this.Dispatcher.Invoke(DispatcherPriority.Normal, // (System.Windows.Forms.MethodInvoker)delegate() // { // }); // string strMail = "<p>Alta de Artículo</p> <p>Codigo_De_Articulo:<b> " + productID + "</b></p>" + "<p>Descripción: " + strDesc + "</p> <font color=\"#08088A\"> Fecha:" + DateTime.Now.ToLongDateString() + ", " + DateTime.Now.ToLongTimeString() + "</font> <p>...</p>"; AccesoDatos sPV = null; return(true); } catch (Exception ex) { // throw new Exception("Error al Guardar: " + ex.Message); //RadWindow.Alert(new DialogParameters() //{ // Content = "La requisicion puede estar duplicada \n\n o esta pendiente habilitar mas funciones del sistema", // Header = "GGGC" // // IconContent = ""; //}); MessageBox.Show("Mensaje error: " + ex.Message); } return(false); }
public EditCatalogServicesViewModel(IServiceFactory serviceFactory, Service obj) { _ServiceFactory = serviceFactory; try { //13nov 80 898 GlobalModule.ActualStoreID = "2"; GlobalModule.ActualUserID = 898131180; int intID = Math.Abs(Guid.NewGuid().GetHashCode()); //if (intID < 0) // intID = intID * -1; _Obj = new Service() { EntityKey = obj.EntityKey, ProductID = intID, ClassID = 0, GroupID = 0, LineID = 0, BrandID = 0, UnitID = 0, CodeID = "", Description = "", Prefix = "SERV", Sufix = "", TaxID = 0.16M, OnStock = 1, Editable = 0, Comments = "", UserID = GlobalModule.ActualUserID, LocalIP = GlobalModule.GetLocalIP(), PublicIP = GlobalModule.getPublicIP(), SystemInfo = GlobalModule.GetSystemInfo(), UserInfo = GlobalModule.GetUserInfo(), InsertDate = DateTime.Now,//Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")), ModifiedDate = DateTime.Now, LastUpdate = DateTime.Now, StatusID = 0, DeletedFlag = 0, RowID = Guid.NewGuid() //DepartmentID = obj.DepartmentID, //Subject = "",//obj.Subject, Convert.ToInt32(DateTime.Now.Ticks) //Body = obj.Body, //StoreID = Convert.ToByte(GlobalModule.ActualStoreID), //UserID = GlobalModule.ActualUserID, //PriorityID = obj.PriorityID, //OrderStatusID = 1, //Rating = obj.Rating, //SystemInfo = GlobalModule.GetSystemInfo(), //UserInfo = GlobalModule.GetUserInfo(), //Problem = " ", //Solution = " ", //Tags = "", //LocalIP = GlobalModule.GetLocalIP(), //PublicIP = GlobalModule.getPublicIP(), //Comments = "", //StatusID = 0, //DeletedFlag = 0, //ResourcesQty = 0, //OrderDate = DateTime.Now, //StartDate = DateTime.Now, //EndDate = DateTime.Now, //ClosedDate = DateTime.Now, //ModifiedDate = DateTime.Now, //InsertDate = DateTime.Now,//Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")), //LastUpdate = DateTime.Now,//Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")), //RowID = obj.RowID //Guid.NewGuid() //Color = car.Color, //Year = car.Year, //RentalPrice = car.RentalPrice }; if (obj.RowID == Guid.Empty) { _Obj.RowID = Guid.NewGuid(); } _Obj.CleanAll(); //00000000-0000-0000-0000-000000000000 } catch (Exception ex) { throw new Exception("Error " + ex.ToString()); } SaveCommand = new DelegateCommand <object>(OnSaveCommandExecute, OnSaveCommandCanExecute); CancelCommand = new DelegateCommand <object>(OnCancelCommandExecute); }