public static int DatePart (String Interval, Object DateValue, [Optional][DefaultValue(FirstDayOfWeek.Sunday)] FirstDayOfWeek FirstDayOfWeekValue, [Optional][DefaultValue(FirstWeekOfYear.Jan1)] FirstWeekOfYear FirstWeekOfYearValue) { return(DatePart(StringToInterval(Interval), DateType.FromObject(DateValue), FirstDayOfWeekValue, FirstWeekOfYearValue)); }
private void CargarDatosPrestacion() { ClienteFactor.cClientePrestacion clientePrestacion = new ClienteFactor.cClientePrestacion(0); clientePrestacion.Consulta(this._Cliente); while (clientePrestacion.drReader.Read()) { this.dtpFInicio.Value = DateType.FromObject(clientePrestacion.drReader[3]); this.cboStatus.SelectedIndex = 0; this.DesplegarDatos(IntegerType.FromObject(clientePrestacion.drReader[5]), StringType.FromObject(clientePrestacion.drReader[7]), DecimalType.FromObject(clientePrestacion.drReader[6])); } }
public static long DateDiff (String Interval, Object Date1, Object Date2, [Optional][DefaultValue(FirstDayOfWeek.Sunday)] FirstDayOfWeek DayOfWeek, [Optional][DefaultValue(FirstWeekOfYear.Jan1)] FirstWeekOfYear WeekOfYear) { return(DateDiff(StringToInterval(Interval), DateType.FromObject(Date1), DateType.FromObject(Date2), DayOfWeek, WeekOfYear)); }
public static DateTime TimeToDateTime(object time) { DateTime dt;// = new DateTime(); if (time is TimeSpan) { TimeSpan ts = (TimeSpan)time; //dt = new DateTime(); dt = TimeToDateTime(ts);//dt.Add(ts); } else { dt = DateType.FromObject(time); } return(dt); }
public DateTime FechaActual() { DateTime dateTime1 = new DateTime(); try { this.cnSigamet = new SqlConnection(Globals.GetInstance._CadenaConexion); SqlCommand sqlCommand = new SqlCommand("spPTLClienteIncentivo", this.cnSigamet); sqlCommand.Parameters.Add("@Configuracion", SqlDbType.SmallInt).Value = (object)3; sqlCommand.Parameters.Add("@Cliente", SqlDbType.Int).Value = (object)0; sqlCommand.Parameters.Add("@TipoIncentivo", SqlDbType.Int).Value = (object)0; sqlCommand.Parameters.Add("@FIncentivo", SqlDbType.DateTime).Value = (object)DateAndTime.Now; sqlCommand.Parameters.Add("@Incentivo", SqlDbType.Decimal).Value = (object)0; sqlCommand.Parameters.Add("@Usuario", SqlDbType.VarChar).Value = (object)""; sqlCommand.Parameters.Add("@Status", SqlDbType.VarChar).Value = (object)""; sqlCommand.CommandType = CommandType.StoredProcedure; this.cnSigamet.Open(); this.drReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection); DateTime dateTime2 = new DateTime(); while (this.drReader.Read()) { dateTime2 = DateType.FromObject(this.drReader[0]); } this.cnSigamet.Close(); dateTime1 = dateTime2; } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; EventLog.WriteEntry("Consulta cliente factor" + exception.Source, exception.Message, EventLogEntryType.Error); int num = (int)MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } return(dateTime1); }
// Add a time interval to a date value. public static DateTime DateAdd (String Interval, double Number, Object DateValue) { return(DateAdd(StringToInterval(Interval), Number, DateType.FromObject(DateValue))); }
public void FromObject_ThrowsOverflowException(object value) { Assert.Throws <OverflowException>(() => DateType.FromObject(value)); }
public void FromObject_ThrowsInvalidCastException(object value) { Assert.Throws <InvalidCastException>(() => DateType.FromObject(value)); }
public void FromObject_NotSupported(object value, DateTime expected) { Assert.Throws <InvalidCastException>(() => DateType.FromObject(value)); }
/// <summary> /// SetDateRange assumes that parameteres are date only and sets timePart of From to 0 and To to 23.59 /// </summary> /// <param name="DateFrom"></param> /// <param name="DateTo"></param> public void SetDateRange(object DateFrom, object DateTo) { DateTimeFrom = DateTimeHelper.DateStartOfDay(DateType.FromObject(DateFrom)); DateTimeTo = DateTimeHelper.DateEndOfDay(DateType.FromObject(DateTo)); }
private void cmbAceptar_Click(object sender, EventArgs e) { if (StringType.StrCmp(this.editNroOE.Text, Strings.Space(0), false) == 0) { Interaction.MsgBox("Debe indicar o.ensamblado", MsgBoxStyle.Critical, "Operador"); this.editNroOE.Focus(); } else { this.editNroOE.Enabled = false; this.cmbAceptar.Enabled = false; this.cmbSalir.Enabled = false; Variables.gNroOE = Strings.Format(Conversion.Val(this.editNroOE.Text), "0000000000"); 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 DISTINCT OR010100.OR01016,OR040100.OR04002,OR040100.OR04003 FROM dbo.OR010100 LEFT OUTER JOIN dbo.OR040100 on OR010100.OR01001=OR040100.OR04001 where OR010100.OR01001='" + Variables.gNroOE + "' and OR010100.OR01002=6", connection); SqlDataReader reader = command.ExecuteReader(); if (((int)-(reader.HasRows > false)) == 0) { reader.Close(); connection.Close(); Interaction.MsgBox("O.ensamblado inexistente", MsgBoxStyle.Critical, "Operador"); this.editNroOE.Enabled = true; this.cmbAceptar.Enabled = true; this.cmbSalir.Enabled = true; this.editNroOE.Text = ""; this.editNroOE.Focus(); } else { reader.Read(); CalcDates dates = new CalcDatesClass(); short daysToDue = 0; string dayCountType = "H"; string company = "01"; dates.WeekDate(ref daysToDue, ref DateType.FromObject(reader["OR01016"]), ref dayCountType, ref company); this.txtFechaEntPed.Text = Strings.Format(dates.MidDate, "dd/MM/yyyy"); if (StringType.StrCmp(Strings.Trim(StringType.FromObject(reader["OR04002"])), "0", false) == 0) { this.txtNomCli.Text = ""; } else { this.txtNomCli.Text = Strings.Trim(StringType.FromObject(reader["OR04002"])); } if (StringType.StrCmp(Strings.Trim(StringType.FromObject(reader["OR04003"])), "0", false) == 0) { this.txtNroOV.Text = ""; } else { this.txtNroOV.Text = Strings.Format(Conversion.Val(Strings.Mid(StringType.FromObject(reader["OR04003"]), 1, 10)), "0000000000"); } reader.Close(); reader = new SqlCommand("SELECT DISTINCT OR030100.OR03051 FROM dbo.OR030100 where OR030100.OR03001='" + Variables.gNroOE + "'", connection).ExecuteReader(); if (((int)-(reader.HasRows > false)) == 0) { reader.Close(); connection.Close(); Interaction.MsgBox("O.ensamblado inexistente", MsgBoxStyle.Critical, "Operador"); this.editNroOE.Enabled = true; this.cmbAceptar.Enabled = true; this.cmbSalir.Enabled = true; this.editNroOE.Text = ""; this.editNroOE.Focus(); } else { reader.Read(); if (StringType.StrCmp(Strings.Trim(StringType.FromObject(reader["OR03051"])), "", false) == 0) { reader.Close(); connection.Close(); Interaction.MsgBox("Esta O.ensamblado no tiene lista de recogida generada", MsgBoxStyle.Critical, "Operador"); this.editNroOE.Enabled = true; this.cmbAceptar.Enabled = true; this.cmbSalir.Enabled = true; this.editNroOE.Text = ""; this.editNroOE.Focus(); } else { this.txtNroListaRec.Text = Strings.Trim(StringType.FromObject(reader["OR03051"])); reader.Close(); connection.Close(); this.GroupBox1.Visible = true; this.btnContinuar.Focus(); } } } } }
public frmRepOCConfPend1() { base.Closed += new EventHandler(this.frmRepOCConfPend1_Closed); base.Load += new EventHandler(this.frmRepOCConfPend1_Load); this.Informe = new ReportDocument(); this.DS = new DataSet(); this.DS1 = new DataSet(); this.InitializeComponent(); bool flag = false; string selectConnectionString = "data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=scalaDB;persist security info=False;packet size=4096"; string str4 = "data source=" + Variables.gServer + ";user id=scala;password=scala;initial catalog=edibar;persist security info=False;packet size=4096"; this.DS.Clear(); this.DS1.Clear(); string selectCommandText = "SELECT PC01001,PC01003,PC01004,PC01014,PC01015,PC01016,PC03001,PC03005,PC03006,PC03007,PC03010,PC03011,PC03016,SL01001,SL01002,PL01001,PL01002,PL23003,PL23004,ordnb,lignb FROM dbo.PC010100 inner join PC030100 on PC01001=PC03001 inner join PL010100 on PC01003=PL01001 left outer join SL010100 on PC01004=SL01001 inner join PL230100 on PC01014=PL23003 LEFT OUTER JOIN edibar.dbo.detdes ON PC030100.PC03001 = edibar.dbo.detdes.ordnb AND PC030100.PC03002 = edibar.dbo.detdes.lignb where PC01001>'0000014500' and PC03011<PC03010 and PC03029='1' and PL23001='2' and PL23002='00'"; if (StringType.StrCmp(Variables.gCodProv, "", false) != 0) { selectCommandText = selectCommandText + " and PC01003='" + Variables.gCodProv + "'"; } if (StringType.StrCmp(Variables.gCodMetEnt, "", false) != 0) { selectCommandText = selectCommandText + " and PC01014=" + Variables.gCodMetEnt; } if (StringType.StrCmp(Variables.gCodAlmacen, "", false) != 0) { selectCommandText = selectCommandText + " and PC03035='" + Variables.gCodAlmacen + "'"; } if (Variables.gNoDespachado) { selectCommandText = selectCommandText + " and edibar.dbo.detdes.ordnb is null"; } this.AdapPC01 = new SqlDataAdapter(selectCommandText, selectConnectionString); this.AdapPC01.Fill(this.DS1, "PC010100"); string connectionString = "data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=False;packet size=4096"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); flag = true; SqlCommand command = new SqlCommand("delete " + Variables.gTermi + "TmpOCConfPend", connection); int num2 = command.ExecuteNonQuery(); int num3 = this.DS1.Tables["PC010100"].Rows.Count - 1; for (int i = 0; i <= num3; i++) { DataRow row = this.DS1.Tables["PC010100"].Rows[i]; if (DateAndTime.DateDiff(DateInterval.Day, DateType.FromObject(row["PC01016"]), DateType.FromObject(row["PC03016"]), FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1) >= Variables.gDiasDif) { selectCommandText = 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("insert into " + Variables.gTermi + "TmpOCConfPend (CodProv,NomProv,NroOC,FechaOC,FEntSolic,FEntConf,Codigo,Descripcion,Cantidad,FormaDesp,Destinatario,EnTransito) values ('", row["PC01003"]), "','"), row["PL01002"]), "','"), row["PC01001"]), "','"), Strings.Format(RuntimeHelpers.GetObjectValue(row["PC01015"]), "MM/dd/yyyy")), "','"), Strings.Format(RuntimeHelpers.GetObjectValue(row["PC01016"]), "MM/dd/yyyy")), "','"), Strings.Format(RuntimeHelpers.GetObjectValue(row["PC03016"]), "MM/dd/yyyy")), "','"), row["PC03005"]), "','"), Strings.Trim(StringType.FromObject(row["PC03006"]))), " "), Strings.Trim(StringType.FromObject(row["PC03007"]))), "',"), ObjectType.SubObj(row["PC03010"], row["PC03011"])), ",'"), row["PL23004"]), "',")); if (ObjectType.ObjTst(row["PC01004"], "+", false) == 0) { selectCommandText = selectCommandText + "'BGA',"; } else { selectCommandText = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(selectCommandText + "'", row["SL01002"]), "',")); } if (Information.IsDBNull(RuntimeHelpers.GetObjectValue(row["ordnb"]))) { selectCommandText = selectCommandText + "'N')"; } else { selectCommandText = selectCommandText + "'S')"; } command = new SqlCommand(selectCommandText, connection); try { command.ExecuteNonQuery(); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, MsgBoxStyle.OKOnly, null); if (flag) { connection.Close(); flag = false; } ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } } connection.Close(); flag = false; selectCommandText = "select * from " + Variables.gTermi + "TmpOCConfPend as PC1TmpOCConfPend"; this.AdapTmp = new SqlDataAdapter(selectCommandText, connectionString); this.AdapTmp.Fill(this.DS, "PC1TmpOCConfPend"); this.Informe.Load(Application.StartupPath + @"\repocconfpend.rpt"); this.Informe.SetDataSource(this.DS); FormulaFieldDefinitions formulaFields = this.Informe.DataDefinition.FormulaFields; FormulaFieldDefinition definition = formulaFields["almacen"]; if (StringType.StrCmp(Variables.gCodAlmacen, Strings.Space(0), false) != 0) { definition.Text = "'Almacen: " + Strings.Trim(Variables.gNomAlmacen) + "'"; } else { definition.Text = "'Todos los almacenes'"; } FormulaFieldDefinition definition2 = formulaFields["formadesp"]; if (StringType.StrCmp(Variables.gCodMetEnt, Strings.Space(0), false) != 0) { definition2.Text = "'Forma Despacho: " + Strings.Trim(Variables.gDescMetEnt) + "'"; } else { definition2.Text = "'Todos las formas de despacho'"; } FormulaFieldDefinition definition3 = formulaFields["diasdif"]; definition3.Text = "'" + Strings.Format(Variables.gDiasDif, "###0") + "'"; FormulaFieldDefinition definition4 = formulaFields["nodesp"]; if (Variables.gNoDespachado) { definition4.Text = "'Solamente los items con tr\x00e1nsito no registrado'"; } else { definition4.Text = "'Items despachados y no despachados'"; } this.CrystalReportViewer1.ShowGroupTreeButton = true; this.CrystalReportViewer1.ReportSource = this.Informe; }
// 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; } } }
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(); }
private void ActTmp() { DataSet dataSet = new DataSet(); 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 num3 = new SqlCommand("delete " + Variables.gTermi + "TmpOCompraExp", connection2).ExecuteNonQuery(); SqlCommand command3 = new SqlCommand("delete " + Variables.gTermi + "TmpOCGen", connection2); num3 = command3.ExecuteNonQuery(); SqlCommand command2 = new SqlCommand("Select OR01016,OR01004,SL01002,OR01014,PL23004,OR04002,OR04003,OR04004,OR04005,OR04008,OR01050 from OR010100 left outer join OR040100 on OR010100.OR01001=OR040100.OR04001 inner join SL010100 on OR010100.OR01004=SL010100.SL01001 inner join PL230100 on OR010100.OR01014=convert(int,PL230100.PL23003) where OR01001='" + this.editNroOV.Text + "' and PL23001='2' and PL23002='00'", connection); command2.CommandTimeout = 900; dataSet.Clear(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command2; adapter.Fill(dataSet, "OR010100"); if (dataSet.Tables["OR010100"].Rows.Count == 0) { Interaction.MsgBox("O.Venta inexistente", 0x10, "Operador"); this.gErrorAct = true; connection.Close(); connection2.Close(); this.editNroOV.Text = ""; this.editNroOV.Enabled = true; this.cbProveedor.Enabled = true; this.cbProveedor.Text = ""; this.cbProveedor.SelectedValue = ""; this.editNroOV.Focus(); } else { DataRow row = dataSet.Tables["OR010100"].Rows[0]; this.dtpFechaOC.Value = DateType.FromObject(row["OR01016"]); this.txtCliente.Text = StringType.FromObject(row["OR01004"]); this.txtNomCli.Text = StringType.FromObject(row["SL01002"]); this.txtMetEnv.Text = StringType.FromObject(row["OR01014"]); this.txtNomMetEnv.Text = StringType.FromObject(row["PL23004"]); this.txtDirEnt1.Text = StringType.FromObject(row["OR04002"]); this.txtDirEnt2.Text = StringType.FromObject(row["OR04003"]); this.txtDirEnt3.Text = StringType.FromObject(row["OR04004"]); this.txtDirEnt4.Text = StringType.FromObject(row["OR04005"]); this.txtDirEnt5.Text = StringType.FromObject(row["OR04008"]); this.txtFechaEntDes.Text = StringType.FromObject(row["OR01016"]); Variables.gAlmacen1 = StringType.FromObject(row["OR01050"]); command2 = new SqlCommand("SELECT OR03002,OR03005,OR03006,OR03007,OR03011 FROM OR030100 WHERE OR030100.OR03001='" + this.editNroOV.Text + "'", connection); command2.CommandTimeout = 900; dataSet.Clear(); SqlDataAdapter adapter2 = new SqlDataAdapter(); adapter2.SelectCommand = command2; adapter2.Fill(dataSet, "OR030100"); long num4 = dataSet.Tables["OR030100"].Rows.Count - 1; for (long i = 0L; i <= num4; i += 1L) { row = dataSet.Tables["OR030100"].Rows[(int)i]; string str3 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("insert into " + Variables.gTermi + "TmpOCompraExp (NroLinea,Codigo,Descripcion,CantidadOV,CodProv,NomProv,Seleccion) values ('", row["OR03002"]), "','"), row["OR03005"]), "','"), Strings.Trim(StringType.FromObject(row["OR03006"]))), " "), Strings.Trim(StringType.FromObject(row["OR03007"]))), "',"), row["OR03011"]), ",")) + "'", this.cbProveedor.SelectedValue), "',")); int num2 = Strings.InStr(this.cbProveedor.Text, "-", 1); command3 = new SqlCommand(str3 + "'" + Strings.Mid(this.cbProveedor.Text, num2 + 1) + "',0)", connection2); try { num3 = command3.ExecuteNonQuery(); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, 0, null); this.gErrorAct = true; connection.Close(); connection2.Close(); ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } connection.Close(); connection2.Close(); } }
private void ActTmp() { DataRow row; long num; SqlDataReader reader; DateTime time2; DateTime time3; string str4; DataSet dataSet = new DataSet(); DataSet set2 = new DataSet(); this.cmbSalir.Enabled = false; this.cmbVolver.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 num4 = new SqlCommand("delete " + Variables.gTermi + "TmpCalendario", connection2).ExecuteNonQuery(); SqlCommand command4 = new SqlCommand("delete " + Variables.gTermi + "TmpCalendarioStkComp", connection2); num4 = command4.ExecuteNonQuery(); string str = "SELECT OR01001,OR01004,OR01016,OR01050,OR03002,OR03005,OR03006,OR03007,OR03011,OR03012,OR03051,OR04002,OR04003,OR04004,OR04005,OR04008 FROM dbo.OR010100 inner join OR030100 on OR010100.OR01001=OR030100.OR03001 inner join OR040100 on OR010100.OR01001=OR040100.OR04001 where OR010100.OR01002=6 and OR010100.OR01091=0 and OR03011-OR03012<>0 and OR03034=1 and ("; if (Variables.gIntr01) { str = str + "OR01004='INTR01' "; if (Variables.gIntr02) { str = str + "or OR01004='INTR02' "; } if (Variables.gIntr03) { str = str + "or OR01004='INTR03' "; } if (Variables.gIntr04) { str = str + "or OR01004='INTR04' "; } } else if (Variables.gIntr02) { str = str + "OR01004='INTR02' "; if (Variables.gIntr03) { str = str + "or OR01004='INTR03' "; } if (Variables.gIntr04) { str = str + "or OR01004='INTR04' "; } } else if (Variables.gIntr03) { str = str + "OR01004='INTR03' "; if (Variables.gIntr04) { str = str + "or OR01004='INTR04' "; } } else if (Variables.gIntr04) { str = str + "OR01004='INTR04' "; } SqlCommand command3 = new SqlCommand(str + ") order by OR010100.OR01016", connection); command3.CommandTimeout = 900; dataSet.Clear(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command3; adapter.Fill(dataSet, "OR010100"); long num9 = dataSet.Tables["OR010100"].Rows.Count - 1; for (num = 0L; num <= num9; num += 1L) { row = dataSet.Tables["OR010100"].Rows[(int)num]; str4 = "insert into " + Variables.gTermi + "TmpCalendario (FechaEnt,Cliente,ListaRec,NroOA,NroLinea,Codigo,Descripcion,Almacen,Cantidad,AsignadoA,Observaciones,ReqEsp,Horas,SinStock,Obs) values ("; CalcDates dates = new CalcDatesClass(); short daysToDue = 0; DataRow row3 = row; string str9 = "OR01016"; DateTime currentDate = DateType.FromObject(row3[str9]); string dayCountType = "H"; string company = "01"; dates.WeekDate(ref daysToDue, ref currentDate, ref dayCountType, ref company); row3[str9] = currentDate; str4 = 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((str4 + "'" + Strings.Format(dates.MidDate, "MM/dd/yyyy")) + "','", row["OR01004"]), "','"), row["OR03051"]), "','"), row["OR01001"]), "','"), row["OR03002"]), "','"), row["OR03005"]), "','"), row["OR03006"]), " "), row["OR03007"]), "','"), row["OR01050"]), "',"), ObjectType.SubObj(row["OR03011"], row["OR03012"])), ",")); if (StringType.StrCmp(Strings.Trim(StringType.FromObject(row["OR04002"])), "0", false) == 0) { str4 = str4 + "'',"; } else { str4 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04002"]), "',")); } if (StringType.StrCmp(Strings.Trim(StringType.FromObject(row["OR04003"])), "0", false) == 0) { if (StringType.StrCmp(Strings.Trim(StringType.FromObject(row["OR04004"])), "0", false) == 0) { str4 = str4 + "'',"; } else { str4 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04004"]), "',")); } } else if (StringType.StrCmp(Strings.Trim(StringType.FromObject(row["OR04004"])), "0", false) == 0) { str4 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04003"]), "',")); } else { str4 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04003"]), " "), row["OR04004"]), "',")); } if (StringType.StrCmp(Strings.Trim(StringType.FromObject(row["OR04005"])), "0", false) == 0) { str4 = str4 + "'',"; } else { str4 = StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04005"]), "',")); } command4 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(str4 + "'", row["OR04008"]), "',0,0)")), connection2); try { num4 = 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.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } command3 = new SqlCommand("SELECT distinct NroOA from " + Variables.gTermi + "TmpCalendario", connection2); command3.CommandTimeout = 900; dataSet.Clear(); adapter = new SqlDataAdapter(); adapter.SelectCommand = command3; adapter.Fill(dataSet, Variables.gTermi + "TmpCalendario"); long num7 = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows.Count - 1; for (num = 0L; num <= num7; num += 1L) { row = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows[(int)num]; SqlCommand command = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT * from GesEnsObs where NroOE='", row["NroOA"]), "'")), connection2); reader = command.ExecuteReader(); if (reader.Read()) { reader.Close(); command4 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("update " + Variables.gTermi + "TmpCalendario set Obs=1 where NroOA='", row["NroOA"]), "'")), connection2); try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception8) { ProjectData.SetProjectError(exception8); Exception exception2 = exception8; Interaction.MsgBox("Se ha producido el siguiente error:" + exception2.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } else { reader.Close(); } } command3 = new SqlCommand("SELECT * from " + Variables.gTermi + "TmpCalendario order by FechaEnt", connection2); command3.CommandTimeout = 900; dataSet.Clear(); adapter = new SqlDataAdapter(); adapter.SelectCommand = command3; adapter.Fill(dataSet, Variables.gTermi + "TmpCalendario"); if (dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows.Count != 0) { row = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows[0]; if (DateAndTime.Weekday(DateType.FromObject(row["FechaEnt"]), FirstDayOfWeek.Sunday) > 1) { time3 = DateAndTime.DateAdd(DateInterval.Day, (double)((DateAndTime.Weekday(DateType.FromObject(row["FechaEnt"]), FirstDayOfWeek.Sunday) - 1) * -1), DateType.FromObject(row["FechaEnt"])); } else { time3 = DateType.FromObject(row["FechaEnt"]); } } command3 = new SqlCommand("SELECT * from " + Variables.gTermi + "TmpCalendario order by FechaEnt desc", connection2); command3.CommandTimeout = 900; dataSet.Clear(); adapter = new SqlDataAdapter(); adapter.SelectCommand = command3; adapter.Fill(dataSet, Variables.gTermi + "TmpCalendario"); if (dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows.Count != 0) { row = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows[0]; if (DateAndTime.Weekday(DateType.FromObject(row["FechaEnt"]), FirstDayOfWeek.Sunday) < 7) { time2 = DateAndTime.DateAdd(DateInterval.Day, (double)(7 - DateAndTime.Weekday(DateType.FromObject(row["FechaEnt"]), FirstDayOfWeek.Sunday)), DateType.FromObject(row["FechaEnt"])); } else { time2 = DateType.FromObject(row["FechaEnt"]); } } while (DateTime.Compare(time3, time2) <= 0) { SqlCommand command2 = new SqlCommand("SELECT * FROM " + Variables.gTermi + "TmpCalendario where FechaEnt='" + Strings.Format(time3, "MM/dd/yyyy") + "'", connection2); reader = command2.ExecuteReader(); if (reader.Read()) { reader.Close(); } else { reader.Close(); reader = new SqlCommand("SELECT * FROM dbo.SYHO0100 where SYHO001='" + Strings.Format(time3, "MM/dd/yyyy") + "'", connection).ExecuteReader(); if (reader.Read()) { command4 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj((("insert into " + Variables.gTermi + "TmpCalendario (FechaEnt,Observaciones) values (") + "'" + Strings.Format(time3, "MM/dd/yyyy") + "',") + "'", reader["SYHO002"]), "')")), connection2); reader.Close(); } else { command4 = new SqlCommand(("insert into " + Variables.gTermi + "TmpCalendario (FechaEnt) values (") + "'" + Strings.Format(time3, "MM/dd/yyyy") + "')", connection2); reader.Close(); } try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception9) { ProjectData.SetProjectError(exception9); Exception exception3 = exception9; Interaction.MsgBox("Se ha producido el siguiente error:" + exception3.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } time3 = DateAndTime.DateAdd(DateInterval.Day, 1.0, time3); } command3 = new SqlCommand("SELECT * from " + Variables.gTermi + "TmpCalendario where not Codigo is null order by NroOA,NroLinea", connection2); command3.CommandTimeout = 900; dataSet.Clear(); adapter = new SqlDataAdapter(); adapter.SelectCommand = command3; adapter.Fill(dataSet, Variables.gTermi + "TmpCalendario"); long num6 = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows.Count - 1; for (num = 0L; num <= num6; num += 1L) { row = dataSet.Tables[Variables.gTermi + "TmpCalendario"].Rows[(int)num]; command3 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT OR03005,OR03006,OR03007,OR03011,OR03012,SC03003,SC03004,SC03005 FROM dbo.OR030100 inner join SC030100 on OR030100.OR03005=SC030100.SC03001 where OR03001='", row["NroOA"]), "' and OR03002='"), row["NroLinea"]), "' and OR03003<>'000' and SC03002='"), row["Almacen"]), "'")), connection); command3.CommandTimeout = 900; set2.Clear(); SqlDataAdapter adapter2 = new SqlDataAdapter(); adapter2.SelectCommand = command3; adapter2.Fill(set2, "OR030100"); bool flag = false; long num5 = set2.Tables["OR030100"].Rows.Count - 1; for (long i = 0L; i <= num5; i += 1L) { DataRow row2 = set2.Tables["OR030100"].Rows[(int)i]; if (BooleanType.FromObject(ObjectType.BitOrObj(ObjectType.ObjTst(row2["SC03003"], 0, false) <= 0, ObjectType.ObjTst(ObjectType.AddObj(row2["SC03004"], row2["SC03005"]), row2["SC03003"], false) > 0))) { flag = true; } if (ObjectType.ObjTst(ObjectType.AddObj(row2["SC03004"], row2["SC03005"]), row2["SC03003"], false) > 0) { reader = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("SELECT PC03043,PC03044,PC03016 FROM dbo.PC030100 where PC03005='", row2["OR03005"]), "' and PC03043<PC03044 and PC03029=1 ")) + "and PC03035='", row["Almacen"]), "' order by PC03016")), connection).ExecuteReader(); if (reader.Read()) { str4 = 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 " + Variables.gTermi + "TmpCalendarioStkComp (NroOA,NroLinea,CodComp,DescComp,Cantidad,StkFisico,StkComprometido,FechaOC,CantOC) values ('", row["NroOA"]), "','"), row["NroLinea"]), "','"), row2["OR03005"]), "','"), row2["OR03006"]), " "), row2["OR03007"]), "',"), ObjectType.SubObj(row2["OR03011"], row2["OR03012"])), ","), row2["SC03003"]), ","), ObjectType.AddObj(row2["SC03004"], row2["SC03005"])), ",'"), Strings.Format(RuntimeHelpers.GetObjectValue(reader["PC03016"]), "MM/dd/yyyy")), "',"), ObjectType.SubObj(reader["PC03044"], reader["PC03043"])), ")")); reader.Close(); command4 = new SqlCommand(str4, connection2); try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception10) { ProjectData.SetProjectError(exception10); Exception exception4 = exception10; Interaction.MsgBox("Se ha producido el siguiente error:" + exception4.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } else { reader.Close(); command4 = 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("insert into " + Variables.gTermi + "TmpCalendarioStkComp (NroOA,NroLinea,CodComp,DescComp,Cantidad,StkFisico,StkComprometido) values ('", row["NroOA"]), "','"), row["NroLinea"]), "','"), row2["OR03005"]), "','"), row2["OR03006"]), " "), row2["OR03007"]), "',"), ObjectType.SubObj(row2["OR03011"], row2["OR03012"])), ","), row2["SC03003"]), ","), ObjectType.AddObj(row2["SC03004"], row2["SC03005"])), ")")), connection2); try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception11) { ProjectData.SetProjectError(exception11); Exception exception5 = exception11; Interaction.MsgBox("Se ha producido el siguiente error:" + exception5.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } } else { command4 = 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("insert into " + Variables.gTermi + "TmpCalendarioStkComp (NroOA,NroLinea,CodComp,DescComp,Cantidad,StkFisico,StkComprometido) values ('", row["NroOA"]), "','"), row["NroLinea"]), "','"), row2["OR03005"]), "','"), row2["OR03006"]), " "), row2["OR03007"]), "',"), ObjectType.SubObj(row2["OR03011"], row2["OR03012"])), ","), row2["SC03003"]), ","), ObjectType.AddObj(row2["SC03004"], row2["SC03005"])), ")")), connection2); try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception12) { ProjectData.SetProjectError(exception12); Exception exception6 = exception12; Interaction.MsgBox("Se ha producido el siguiente error:" + exception6.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } } if (flag) { command4 = new SqlCommand(StringType.FromObject(ObjectType.StrCatObj(ObjectType.StrCatObj("update " + Variables.gTermi + "TmpCalendario set SinStock=1 where NroOA='", row["NroOA"]), "'")), connection2); try { num4 = command4.ExecuteNonQuery(); } catch (Exception exception13) { ProjectData.SetProjectError(exception13); Exception exception7 = exception13; Interaction.MsgBox("Se ha producido el siguiente error:" + exception7.Message, MsgBoxStyle.OKOnly, null); connection.Close(); connection2.Close(); this.cmbSalir.Enabled = true; this.cmbVolver.Enabled = true; ProjectData.ClearProjectError(); return; ProjectData.ClearProjectError(); } } } connection.Close(); connection2.Close(); }
public void FromObject(object value, DateTime expected) { Assert.Equal(expected, DateType.FromObject(value)); }