示例#1
0
        /// <summary>
        /// ToolSettings.cs \\ Save map-unrelated user settings
        /// </summary>
        public void saveUserSettings()
        {
            if (!Variables.allowSaveLastMap)
            {
                return;
            }

            StreamWriter streamWriter = new StreamWriter((Stream) new FileStream(Variables.strWorkingDir + "CoD4CompileTools.settings", FileMode.Create));

            streamWriter.WriteLine("tree," + Variables.strTreePath);
            streamWriter.WriteLine("mapname," + Variables.selectedMap_Name);
            streamWriter.WriteLine("developer," + StringType.FromBoolean((bool)chkDeveloper.IsChecked));
            streamWriter.WriteLine("developerscript," + StringType.FromBoolean((bool)chkDeveloperScript.IsChecked));
            streamWriter.WriteLine("cheats," + StringType.FromBoolean((bool)chkCheats.IsChecked));
            streamWriter.WriteLine("tab," + StringType.FromInteger(compileTab.SelectedIndex));
            streamWriter.WriteLine("chkCustomCommandLine," + StringType.FromBoolean((bool)chkCustomCommandLine.IsChecked));
            streamWriter.WriteLine("txtCustomCommandLine," + txtCustomCommandLine.Text);
            streamWriter.WriteLine("moveToUsermaps," + StringType.FromBoolean(Variables.copyToUsermaps));
            streamWriter.WriteLine("exeGameMp," + Variables.strGameMpName);
            streamWriter.WriteLine("exeRadiant," + Variables.strRadiantName);

            // GLSL->HLSL Syntax Converter
            streamWriter.WriteLine("sgen_width," + StringType.FromDouble(Variables.SyntaxConverterWidth));
            streamWriter.WriteLine("sgen_height," + StringType.FromDouble(Variables.SyntaxConverterHeight));
            streamWriter.WriteLine("sgen_font," + StringType.FromDouble(Variables.SyntaxConverterFontSize));
            streamWriter.WriteLine("sgen_optimise," + StringType.FromBoolean(Variables.SyntaxConverterOptimise));

            streamWriter.Close();
        }
示例#2
0
        private static string word2(string numb, string param)
        {
            string[] textArray1;
            string   text2 = "";

            if (Strings.Len(numb) == 1)
            {
                textArray1 = new string[] { text2, Word(numb), " ", param, " " };
                return(string.Concat(textArray1));
            }
            if (Strings.Len(numb) == 2)
            {
                if (Conversion.Val(numb) == 0)
                {
                    return(text2);
                }
                if ((DoubleType.FromString(numb) > 0) & (DoubleType.FromString(numb) < 20))
                {
                    textArray1 = new string[] { text2, Word(numb), " ", param, " " };
                    return(string.Concat(textArray1));
                }
                textArray1 = new string[] { text2, Word(StringType.FromDouble(DoubleType.FromString(Strings.Left(numb, 1)) * 10)), " ", Word(Strings.Mid(numb, 2, 1)), " ", param, " " };
                return(string.Concat(textArray1));
            }
            if (Strings.Len(numb) == 3)
            {
                string text1 = Strings.Mid(numb, 1, 1);
                if (Conversion.Int(Conversion.Val(text1)) != 0)
                {
                    text2 = text2 + Word(Strings.Mid(numb, 1, 1)) + " hundred ";
                }
                text1 = Strings.Mid(numb, 2, 2);
                if (Conversion.Val(text1) == 0)
                {
                    if (DoubleType.FromString(Strings.Mid(numb, 1, 1)) != 0)
                    {
                        text2 = text2 + " " + param + " ";
                    }
                }
                else if (((Conversion.Val(text1) > 0) & (Conversion.Val(text1) < 20)) | ((DoubleType.FromString(text1) % 10) == 0))
                {
                    textArray1 = new string[] { text2, Word(Strings.Mid(numb, 2, 2)), " ", param, " " };
                    text2      = string.Concat(textArray1);
                }
                else
                {
                    textArray1 = new string[] { text2, Word(StringType.FromDouble(DoubleType.FromString(Strings.Mid(numb, 2, 1)) * 10)), " ", Word(Strings.Mid(numb, 3, 1)), " ", param, " " };
                    text2      = string.Concat(textArray1);
                }
            }
            return(text2);
        }
示例#3
0
        private static string word3(string numb)
        {
            string text2 = string.Empty;

            if (Strings.Len(numb) == 1)
            {
                return(text2 + Word(numb));
            }
            if (Strings.Len(numb) == 2)
            {
                if (((DoubleType.FromString(numb) > 1) & (DoubleType.FromString(numb) < 20)) | ((DoubleType.FromString(numb) % 10) == 0))
                {
                    return(text2 + Word(numb));
                }
                return(text2 + Word(StringType.FromDouble(DoubleType.FromString(Strings.Left(numb, 1)) * 10)) + " " + Word(Strings.Right(numb, 1)));
            }
            if (Strings.Len(numb) == 3)
            {
                string text1 = Word(StringType.FromDouble(Conversion.Int(DoubleType.FromString(numb) / 100)));
                if (StringType.StrCmp(text1, "zero", false) != 0)
                {
                    text2 = text2 + text1 + " hundred ";
                }
                text1 = StringType.FromDouble(DoubleType.FromString(Strings.Mid(numb, 2)) % 10);
                if (StringType.StrCmp(text1, "0", false) == 0)
                {
                    text1 = Word(Strings.Mid(numb, 2));
                    if (StringType.StrCmp(text1, "zero", false) != 0)
                    {
                        text2 = text2 + text1;
                    }
                }
                else if ((DoubleType.FromString(Strings.Right(numb, 2)) > 0) & (DoubleType.FromString(Strings.Right(numb, 2)) < 20))
                {
                    text2 = text2 + Word(Strings.Right(numb, 2));
                }
                else
                {
                    text2 = text2 + Word(StringType.FromDouble(Conversion.Int(DoubleType.FromString(Strings.Mid(numb, 2, 1)) * 10))) + " " + ConvertNumberToWord.Word(Strings.Right(numb, 1));
                }
            }
            return(text2);
        }
示例#4
0
 public void FromDouble_Format(double value, NumberFormatInfo format, string expected)
 {
     Assert.Equal(expected, StringType.FromDouble(value, format));
 }
示例#5
0
 public void FromDouble(double value, string expected)
 {
     Assert.Equal(expected, StringType.FromDouble(value));
     Assert.Equal(expected, StringType.FromDouble(value, default(NumberFormatInfo)));
 }
示例#6
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();
        }