예제 #1
0
 public void FromObject()
 {
     Assert.Equal(0d, DoubleType.FromObject(null));
     Assert.Equal(-1d, DoubleType.FromObject(true));
     Assert.Equal(123d, DoubleType.FromObject((byte)123));
     Assert.Equal(123d, DoubleType.FromObject((short)123));
     Assert.Equal(123d, DoubleType.FromObject((int)123));
     Assert.Equal(123d, DoubleType.FromObject((long)123));
     Assert.Equal(123d, DoubleType.FromObject((float)123));
     Assert.Equal(123d, DoubleType.FromObject((double)123));
     Assert.Equal(123d, DoubleType.FromObject((decimal)123));
     Assert.Equal(123d, DoubleType.FromObject("123"));
 }
예제 #2
0
        // Format a percentage value.
        public static String FormatPercent
            (Object Expression,
            [Optional][DefaultValue(-1)] int NumDigitsAfterDecimal,
            [Optional][DefaultValue(TriState.UseDefault)]
            TriState IncludeLeadingDigit,
            [Optional][DefaultValue(TriState.UseDefault)]
            TriState UseParensForNegativeNumbers,
            [Optional][DefaultValue(TriState.UseDefault)]
            TriState GroupDigits)
        {
            NumberFormatInfo nfi        = CultureInfo.CurrentCulture.NumberFormat;
            NumberFormatInfo nfiCurrent = nfi;

            if (NumDigitsAfterDecimal != -1)
            {
                nfi = (NumberFormatInfo)(nfi.Clone());
                nfi.PercentDecimalDigits = NumDigitsAfterDecimal;
            }
            if (UseParensForNegativeNumbers != TriState.UseDefault)
            {
                if (nfi == nfiCurrent)
                {
                    nfi = (NumberFormatInfo)(nfi.Clone());
                }
                if (UseParensForNegativeNumbers == TriState.False)
                {
                    nfi.PercentNegativePattern = 0;
                }
                else
                {
                    nfi.PercentNegativePattern = 1;
                }
            }
            if (GroupDigits != TriState.UseDefault)
            {
                if (nfi == nfiCurrent)
                {
                    nfi = (NumberFormatInfo)(nfi.Clone());
                }
                if (GroupDigits == TriState.False)
                {
                    nfi.PercentGroupSizes = new int [] { 0 };
                }
                else
                {
                    nfi.PercentGroupSizes = new int [] { 3 };
                }
            }
            return(DoubleType.FromObject(Expression).ToString("P", nfi));
        }
예제 #3
0
파일: Conversion.cs 프로젝트: ForNeVeR/pnet
        public static Object Int(Object Number)
        {
            if (Number == null)
            {
                throw new ArgumentNullException("Number");
            }
            switch (ObjectType.GetTypeCode(Number))
            {
            case TypeCode.Boolean:
            case TypeCode.Char:
            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
                return(Int(IntegerType.FromObject(Number)));

            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
                return(Number);

            case TypeCode.Single:
                return(Int(SingleType.FromObject(Number)));

            case TypeCode.Double:
                return(Int(DoubleType.FromObject(Number)));

            case TypeCode.Decimal:
                return(Int(DecimalType.FromObject(Number)));

            case TypeCode.String:
                return(Int(DoubleType.FromString
                               (StringType.FromObject(Number))));
            }
            throw new ArgumentException(S._("VB_InvalidNumber"), "Number");
        }
예제 #4
0
 public void FromObject_Invalid()
 {
     Assert.Throws <InvalidCastException>(() => DoubleType.FromObject('1'));
     Assert.Throws <InvalidCastException>(() => DoubleType.FromObject(DateTime.MinValue));
     Assert.Throws <InvalidCastException>(() => DoubleType.FromObject(Guid.Empty));
 }
예제 #5
0
        private void cmbAceptar_Click(object sender, EventArgs e)
        {
            SqlConnection  connection;
            SqlConnection  connection2;
            SqlConnection  connection3;
            SqlTransaction transaction;
            bool           flag  = false;
            bool           flag3 = false;
            bool           flag2 = false;
            bool           flag4 = false;

            this.dgBultos.Enabled   = false;
            this.cmbAceptar.Enabled = false;
            this.cmbSalir.Enabled   = false;
            try
            {
                SqlCommand    command;
                DataRow       row;
                int           num;
                SqlDataReader reader;
                int           num8;
                string        str7;
                DataSet       dataSet = new DataSet("PruebaSQL");
                connection2 = new SqlConnection("data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=True;packet size=4096");
                connection2.Open();
                flag3       = true;
                connection3 = new SqlConnection("data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=edibar;persist security info=True;packet size=4096");
                connection3.Open();
                flag4 = true;
                new SqlDataAdapter("select NroOC,NroLinea,Codigo,sum(CantRec) as CantRec from Bultos where PackList='" + Variables.gPackList + "' group by NroOC,NroLinea,Codigo", connection2).Fill(dataSet, "Bultos");
                transaction = connection2.BeginTransaction();
                flag        = true;
                connection  = new SqlConnection("data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=scalaDB;persist security info=True;packet size=4096");
                connection.Open();
                flag2 = true;
                int num10 = dataSet.Tables["Bultos"].Rows.Count - 1;
                for (num = 0; num <= num10; num++)
                {
                    row     = dataSet.Tables["Bultos"].Rows[num];
                    command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC01067 FROM dbo.SC010100 where SC01001='", row["Codigo"]), "'")), connection);
                    reader  = command.ExecuteReader();
                    if (reader.Read())
                    {
                        Variables.gPaisOrigen = StringType.FromObject(reader["SC01067"]);
                        reader.Close();
                    }
                    else
                    {
                        Variables.gPaisOrigen = "";
                        reader.Close();
                    }
                    command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT PC03001,PC03002,PC03005,PC03006,PC03007,PC03010,PC03011,PC03016 FROM dbo.PC030100 where PC03001='", row["NroOC"]), "' and PC03002='"), row["NroLinea"]), "' and PC03010<>0 and PC03010-PC03011<>0")), connection);
                    reader  = command.ExecuteReader();
                    if (reader.Read())
                    {
                        if (ObjectType.ObjTst(row["CantRec"], ObjectType.SubObj(reader["PC03010"], reader["PC03011"]), false) == 0)
                        {
                            double num2;
                            double num3;
                            string str4;
                            string str5;
                            double num4;
                            double num6;
                            double num7;
                            string str3 = (((((StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(StringType.FromObject(row["NroOC"]), reader["PC03002"]), Strings.Space(6 - Strings.Len(RuntimeHelpers.GetObjectValue(reader["PC03002"]))))), row["Codigo"]), Strings.Space(0x23 - Strings.Len(RuntimeHelpers.GetObjectValue(row["Codigo"]))))) + Strings.Format(RuntimeHelpers.GetObjectValue(row["CantRec"]), "00000000000.00000000") + Strings.Format(DateAndTime.get_Now(), "ddMMyyyy")) + Variables.gDespacho + Strings.Space(0x19 - Strings.Len(Variables.gDespacho))) + Strings.Format(Variables.gFechaImp, "ddMMyyyy")) + Variables.gPaisOrigen + Strings.Space(11 - Strings.Len(Variables.gPaisOrigen))) + Variables.gCodAduana + Strings.Space(10 - Strings.Len(Variables.gCodAduana))) + Strings.Format(DateAndTime.get_Now(), "ddMMyyyy") + "\r" + "\n";
                            string str6 = StringType.FromObject(reader["PC03002"]);
                            reader.Close();
                            StreamWriter writer = new StreamWriter(Variables.gPathTxt + @"\ocompra.prn", true);
                            writer.Write(str3);
                            writer.Close();
                            command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC03058,SC03060 FROM dbo.SC030100 where SC03001='", row["Codigo"]), "' and SC03002='01'")), connection);
                            reader  = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num3 = DoubleType.FromObject(reader["SC03058"]);
                                num7 = DoubleType.FromObject(reader["SC03060"]);
                            }
                            else
                            {
                                num3 = 0.0;
                                num7 = 0.0;
                            }
                            reader.Close();
                            command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC03058,SC03060 FROM dbo.SC030100 where SC03001='", row["Codigo"]), "' and SC03002='02'")), connection);
                            reader  = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num2 = DoubleType.FromObject(reader["SC03058"]);
                                num6 = DoubleType.FromObject(reader["SC03060"]);
                            }
                            else
                            {
                                num2 = 0.0;
                                num6 = 0.0;
                            }
                            reader.Close();
                            command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC01055,SC01056,SYCD010 FROM dbo.SC010100,SYCD0100 where SC01001='", row["Codigo"]), "' and SC01056=SYCD001")), connection);
                            reader  = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num4 = DoubleType.FromObject(reader["SC01055"]);
                                str5 = StringType.FromObject(reader["SC01056"]);
                                str4 = StringType.FromObject(reader["SYCD010"]);
                            }
                            else
                            {
                                num4 = 0.0;
                                str5 = "";
                                str4 = "";
                            }
                            reader.Close();
                            command             = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("insert into MercRec (NroOC,NroLinea,Codigo,CantRec,FechaRec,Despacho,CostoUnitLoc,CostoUnitExp,PrecioCpra,MonedaCpra,DescMonedaCpra,SobreCostoLoc,SobreCostoExp,PrecioUnitProv,PackList) values ('", row["NroOC"]), "','"), str6), "','"), row["Codigo"]), "',"), row["CantRec"]), ",'"), Strings.Format(DateAndTime.get_Now(), "MM/dd/yyyy")), "','"), Variables.gDespacho), "',"), num3), ","), num2), ","), num4), ",'"), str5), "','"), str4), "',"), num7), ","), num6), ",0,'"), Variables.gPackList), "')")), connection2);
                            command.Transaction = transaction;
                            num8 = command.ExecuteNonQuery();
                        }
                        else
                        {
                            str7 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("insert into Recepcion select NroBulto,NroOC,NroLinea,Codigo,Desc1,Desc2,", ObjectType.SubObj(reader["PC03010"], reader["PC03011"])), ",CantRec,'"), Strings.Format(DateAndTime.get_Now(), "MM/dd/yyyy")), "',0,0,0,'"), Variables.gDespacho), "','"), Strings.Format(Variables.gFechaImp, "MM/dd/yyyy")), "','"), Variables.gCodAduana), "','"), Variables.gPaisOrigen), "','"), Variables.gPackList), "' from Bultos where PackList='"), Variables.gPackList), "' and NroOC='"), row["NroOC"]), "' and Codigo='"), row["Codigo"]), "'"));
                            reader.Close();
                            command             = new SqlCommand(str7, connection2);
                            command.Transaction = transaction;
                            num8 = command.ExecuteNonQuery();
                        }
                    }
                    else
                    {
                        str7 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj((((((("insert into Recepcion select NroBulto,NroOC,NroLinea,Codigo,Desc1,Desc2,0,CantRec,'" + Strings.Format(DateAndTime.get_Now(), "MM/dd/yyyy") + "',0,0,0,'") + Variables.gDespacho + "','") + Strings.Format(Variables.gFechaImp, "MM/dd/yyyy") + "','") + Variables.gCodAduana + "','") + Variables.gPaisOrigen + "','") + Variables.gPackList + "' from Bultos where PackList='") + Variables.gPackList + "' and NroOC='", row["NroOC"]), "' and Codigo='"), row["Codigo"]), "'"));
                        reader.Close();
                        command             = new SqlCommand(str7, connection2);
                        command.Transaction = transaction;
                        num8 = command.ExecuteNonQuery();
                    }
                }
                transaction.Commit();
                flag = false;
                str7 = "select * from Recepcion";
                dataSet.Clear();
                command = new SqlCommand(str7, connection2);
                new SqlDataAdapter(command).Fill(dataSet, "Recepcion");
                int num9 = dataSet.Tables["Recepcion"].Rows.Count - 1;
                for (num = 0; num <= num9; num++)
                {
                    row     = dataSet.Tables["Recepcion"].Rows[num];
                    command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT * from detdes where colnb=", row["NroBulto"]), " and itnbr='"), row["Codigo"]), "' and ordnb<>"), row["NroOC"])), connection3);
                    reader  = command.ExecuteReader();
                    if (reader.Read())
                    {
                        string str2 = StringType.FromObject(reader["ordnb"]);
                        string str  = StringType.FromObject(reader["lignb"]);
                        reader.Close();
                        command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT * from Recepcion where NroBulto='", row["NroBulto"]), "' and Codigo='"), row["Codigo"]), "' and NroOC='"), Strings.Format(Conversion.Val(str2), "0000000000")), "'")), connection2);
                        reader  = command.ExecuteReader();
                        if (!reader.Read())
                        {
                            reader.Close();
                            command = new SqlCommand("SELECT PC03001,PC03002,PC03005,PC03006,PC03007,PC03010,PC03011,PC03016 FROM dbo.PC030100 where PC03001='" + str2 + "' and PC03002='" + str + "' and PC03010<>0 and PC03010-PC03011<>0", connection);
                            reader  = command.ExecuteReader();
                            if (reader.Read())
                            {
                                str7 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(("insert into Recepcion select NroBulto,'" + Strings.Format(Conversion.Val(str2), "0000000000") + "','") + Strings.Format(Conversion.Val(str), "000000") + "',Codigo,Desc1,Desc2,", ObjectType.SubObj(reader["PC03010"], reader["PC03011"])), ",0,'"), Strings.Format(DateAndTime.get_Now(), "MM/dd/yyyy")), "',0,0,0,Despacho,FechaImp,CodAduana,PaisOrigen,PackList from Recepcion where NroOC='"), row["NroOC"]), "' and Codigo='"), row["Codigo"]), "' and NroBulto='"), row["NroBulto"]), "'"));
                                reader.Close();
                                command = new SqlCommand(str7, connection2);
                                num8    = command.ExecuteNonQuery();
                            }
                            else
                            {
                                str7 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj((("insert into Recepcion select NroBulto,'" + Strings.Format(Conversion.Val(str2), "0000000000") + "','" + Strings.Format(Conversion.Val(str), "000000")) + "',Codigo,Desc1,Desc2,0,0,'") + Strings.Format(DateAndTime.get_Now(), "MM/dd/yyyy") + "',0,0,0,Despacho,FechaImp,CodAduana,PaisOrigen,PackList from Recepcion where NroOC='", row["NroOC"]), "' and Codigo='"), row["Codigo"]), "' and NroBulto='"), row["NroBulto"]), "'"));
                                reader.Close();
                                num8 = new SqlCommand(str7, connection2).ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            reader.Close();
                        }
                    }
                    else
                    {
                        reader.Close();
                    }
                }
                connection2.Close();
                flag3 = false;
                connection.Close();
                flag2 = false;
                connection3.Close();
                flag4 = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, 0, null);
                if (flag)
                {
                    transaction.Rollback();
                    flag = false;
                }
                if (flag3)
                {
                    connection2.Close();
                    flag3 = false;
                }
                if (flag2)
                {
                    connection.Close();
                    flag2 = false;
                }
                if (flag4)
                {
                    connection3.Close();
                    flag4 = false;
                }
                this.dgBultos.Enabled   = true;
                this.cmbAceptar.Enabled = true;
                this.cmbSalir.Enabled   = true;
                ProjectData.ClearProjectError();
                return;

                ProjectData.ClearProjectError();
            }
            this.Close();
        }
예제 #6
0
 private void cmbAceptar_Click(object sender, EventArgs e)
 {
     if (StringType.StrCmp(Variables.gColor, "R", false) == 0)
     {
         Interaction.MsgBox("No puede imprimir etiqueta de esta orden", MsgBoxStyle.Critical, "Operador");
         this.cmbSalir.Focus();
     }
     else if (StringType.StrCmp(this.editCantEti.Text, Strings.Space(0), false) == 0)
     {
         Interaction.MsgBox("Debe ingresar cantidad de etiquetas a imprimir", MsgBoxStyle.Critical, "Operador");
         this.editCantEti.Focus();
     }
     else if (!Information.IsNumeric(this.editCantEti.Text))
     {
         Interaction.MsgBox("Cantidad de etiquetas a imprimir debe ser num\x00e9rica", MsgBoxStyle.Critical, "Operador");
         this.editCantEti.Focus();
     }
     else
     {
         int num2;
         if (File.Exists(@"C:\PrepPed.txt"))
         {
             FileSystem.Kill(@"C:\PrepPed.txt");
         }
         if (Variables.gTipoOV != 6)
         {
             num2 = FileSystem.FreeFile();
             FileSystem.FileOpen(num2, @"C:\PrepPed.txt", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1);
             FileSystem.PrintLine(num2, new object[] { "\x0002c0000" });
             FileSystem.PrintLine(num2, new object[] { "\x0002e" });
             FileSystem.PrintLine(num2, new object[] { "\x0002M1407" });
             FileSystem.PrintLine(num2, new object[] { "\x0002a" });
             FileSystem.PrintLine(num2, new object[] { "\x0002RN" });
             FileSystem.PrintLine(num2, new object[] { "\x0002s" });
             FileSystem.PrintLine(num2, new object[] { "\x0002V0" });
             FileSystem.PrintLine(num2, new object[] { "\x0002O0110" });
             FileSystem.PrintLine(num2, new object[] { "\x0002Kf0038" });
             FileSystem.PrintLine(num2, new object[] { "\x0002L" });
             FileSystem.PrintLine(num2, new object[] { "D11" });
             FileSystem.PrintLine(num2, new object[] { "A0" });
             FileSystem.PrintLine(num2, new object[] { "Q" + Strings.Format(Conversion.Val(this.editCantEti.Text), "0000") });
             FileSystem.PrintLine(num2, new object[] { "491100500140064Metodo de entrega: " });
             FileSystem.PrintLine(num2, new object[] { "491100501900066" + Variables.gDescMetEnt });
             FileSystem.PrintLine(num2, new object[] { "491100500140094Cliente: " });
             FileSystem.PrintLine(num2, new object[] { "491100500860096" + Variables.gCliente });
             FileSystem.PrintLine(num2, new object[] { "491100500140126" + Variables.gObserva1 });
             FileSystem.PrintLine(num2, new object[] { "491100500140156" + Variables.gObserva2 });
             FileSystem.PrintLine(num2, new object[] { "491100500140186Fecha Entrega: " + Strings.Format(Variables.gFechaEnt, "dd/MM/yyyy") });
             FileSystem.PrintLine(num2, new object[] { "491100700160225Orden de Venta Nro. " + Variables.gNroOV });
             FileSystem.PrintLine(num2, new object[] { "4e7709000290329A" + Variables.gNroOV });
             FileSystem.PrintLine(num2, new object[] { "E" });
             FileSystem.FileClose(new int[] { num2 });
             Interaction.Shell(@"C:\PrepPed.bat", AppWinStyle.MinimizedFocus, false, -1);
         }
         else
         {
             double        num;
             string        str;
             string        str2;
             string        str3;
             SqlConnection connection = new SqlConnection("data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=scalaDB;persist security info=True;packet size=4096");
             connection.Open();
             SqlCommand    command = new SqlCommand("SELECT OR030100.OR03005,OR030100.OR03006,OR030100.OR03007,OR030100.OR03011 FROM dbo.OR030100 where OR03001='" + Variables.gNroOV + "' and OR03034=1", connection);
             SqlDataReader reader  = command.ExecuteReader();
             if (reader.Read())
             {
                 str  = StringType.FromObject(reader["OR03005"]);
                 str2 = Strings.Trim(StringType.FromObject(reader["OR03006"])) + " " + Strings.Trim(StringType.FromObject(reader["OR03007"]));
                 num  = DoubleType.FromObject(ObjectType.MulObj(reader["OR03011"], -1));
                 reader.Close();
             }
             else
             {
                 str  = "";
                 str2 = "";
                 num  = 0.0;
                 reader.Close();
             }
             reader = new SqlCommand("SELECT OR040100.OR04003 FROM dbo.OR040100 where OR04001='" + Variables.gNroOV + "'", connection).ExecuteReader();
             if (reader.Read())
             {
                 if (StringType.StrCmp(Strings.Trim(StringType.FromObject(reader["OR04003"])), "0", false) == 0)
                 {
                     str3 = "";
                 }
                 else
                 {
                     str3 = StringType.FromObject(reader["OR04003"]);
                 }
                 reader.Close();
             }
             else
             {
                 str3 = "";
                 reader.Close();
             }
             num2 = FileSystem.FreeFile();
             FileSystem.FileOpen(num2, @"C:\PrepPed.txt", OpenMode.Output, OpenAccess.Default, OpenShare.Default, -1);
             FileSystem.PrintLine(num2, new object[] { "\x0002c0000" });
             FileSystem.PrintLine(num2, new object[] { "\x0002e" });
             FileSystem.PrintLine(num2, new object[] { "\x0002M1407" });
             FileSystem.PrintLine(num2, new object[] { "\x0002a" });
             FileSystem.PrintLine(num2, new object[] { "\x0002RN" });
             FileSystem.PrintLine(num2, new object[] { "\x0002s" });
             FileSystem.PrintLine(num2, new object[] { "\x0002V0" });
             FileSystem.PrintLine(num2, new object[] { "\x0002O0110" });
             FileSystem.PrintLine(num2, new object[] { "\x0002Kf0038" });
             FileSystem.PrintLine(num2, new object[] { "\x0002L" });
             FileSystem.PrintLine(num2, new object[] { "D11" });
             FileSystem.PrintLine(num2, new object[] { "A0" });
             FileSystem.PrintLine(num2, new object[] { "Q" + Strings.Format(Conversion.Val(this.editCantEti.Text), "0000") });
             FileSystem.PrintLine(num2, new object[] { "491100500140034" + Variables.gCliente });
             FileSystem.PrintLine(num2, new object[] { "491100500140054O.Venta Nro : " + str3 });
             FileSystem.PrintLine(num2, new object[] { "491100500140074Cantidad      : " + Strings.Format(num, "#####0") });
             FileSystem.PrintLine(num2, new object[] { "491100500140104Producto      : " + str });
             FileSystem.PrintLine(num2, new object[] { "491100500140124" + str2 });
             FileSystem.PrintLine(num2, new object[] { "4e5509000140214C" + str });
             FileSystem.PrintLine(num2, new object[] { "491100500140236O.Ensamblado Nro.  : " + Variables.gNroOV });
             FileSystem.PrintLine(num2, new object[] { "4e5509000140329A" + Variables.gNroOV });
             FileSystem.PrintLine(num2, new object[] { "E" });
             FileSystem.FileClose(new int[] { num2 });
             Interaction.Shell(@"C:\PrepPed.bat", AppWinStyle.MinimizedFocus, false, -1);
         }
         this.Actualiza();
         this.Close();
     }
 }
예제 #7
0
        // Inner version of "Print" and "Write".
        private static void Print(File file, Object[] Output,
                                  CultureInfo culture, bool print)
        {
            NumberFormatInfo nfi = culture.NumberFormat;

            if (Output == null)
            {
                return;
            }
            bool first = true;

            foreach (Object obj in Output)
            {
                if (!first && !print)
                {
                    file.Write(",");
                }
                else
                {
                    first = false;
                }
                if (obj == null)
                {
                    if (!print)
                    {
                        file.Write("#NULL#");
                    }
                    continue;
                }
                if (obj is TabInfo)
                {
                    file.Tab((TabInfo)obj);
                    continue;
                }
                else if (obj is SpcInfo)
                {
                    file.Space((SpcInfo)obj);
                    continue;
                }
                else if (obj is char[])
                {
                    file.Write(new String((char[])obj));
                    continue;
                }
                else if (obj is ErrObject)
                {
                    if (print)
                    {
                        file.Write(String.Format("Error {0}",
                                                 ((ErrObject)obj).Number));
                    }
                    else
                    {
                        file.Write(String.Format("#ERROR {0}#",
                                                 ((ErrObject)obj).Number));
                    }
                    continue;
                }
                switch (ObjectType.GetTypeCode(obj))
                {
                case TypeCode.DBNull:
                {
                    if (print)
                    {
                        file.Write("Null");
                    }
                    else
                    {
                        file.Write("#NULL#");
                    }
                }
                break;

                case TypeCode.Boolean:
                {
                    bool b = BooleanType.FromObject(obj);
                    if (print)
                    {
                        file.Write(b.ToString(culture));
                    }
                    else if (b)
                    {
                        file.Write("#TRUE#");
                    }
                    else
                    {
                        file.Write("#FALSE#");
                    }
                }
                break;

                case TypeCode.Byte:
                {
                    byte by = ByteType.FromObject(obj);
                    file.Write(by.ToString(nfi));
                }
                break;

                case TypeCode.Int16:
                {
                    short s = ShortType.FromObject(obj);
                    file.Write(s.ToString(nfi));
                }
                break;

                case TypeCode.Int32:
                {
                    int i = IntegerType.FromObject(obj);
                    file.Write(i.ToString(nfi));
                }
                break;

                case TypeCode.Int64:
                {
                    long l = LongType.FromObject(obj);
                    file.Write(l.ToString(nfi));
                }
                break;

                case TypeCode.Single:
                {
                    float f = SingleType.FromObject(obj, nfi);
                    file.Write(f.ToString(nfi));
                }
                break;

                case TypeCode.Double:
                {
                    double d = DoubleType.FromObject(obj, nfi);
                    file.Write(d.ToString(nfi));
                }
                break;

                case TypeCode.Decimal:
                {
                    Decimal dc = DecimalType.FromObject(obj, nfi);
                    file.Write(dc.ToString(nfi));
                }
                break;

                case TypeCode.DateTime:
                {
                    DateTime dt = DateType.FromObject(obj);
                    if (print)
                    {
                        file.Write(StringType.FromDate(dt) + " ");
                    }
                    else
                    {
                        String format;
                        long   dayTicks = dt.Ticks % TimeSpan.TicksPerDay;
                        if (dt.Ticks == dayTicks)
                        {
                            format = "T";
                        }
                        else if (dayTicks == 0)
                        {
                            format = "d";
                        }
                        else
                        {
                            format = "F";
                        }
                        file.Write(dt.ToString
                                       (format, culture.DateTimeFormat));
                    }
                }
                break;

                case TypeCode.String:
                {
                    file.Write(StringType.FromObject(obj));
                }
                break;

                default:
                {
                    Utils.ThrowException(5);                                            // ArgumentException.
                }
                break;
                }
            }
        }
예제 #8
0
        private void ActTmp()
        {
            DataSet dataSet = new DataSet();
            DataSet set2    = new DataSet();

            this.cmbAceptar.Enabled = false;
            this.cmbSalir.Enabled   = false;
            SqlConnection connection = new SqlConnection("data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=scalaDB;persist security info=False;packet size=4096");

            connection.Open();
            SqlConnection connection2 = new SqlConnection("data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=False;packet size=4096");

            connection2.Open();
            int num16 = new SqlCommand("delete " + Variables.gTermi + "TmpOCompra", connection2).ExecuteNonQuery();

            num16 = new SqlCommand("delete " + Variables.gTermi + "TmpOCGen", connection2).ExecuteNonQuery();
            SqlCommand command4 = new SqlCommand("delete " + Variables.gTermi + "TmpCodReemp", connection2);

            num16 = command4.ExecuteNonQuery();
            string        str     = "";
            string        str10   = "";
            string        str2    = "";
            string        str11   = "";
            string        str3    = "";
            string        str12   = "";
            string        cmdText = "SELECT PL23003,PL23004 FROM dbo.PL230100 where PL23001='2' and PL23002='00' and (PL23003='01' or PL23003='02' or PL23003='03') order by PL23003";
            SqlDataReader reader  = new SqlCommand(cmdText, connection).ExecuteReader();

            if (reader.Read())
            {
                str   = StringType.FromObject(reader["PL23003"]);
                str10 = StringType.FromObject(reader["PL23004"]);
            }
            if (reader.Read())
            {
                str2  = StringType.FromObject(reader["PL23003"]);
                str11 = StringType.FromObject(reader["PL23004"]);
            }
            if (reader.Read())
            {
                str3  = StringType.FromObject(reader["PL23003"]);
                str12 = StringType.FromObject(reader["PL23004"]);
            }
            reader.Close();
            cmdText = "SELECT SC01001,SC01089 FROM dbo.SC010100 where SC01089<>''";
            SqlCommand command = new SqlCommand(cmdText, connection);

            command.CommandTimeout = 300;
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                command4 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("insert into " + Variables.gTermi + "TmpCodReemp (Codigo,CodReemplazo) values ('", reader["SC01001"]), "','"), reader["SC01089"]), "')")), connection2);
                try
                {
                    num16 = command4.ExecuteNonQuery();
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, MsgBoxStyle.OKOnly, null);
                    connection.Close();
                    connection2.Close();
                    this.cmbAceptar.Enabled = true;
                    this.cmbSalir.Enabled   = true;
                    ProjectData.ClearProjectError();
                    return;

                    ProjectData.ClearProjectError();
                }
            }
            reader.Close();
            SqlCommand command2 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC01001,SC01002,SC01003,SC03010,SC03003,SC03004,SC03005,SC03006,SC03011,SC03018,SC01089,SC01125,SC03022,PL01002,SC01055,SC01056,SY14002 FROM SC010100 INNER JOIN SC030100 ON SC010100.SC01001 = SC030100.SC03001 INNER JOIN PL010100 ON SC030100.SC03022 = PL010100.PL01001 INNER JOIN SY140100 ON SC010100.SC01056 = SY140100.SY14001 WHERE SC030100.SC03002 = '", this.cbAlmacen.SelectedValue), "'")), connection);

            command2.CommandTimeout = 900;
            dataSet.Clear();
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = command2;
            adapter.Fill(dataSet, "SC010100");
            this.Label1.Visible = true;
            this.Label1.Refresh();
            this.txtCodProd.Visible = true;
            long num17 = dataSet.Tables["SC010100"].Rows.Count - 1;

            for (long i = 0L; i <= num17; i += 1L)
            {
                double  num13;
                double  num14;
                double  num15;
                DataRow row = dataSet.Tables["SC010100"].Rows[(int)i];
                this.txtCodProd.Text = StringType.FromObject(row["SC01001"]);
                this.txtCodProd.Refresh();
                string str5  = StringType.FromObject(row["SC01001"]);
                string str13 = Strings.Trim(StringType.FromObject(row["SC01002"])) + " " + Strings.Trim(StringType.FromObject(row["SC01003"]));
                double num5  = DoubleType.FromObject(row["SC03010"]);
                if (ObjectType.ObjTst(row["SC03003"], 0, false) < 0)
                {
                    num15 = 0.0;
                }
                else
                {
                    num15 = DoubleType.FromObject(row["SC03003"]);
                }
                double   num9       = DoubleType.FromObject(ObjectType.AddObj(row["SC03004"], row["SC03005"]));
                double   num8       = DoubleType.FromObject(row["SC03006"]);
                double   num3       = DoubleType.FromObject(row["SC03011"]);
                double   num2       = DoubleType.FromObject(row["SC03018"]);
                string   sLeft      = StringType.FromObject(row["SC01089"]);
                DateTime expression = DateType.FromObject(row["SC01125"]);
                string   str7       = StringType.FromObject(row["SC03022"]);
                string   str15      = StringType.FromObject(row["PL01002"]);
                double   num11      = DoubleType.FromObject(row["SC01055"]);
                string   str4       = StringType.FromObject(row["SC01056"]);
                string   str14      = StringType.FromObject(row["SY14002"]);
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "01", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='01'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "03", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='03'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "05", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='05'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "07", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='07'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "08", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='08'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "09", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='09'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "10", false) != 0)
                {
                    command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str5 + "' and SC03002='10'", connection);
                    command.CommandTimeout = 300;
                    reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                    }
                    reader.Close();
                }
                double num10 = 0.0;
                command = new SqlCommand("SELECT sum(OR03011-OR03012) as OVRes FROM dbo.OR030100,OR010100 where (OR01002=1 or OR01002=4 or OR01002=6) and OR01091=1 and OR03011-OR03012<>0 and OR03005='" + str5 + "' and OR01001=OR03001", connection);
                command.CommandTimeout = 300;
                reader = command.ExecuteReader();
                if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["OVRes"])))
                {
                    num10 = DoubleType.FromObject(reader["OVRes"]);
                }
                reader.Close();
                double num12 = 0.0;
                command = new SqlCommand("SELECT sum(OR03011) as PromVtas FROM dbo.OR030100,OR010100 where (OR01002=1 or OR01002=4 or OR01002=6) and OR01091=0 and OR03005='" + str5 + "' and OR01001=OR03001 and OR01015>='" + Strings.Format(DateAndTime.DateAdd(DateInterval.Month, -3.0, DateAndTime.Now), "MM/dd/yyyy") + "' and OR01015<='" + Strings.Format(DateAndTime.Now, "MM/dd/yyyy") + "'", connection);
                command.CommandTimeout = 300;
                reader = command.ExecuteReader();
                if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["PromVtas"])))
                {
                    num12 = DoubleType.FromObject(reader["PromVtas"]);
                }
                reader.Close();
                command = new SqlCommand("SELECT sum(OR21011) as PromVtas FROM dbo.OR210100,OR200100 where (OR20002=1 or OR20002=4 or OR20002=6) and OR20091=0 and OR21005='" + str5 + "' and OR20001=OR21001 and OR20015>='" + Strings.Format(DateAndTime.DateAdd(DateInterval.Month, -3.0, DateAndTime.Now), "MM/dd/yyyy") + "' and OR20015<='" + Strings.Format(DateAndTime.Now, "MM/dd/yyyy") + "'", connection);
                command.CommandTimeout = 300;
                reader = command.ExecuteReader();
                if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["PromVtas"])))
                {
                    num12 = DoubleType.FromObject(ObjectType.AddObj(num12, reader["PromVtas"]));
                }
                reader.Close();
                num12 /= 3.0;
                double num7 = num12 * Variables.gMesesNRNue;
                if (num7 == 0.0)
                {
                    num7 = num5;
                }
                if (StringType.StrCmp(sLeft, " ", false) != 0)
                {
                    num13 = 0.0;
                    num14 = 0.0;
                    if (!(((((StringType.StrCmp(Strings.Format(expression, "yyyyMMdd"), Strings.Format(DateAndTime.Now, "yyyyMMdd"), false) < 0) & (num15 == 0.0)) & (num9 == 0.0)) & (num8 == 0.0)) & (num10 == 0.0)))
                    {
                        command4 = new SqlCommand((((((((((((((((("insert into " + Variables.gTermi + "TmpOCompra (Codigo,Descripcion,NivelRepos,StockAl,OV,OCPend,OVRes,LoteOptCpra,CantMinPed,CodReemplazo,FecReemp,PropCpra,PromVtas,NivelReposPV,PropCpraPV,CodProv,NomProv,CodMetEnv01,DescMetEnv01,CantMetEnv01,FecEntOC01,CodMetEnv02,DescMetEnv02,CantMetEnv02,FecEntOC02,CodMetEnv03,DescMetEnv03,CantMetEnv03,FecEntOC03,Seleccion,PrecioCpra,CodMoneda,Moneda) values ('" + str5) + "','" + str13 + "'," + StringType.FromDouble(num5) + "," + StringType.FromDouble(num15) + "," + StringType.FromDouble(num9) + "," + StringType.FromDouble(num8) + "," + StringType.FromDouble(num10) + "," + StringType.FromDouble(num3) + "," + StringType.FromDouble(num2)) + ",'" + sLeft) + "','" + Strings.Format(expression, "MM/dd/yyyy") + "'," + StringType.FromDouble(num13) + "," + StringType.FromDouble(num12) + "," + StringType.FromDouble(num7) + "," + StringType.FromDouble(num14)) + ",'" + str7) + "','" + str15) + "','" + str) + "','" + str10 + "'," + StringType.FromDouble(num13)) + ",'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy")) + "','" + str2) + "','" + str11) + "',0,'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy")) + "','" + str3) + "','" + str12) + "',0,'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy") + "',0," + StringType.FromDouble(num11)) + ",'" + str4) + "','" + str14 + "')", connection2);
                        try
                        {
                            num16 = command4.ExecuteNonQuery();
                        }
                        catch (Exception exception4)
                        {
                            ProjectData.SetProjectError(exception4);
                            Exception exception2 = exception4;
                            Interaction.MsgBox("Se ha producido el siguiente error:" + exception2.Message, MsgBoxStyle.OKOnly, null);
                            connection.Close();
                            connection2.Close();
                            this.cmbAceptar.Enabled = true;
                            this.cmbSalir.Enabled   = true;
                            ProjectData.ClearProjectError();
                            return;

                            ProjectData.ClearProjectError();
                        }
                    }
                    continue;
                }
                if (StringType.StrCmp(sLeft, " ", false) == 0)
                {
                    string str6 = str5;
                    while (1 != 0)
                    {
                        command = new SqlCommand("SELECT * FROM " + Variables.gTermi + "TmpCodReemp where CodReemplazo='" + str6 + "'", connection2);
                        command.CommandTimeout = 300;
                        reader = command.ExecuteReader();
                        if (reader.HasRows)
                        {
                            reader.Read();
                            str6 = StringType.FromObject(reader["Codigo"]);
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                            break;
                        }
                        command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT SC03010,SC03003,SC03004,SC03005,SC03006,SC03011,SC03018 FROM SC030100 where SC03001='" + str6 + "' and SC03002='", this.cbAlmacen.SelectedValue), "'")), connection);
                        command.CommandTimeout = 300;
                        reader = command.ExecuteReader();
                        if (reader.HasRows)
                        {
                            reader.Read();
                            num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["SC03003"]));
                            num9  = DoubleType.FromObject(ObjectType.AddObj(ObjectType.AddObj(num9, reader["SC03004"]), reader["SC03005"]));
                            num8  = DoubleType.FromObject(ObjectType.AddObj(num8, reader["SC03006"]));
                        }
                        reader.Close();
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "01", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='01'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "03", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='03'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "05", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='05'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "07", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='07'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "08", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='08'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "09", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='09'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        if (ObjectType.ObjTst(this.cbAlmacen.SelectedValue, "10", false) != 0)
                        {
                            command = new SqlCommand("SELECT SC03003 as Stock FROM dbo.SC030100 where SC03001='" + str6 + "' and SC03002='10'", connection);
                            command.CommandTimeout = 300;
                            reader = command.ExecuteReader();
                            if (reader.Read())
                            {
                                num15 = DoubleType.FromObject(ObjectType.AddObj(num15, reader["Stock"]));
                            }
                            reader.Close();
                        }
                        command = new SqlCommand("SELECT sum(OR03011-OR03012) as OVRes FROM dbo.OR030100,OR010100 where (OR01002=1 or OR01002=4 or OR01002=6) and OR01091=1 and OR03011-OR03012<>0 and OR03005='" + str6 + "' and OR01001=OR03001", connection);
                        command.CommandTimeout = 300;
                        reader = command.ExecuteReader();
                        if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["OVRes"])))
                        {
                            num10 = DoubleType.FromObject(ObjectType.AddObj(num10, reader["OVRes"]));
                        }
                        reader.Close();
                        num12   = 0.0;
                        command = new SqlCommand("SELECT sum(OR03011) as PromVtas FROM dbo.OR030100,OR010100 where (OR01002=1 or OR01002=4 or OR01002=6) and OR01091=0 and OR03005='" + str6 + "' and OR01001=OR03001 and OR01015>='" + Strings.Format(DateAndTime.DateAdd(DateInterval.Month, -3.0, DateAndTime.Now), "MM/dd/yyyy") + "' and OR01015<='" + Strings.Format(DateAndTime.Now, "MM/dd/yyyy") + "'", connection);
                        command.CommandTimeout = 300;
                        reader = command.ExecuteReader();
                        if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["PromVtas"])))
                        {
                            num12 = DoubleType.FromObject(reader["PromVtas"]);
                        }
                        reader.Close();
                        command = new SqlCommand("SELECT sum(OR21011) as PromVtas FROM dbo.OR210100,OR200100 where (OR20002=1 or OR20002=4 or OR20002=6) and OR20091=0 and OR21005='" + str6 + "' and OR20001=OR21001 and OR20015>='" + Strings.Format(DateAndTime.DateAdd(DateInterval.Month, -3.0, DateAndTime.Now), "MM/dd/yyyy") + "' and OR20015<='" + Strings.Format(DateAndTime.Now, "MM/dd/yyyy") + "'", connection);
                        command.CommandTimeout = 300;
                        reader = command.ExecuteReader();
                        if (reader.Read() && !Information.IsDBNull(RuntimeHelpers.GetObjectValue(reader["PromVtas"])))
                        {
                            num12 = DoubleType.FromObject(ObjectType.AddObj(num12, reader["PromVtas"]));
                        }
                        reader.Close();
                        num12 /= 3.0;
                        num7   = num12 * Variables.gMesesNRNue;
                        if (num7 == 0.0)
                        {
                            num7 = num5;
                        }
                    }
                    num13 = (((num5 - num15) + num9) - num8) - num10;
                    num14 = (((num7 - num15) + num9) - num8) - num10;
                    if (num13 > 0.0)
                    {
                        if ((num3 != 0.0) && (num3 > num13))
                        {
                            num13 = num3;
                        }
                        if (num2 != 0.0)
                        {
                            num13 = Math.Round((double)((num13 / num2) + 0.49), 0) * num2;
                        }
                        command4 = new SqlCommand(((((((((((((((("insert into " + Variables.gTermi + "TmpOCompra (Codigo,Descripcion,NivelRepos,StockAl,OV,OCPend,OVRes,LoteOptCpra,CantMinPed,CodReemplazo,PropCpra,PromVtas,NivelReposPV,PropCpraPV,CodProv,NomProv,CodMetEnv01,DescMetEnv01,CantMetEnv01,FecEntOC01,CodMetEnv02,DescMetEnv02,CantMetEnv02,FecEntOC02,CodMetEnv03,DescMetEnv03,CantMetEnv03,FecEntOC03,Seleccion,PrecioCpra,CodMoneda,Moneda) values ('" + str5) + "','" + str13 + "'," + StringType.FromDouble(num5) + "," + StringType.FromDouble(num15) + "," + StringType.FromDouble(num9) + "," + StringType.FromDouble(num8) + "," + StringType.FromDouble(num10) + "," + StringType.FromDouble(num3) + "," + StringType.FromDouble(num2)) + ",'" + sLeft + "'," + StringType.FromDouble(num13) + "," + StringType.FromDouble(num12) + "," + StringType.FromDouble(num7) + "," + StringType.FromDouble(num14)) + ",'" + str7) + "','" + str15) + "','" + str) + "','" + str10 + "'," + StringType.FromDouble(num13)) + ",'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy")) + "','" + str2) + "','" + str11) + "',0,'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy")) + "','" + str3) + "','" + str12) + "',0,'" + Strings.Format(DateType.FromString(Variables.gFechaOC), "MM/dd/yyyy") + "',0," + StringType.FromDouble(num11)) + ",'" + str4) + "','" + str14 + "')", connection2);
                        try
                        {
                            num16 = command4.ExecuteNonQuery();
                        }
                        catch (Exception exception5)
                        {
                            ProjectData.SetProjectError(exception5);
                            Exception exception3 = exception5;
                            Interaction.MsgBox("Se ha producido el siguiente error:" + exception3.Message, MsgBoxStyle.OKOnly, null);
                            connection.Close();
                            connection2.Close();
                            this.cmbAceptar.Enabled = true;
                            this.cmbSalir.Enabled   = true;
                            ProjectData.ClearProjectError();
                            return;

                            ProjectData.ClearProjectError();
                        }
                    }
                }
            }
            connection.Close();
            connection2.Close();
        }