public frmSelectPrintFormat(PrintFormat CurrentPrintFormat) { InitializeComponent(); _RB = new RadioButton[20] { radioButton1, radioButton2, radioButton3, radioButton4, radioButton5, radioButton6, radioButton7, radioButton8, radioButton9, radioButton10, radioButton11, radioButton12, radioButton13, radioButton14, radioButton15, radioButton16, radioButton17, radioButton18, radioButton19, radioButton20 }; for (int i = 0; i < _RB.Length; i++) { _RB[i].Text = PrintCodeUtilties.PrtFmtShowName((PrintFormat)i); if (i == Convert.ToInt32(CurrentPrintFormat)) { _RB[i].Checked = true; } } }
private void MoveDataToHistory(string WStime) { string text = Convert.ToDateTime(WStime).AddDays(Program.DayToFlush).ToString("yyyy/MM/dd"); StringBuilder stringBuilder = new StringBuilder(""); stringBuilder.AppendFormat("SELECT ProductName, PackDate, CreateDate, FarmerName, AuthName, TraceCode, EanCOde, QRCodeUrl, initPrintCodeSrt, initPrintCodeEnd, initAvailablePrint, PrintCodeSrt, PrintCodeEnd, Unit, Sum(TotalPrinted) as Printed, PreTraceCode, ExpDate, ResumeID, ReceiveOrg, Producer,SourceProducer "); stringBuilder.AppendFormat("FROM ResumeCurrent "); stringBuilder.AppendFormat("WHERE PackDate < datevalue('{0}') ", text); stringBuilder.AppendFormat("Group by ProductName, PackDate, CreateDate, FarmerName, AuthName, TraceCode, EanCOde, QRCodeUrl, initPrintCodeSrt, initPrintCodeEnd, initAvailablePrint, PrintCodeSrt, PrintCodeEnd, Unit, PreTraceCode, ExpDate, ResumeID, ReceiveOrg, Producer,SourceProducer "); using (OleDbConnection oleDbConnection = new OleDbConnection(Program.ConnectionString)) { using (OleDbCommand oleDbCommand = new OleDbCommand(stringBuilder.ToString(), oleDbConnection)) { try { oleDbCommand.CommandTimeout = 0; oleDbConnection.Open(); object obj = oleDbCommand.ExecuteReader(); int num = 0; string text2 = ""; string empty = string.Empty; if (obj != null) { DataTable dataTable = new DataTable(); dataTable.Load((OleDbDataReader)obj); foreach (DataRow row in dataTable.Rows) { empty = (row["ExpDate"].Equals(DBNull.Value) ? "NULL" : ((DateTime.Compare(Convert.ToDateTime(row["ExpDate"]), Convert.ToDateTime("1900/01/02")) > 0) ? Convert.ToDateTime(row["ExpDate"]).ToString("yyyy/MM/dd") : "NULL")); string[,] strFieldArray = new string[19, 2] { { "ProductName", row["ProductName"].ToString() }, { "PackDate", row["PackDate"].ToString() }, { "CreateDate", row["CreateDate"].ToString() }, { "FarmerName", row["FarmerName"].ToString() }, { "AuthName", row["AuthName"].ToString() }, { "TraceCode", row["TraceCode"].ToString() }, { "EanCode", row["EanCode"].ToString() }, { "QRCodeUrl", row["QRCodeUrl"].ToString() }, { "Unit", row["Unit"].ToString() }, { "Producer", row["Producer"].ToString() }, { "ExpDate", empty }, { "initPrintCodeSrt", row["initPrintCodeSrt"].ToString() }, { "initPrintCodeEnd", row["initPrintCodeEnd"].ToString() }, { "initAvailablePrint", row["initAvailablePrint"].ToString() }, { "PreTraceCode", row["PreTraceCode"].ToString() }, { "TotalPrinted", row["Printed"].ToString() }, { "ReceiveOrg", row["ReceiveOrg"].ToString() }, { "ResumeID", row["ResumeID"].ToString() }, { "SourceProducer", row["SourceProducer"].ToString() } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "ResumeHistory", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); if (PrintCodeUtilties.GetNextNPrintCode(row["initPrintCodeEnd"].ToString(), 2) == row["PrintCodeSrt"].ToString()) { num = 0; text2 = PrintCodeUtilties.GetNextNPrintCode(row["initPrintCodeEnd"].ToString(), 2); } else { num = (int)(Convert.ToInt64(row["initPrintCodeEnd"]) - Convert.ToInt64(row["PrintCodeSrt"])) + 1; text2 = row["PrintCodeSrt"].ToString(); } strFieldArray = new string[4, 2] { { "PrintCodeSrt", text2 }, { "PrintCodeEnd", row["initPrintCodeEnd"].ToString() }, { "PintCodeCount", num.ToString() }, { "DisposeReason", "NULL" } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "FlushPrintCode", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); string[] strWhereParameterArray = new string[1] { row["ResumeID"].ToString() }; foreach (DataRow row2 in ((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "PrintCodeSrt, PrintCodeEnd, PintCodeCount, DisposeReason", "ResumeDispose", "ResumeID = {0}", "", null, strWhereParameterArray, CommandOperationType.ExecuteReaderReturnDataTable)).Rows) { strFieldArray = new string[4, 2] { { "PrintCodeSrt", row2["PrintCodeSrt"].ToString() }, { "PrintCodeEnd", row2["PrintCodeEnd"].ToString() }, { "PintCodeCount", row2["PintCodeCount"].ToString() }, { "DisposeReason", row2["DisposeReason"].ToString() } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "FlushPrintCode", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); } } } string[] strWhereParameterArray2 = new string[1] { text }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Delete, "", "ResumeCurrent", "PackDate < datevalue({0})", "", null, strWhereParameterArray2, CommandOperationType.ExecuteNonQuery); } catch (Exception) { } } } }