private void lblFechVtoCAE_TextChanged(object sender, System.EventArgs e) { string Dia = null; string Mes = null; string Ano = null; Ano = DateAndTime.Year(Convert.ToDateTime(lblFechVtoCAE.Text)); if (Convert.ToInt32(DateAndTime.Month(Convert.ToDateTime(lblFechVtoCAE.Text))) < 10) { Mes = "0" + DateAndTime.Month(Convert.ToDateTime(lblFechVtoCAE.Text)); } else { Mes = DateAndTime.Month(Convert.ToDateTime(lblFechVtoCAE.Text)); } if (Convert.ToInt32(DateAndTime.Day(Convert.ToDateTime(lblFechVtoCAE.Text))) < 10) { Dia = "0" + DateAndTime.Day(Convert.ToDateTime(lblFechVtoCAE.Text)); } else { Dia = DateAndTime.Day(Convert.ToDateTime(lblFechVtoCAE.Text)); } txtCodBarNum.Text = Interaction.GetSetting("Programa", "EMPRESA", "CUIT", Convert.ToString(1)) + lblCod_cbe.Text + cmbSucursal.Text + lblCAE.Text + Ano + Mes + Dia + Cod_Verificador.CodVerificador(ref Interaction.GetSetting("Programa", "EMPRESA", "CUIT", Convert.ToString(1)) + lblCod_cbe.Text + cmbSucursal.Text + lblCAE.Text + Ano + Mes + Dia); }
public string Return_EncryptDate(DateTime DT) { string returnValue = ""; string str_Renamed = ""; short i = 0; string DL = ""; // str = Format(DT, "mm/dd/yyyy") ///changed by nancy str_Renamed = DateAndTime.Month(DT).ToString("00") + "/" + DateAndTime.Day(DT).ToString("00") + "/" + DateAndTime.Year(DT).ToString("0000"); for (i = 1; i <= 10; i++) { DL = DL + System.Convert.ToString(Strings.Asc(str_Renamed.Substring(i - 1, 1)) + 7); } for (i = 1; i <= 10; i++) { VBMath.Randomize(); DL = (VBMath.Rnd() * VBMath.Rnd() * i * 5).ToString("00") + DL; } for (i = 1; i <= 10; i++) { VBMath.Randomize(); DL = DL + (VBMath.Rnd() * VBMath.Rnd() * i * 5).ToString("00"); //Format(Rnd() + i * i + (i * Rnd()) / i, "00") } returnValue = DL; return(returnValue); }
//UPGRADE_NOTE: Argument type has been changed to Object. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="D0BD8832-D1AC-487C-8AA5-B36F9284E51E"' public bool ShowSave(object cmdlg, DatabaseExportEnum ExportMode, ref string DialogTitle = "Export Recordset to...") { bool functionReturnValue = false; string t_Day = null; string t_Month = null; string st_Name = null; string Extention = null; t_Day = Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); t_Month = Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); if (Strings.Len(t_Day) == 1) { t_Day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); } if (Strings.Len(t_Month) == 1) { t_Month = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); } st_Name = "PasteExport" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Month) + Strings.Trim(t_Day); if (ExportMode == DatabaseExportEnum.CSV) { Extention = "Comma Separated Values (*.csv)|*.csv|Text Files (*.txt)|*.txt|"; } // ERROR: Not supported in C#: OnErrorStatement var _with2 = cmdlg; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.CancelError. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.CancelError = true; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.DialogTitle. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.DialogTitle = DialogTitle; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.FileName. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.FileName = st_Name; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.filter. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.filter = Extention; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.FilterIndex. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.FilterIndex = 0; //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.ShowSave. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' _with2.ShowSave(); //UPGRADE_WARNING: Couldn't resolve default property of object cmdlg.FileName. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' ExportFilePath = _with2.FileName; if (!string.IsNullOrEmpty(ExportFilePath)) { functionReturnValue = true; } Extracter: return(functionReturnValue); }
public void Fields() { var now = DateTime.UtcNow; var calendar = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar; Assert.Equal(calendar.GetYear(now), DateAndTime.Year(now)); Assert.Equal(calendar.GetMonth(now), DateAndTime.Month(now)); Assert.Equal(calendar.GetDayOfMonth(now), DateAndTime.Day(now)); Assert.Equal(calendar.GetHour(now), DateAndTime.Hour(now)); Assert.Equal(calendar.GetMinute(now), DateAndTime.Minute(now)); Assert.Equal(calendar.GetSecond(now), DateAndTime.Second(now)); }
private void cmdStart_Click(System.Object eventSender, System.EventArgs eventArgs) { //If mdbFile.Text <> "" Then string dtDate = null; string dtMonth = null; string stPass = null; //Construct password........... if (Strings.Len(DateAndTime.Day(DateAndTime.Today)) == 1) { dtDate = "0" + Conversion.Str(DateAndTime.Day(DateAndTime.Today)); } else { dtDate = Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today))); } if (Strings.Len(DateAndTime.Month(DateAndTime.Today)) == 1) { dtMonth = "0" + Conversion.Str(DateAndTime.Month(DateAndTime.Today)); } else { dtMonth = Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today))); } //Create password stPass = dtDate + "##" + dtMonth; stPass = Strings.Replace(stPass, " ", ""); if (Strings.Trim(txtPassword.Text) == stPass) { // ZeroiseStock //Trim(mdbFile.Text) if (modRecordSet.openConnection() == true) { ExportToCSV(); } else { Interaction.MsgBox("Connection to database was not successful"); } } else { Interaction.MsgBox("Incorrect password was entered!!!", MsgBoxStyle.Exclamation, "Incorrect Passwords"); } //Else //MsgBox "Upload your database before you continue", vbOKOnly, "Customers" //End If }
private void txtPassword_KeyPress(System.Object eventSender, System.Windows.Forms.KeyPressEventArgs eventArgs) { short KeyAscii = Strings.Asc(eventArgs.KeyChar); string dtDate = null; string dtMonth = null; string stPass = null; //Construct password........... if (KeyAscii == 13) { if (Strings.Len(DateAndTime.Day(DateAndTime.Today)) == 1) { dtDate = "0" + Conversion.Str(DateAndTime.Day(DateAndTime.Today)); } else { dtDate = Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today))); } if (Strings.Len(DateAndTime.Month(DateAndTime.Today)) == 1) { dtMonth = "0" + Conversion.Str(DateAndTime.Month(DateAndTime.Today)); } else { dtMonth = Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today))); } //Create password stPass = dtDate + "##" + dtMonth; stPass = Strings.Replace(stPass, " ", ""); if (Strings.Trim(txtPassword.Text) == stPass) { //ZeroiseStock Update_Handheld(); } else { Interaction.MsgBox("Incorrect password was entered!!!", MsgBoxStyle.Exclamation, "Incorrect Passwords"); } } eventArgs.KeyChar = Strings.Chr(KeyAscii); if (KeyAscii == 0) { eventArgs.Handled = true; } }
private void txtPassword_KeyPress(System.Object eventSender, System.Windows.Forms.KeyPressEventArgs eventArgs) { short KeyAscii = Strings.Asc(eventArgs.KeyChar); string dtDate = null; string dtMonth = null; string stPass = null; //Construct password........... if (KeyAscii == 13) { if (Strings.Len(DateAndTime.Day(DateAndTime.Today)) == 1) { dtDate = "0" + Conversion.Str(DateAndTime.Day(DateAndTime.Today)); } else { dtDate = Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today))); } if (Strings.Len(DateAndTime.Month(DateAndTime.Today)) == 1) { dtMonth = "0" + Conversion.Str(DateAndTime.Month(DateAndTime.Today)); } else { dtMonth = Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today))); } //Create password stPass = dtDate + "##" + dtMonth; stPass = Strings.Replace(stPass, " ", ""); if (Strings.Trim(this.txtPassword.Text) == stPass) { //Call intialize process... Frame1.Visible = false; } else { Interaction.MsgBox("Incorrect password was entered!!!", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "4POS Stock Fix"); } } eventArgs.KeyChar = Strings.Chr(KeyAscii); if (KeyAscii == 0) { eventArgs.Handled = true; } }
public static void WriteToLogFile(string MsgStr) { string FileName = ""; // static short FL = 0; VBConversions Note: Static variable moved to class level and renamed WriteToLogFile_FL. Local static variables are not supported in C#. string NewFName = ""; short fnum = 0; Chaps_Main.Register_Renamed = new CStoreCommander.Entities.Register { WritePosLog = true }; try { if (Chaps_Main.Register_Renamed.WritePosLog) { FileName = @"C:\APILog\PosLog.txt"; WriteToLogFile_FL++; if (WriteToLogFile_FL > 100) { WriteToLogFile_FL = (short)0; if (FileSystem.Dir(FileName) != "") { if (FileSystem.FileLen(FileName) > 1000000) { NewFName = Chaps_Main.Logs_Path + "PosLog" + DateAndTime.Day(DateAndTime.Today).ToString("00") + DateAndTime.Hour(DateAndTime.TimeOfDay).ToString("00") + ".txt"; Variables.CopyFile(FileName, NewFName, 0); Variables.DeleteFile(FileName); } } } fnum = (short)(FileSystem.FreeFile()); FileSystem.FileOpen(fnum, FileName, OpenMode.Append); FileSystem.PrintLine(fnum, DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + Strings.Space(3) + MsgStr); FileSystem.FileClose(fnum); } } catch { goto err1; } err1: 1.GetHashCode(); //VBConversions note: C# requires an executable line here, so a dummy line was added. }
//private uint CRC32(string DataStr) //{ // uint returnValue = 0; // uint crc32Result = 0; // short i = 0; // short strLen = 0; // short iLookup = 0; // crc32Result = 0xFFFFFFFF; // strLen = (short)DataStr.Length; // for (i = 1; i <= strLen; i++) // { // iLookup = Convert.ToInt16((crc32Result & 0xFF) ^ Strings.Asc(DataStr.Substring(i - 1, 1))); // crc32Result = Convert.ToUInt32(((crc32Result & 0xFFFFFF00) / 0x100) & 16777215); // nasty shr 8 with vb :/ // crc32Result = crc32Result ^ Convert.ToUInt32(crc32Table[iLookup]); // } // if (crc32Result < 0) // { // returnValue = ~(crc32Result); // } // else // { // returnValue = crc32Result; // } // return returnValue; //} public void WriteToLog(string MsgStr) { string FileName = ""; short fnum = 0; short i; string NewFName = ""; try { if (Chaps_Main.Register_Renamed.WritePosLog) { { FileName = Chaps_Main.Logs_Path + "XML.log"; } if (FileSystem.Dir(FileName) != "") { if (FileSystem.FileLen(FileName) > 1000000) { NewFName = Chaps_Main.Logs_Path + "XML" + DateAndTime.Day(DateAndTime.Today).ToString("00") + DateAndTime.Hour(DateAndTime.TimeOfDay).ToString("00") + ".log"; Variables.CopyFile(FileName, NewFName, 0); Variables.DeleteFile(FileName); } } fnum = (short)(FileSystem.FreeFile()); FileSystem.FileOpen(fnum, FileName, OpenMode.Append); FileSystem.PrintLine(fnum, DateTime.Now + " " + MsgStr); FileSystem.FileClose(fnum); } } catch { goto Err_End; } Err_End: 1.GetHashCode(); //VBConversions note: C# requires an executable line here, so a dummy line was added. }
/// <summary> /// Method to write to log file /// </summary> /// <param name="msgStr"></param> protected void WriteToLogFile(string msgStr) { try { var register = CacheManager.GetRegister(PosId); if (register.WritePosLog) { var logPath = @"C:\APILog\"; var fileName = logPath + "PosLog_" + PosId + ".txt"; WriteToLogFileFl++; if (WriteToLogFileFl > 100) { WriteToLogFileFl = (short)0; if (FileSystem.Dir(fileName) != "") { if (FileSystem.FileLen(fileName) > 1000000) { var newFName = logPath + "PosLog_" + PosId + DateAndTime.Day(DateAndTime.Today).ToString("00") + DateAndTime.Hour(DateAndTime.TimeOfDay).ToString("00") + ".txt"; Variables.CopyFile(fileName, newFName, 0); Variables.DeleteFile(fileName); } } } using (StreamWriter fileWriter = new StreamWriter(fileName, true)) { fileWriter.WriteLine(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + Strings.Space(3) + msgStr); } } } catch (Exception ex) { } }
public decimal DateToJulDate(DateTime vdatDate) { decimal DateToJulDate = default(decimal); if ((DateTime.Compare(vdatDate, new DateTime(499230432000000000L)) < 0) | (DateTime.Compare(vdatDate, new DateTime(693937151990000000L)) > 0)) { Information.Err().Raise(50000, "UtilTime", "Datum außerhalb des Gültigkeitsbereiches."); return(DateToJulDate); } try { DateToJulDate = checked (MakeJulDate((short)DateAndTime.Day(vdatDate), (short)DateAndTime.Month(vdatDate), (short)DateAndTime.Year(vdatDate), (short)DateAndTime.Hour(vdatDate), (short)DateAndTime.Minute(vdatDate), (short)DateAndTime.Second(vdatDate), 0)); return(DateToJulDate); } catch (Exception ex2) { ProjectData.SetProjectError(ex2); Exception ex = ex2; string dstrErrMsg = ExceptionHelper.GetExceptionMessage(ex); Information.Err().Raise(50000, "UtilTime", "Fehler beim Konvertieren des Datums.\n" + dstrErrMsg); ProjectData.ClearProjectError(); return(DateToJulDate); } }
private static bool copyFilesFromPoints() { bool functionReturnValue = false; bool sFiles = false; string f_File = null; string ldir1 = null; ADODB.Recordset rj = default(ADODB.Recordset); Scripting.FileSystemObject FSO = new Scripting.FileSystemObject(); sFiles = false; f_File = Strings.Trim(Conversion.Str(DateAndTime.Year(DateAndTime.Today))) + "\\" + Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today))) + "\\" + Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today))); rj = modRecordSet.getRS(ref "SELECT POS_Name FROM POS WHERE POS_Disabled = False AND POS_KitchenMonitor = False;"); if (rj.RecordCount) { if (FSO.FolderExists(modRecordSet.serverPath + "HQSales")) { } else { FSO.CreateFolder(modRecordSet.serverPath + "HQSales"); } //Make sure the HQSales file is empty... //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(modRecordSet.serverPath + "HQSales\\*.*"); while (!(string.IsNullOrEmpty(ldir1))) { FSO.DeleteFile(modRecordSet.serverPath + "HQSales\\" + ldir1, true); //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(); } while (rj.EOF == false) { if (Strings.LCase(rj.Fields("POS_Name").Value) == "localhost") { if (FSO.FolderExists(modRecordSet.serverPath + "data\\Server\\" + f_File)) { //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(modRecordSet.serverPath + "data\\Server\\" + f_File + "\\*.*"); while (!(string.IsNullOrEmpty(ldir1))) { FSO.CopyFile(modRecordSet.serverPath + "data\\Server\\" + f_File + "\\" + ldir1, modRecordSet.serverPath + "HQSales\\" + ldir1, true); //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(); sFiles = true; } } } else { if (FSO.FolderExists(modRecordSet.serverPath + "data\\" + rj.Fields("POS_Name").Value + "\\" + f_File)) { //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(modRecordSet.serverPath + "data\\" + rj.Fields("POS_Name").Value + "\\" + f_File + "\\*.*"); while (!(string.IsNullOrEmpty(ldir1))) { FSO.CopyFile(modRecordSet.serverPath + "data\\" + rj.Fields("POS_Name").Value + "\\" + f_File + "\\" + ldir1, modRecordSet.serverPath + "HQSales\\" + ldir1, true); //UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' ldir1 = FileSystem.Dir(); sFiles = true; } } } rj.moveNext(); } } if (sFiles == true) { functionReturnValue = true; } else { functionReturnValue = false; } return(functionReturnValue); }
public static string ToSqlDateTime(object Value) { string res = ""; DateTime dtg = default(DateTime); dtg = ToDateDef(Value); if (dtg == new DateTime(2018, 8, 6)) { res = ""; } else if (dtg != new DateTime(1754, 1, 1)) { res = dtg.ToString("yyyy-MM-dd"); if (DateAndTime.DateDiff(DateInterval.Second, dtg, DateAndTime.DateSerial(DateAndTime.Year(dtg), DateAndTime.Month(dtg), DateAndTime.Day(dtg))) != 0) { res += " "; res = dtg.ToString("T"); } } return(res.Trim()); }
public static int Day(DateTime DateValue) { return(DateAndTime.Day(DateValue)); }
private bool ImportCSVHand(ref string strFilePath) { bool functionReturnValue = false; Scripting.FileSystemObject oFileSys = new Scripting.FileSystemObject(); Scripting.TextStream oFile = default(Scripting.TextStream); string strCSV = null; string strFldName = null; //String of fields' name string strFV = null; //String of fields' values short iCount = 0; short x = 0; string strStr_1 = null; string strStr_2 = null; string Temp = null; string strIn = null; bool blEmpty = false; bool blTrue = false; string t_day = null; string t_Month = null; t_day = Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); t_Month = Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents(); ADODB.Recordset rs = default(ADODB.Recordset); if (Strings.Len(t_day) == 1) { t_day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); } if (Strings.Len(t_Month) == 1) { t_Month = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); } // ERROR: Not supported in C#: OnErrorStatement //Create A Table Name st_Name = "Handheld" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Month) + Strings.Trim(t_day); blTrue = false; blEmpty = true; dReceipt = false; prgUpdate.Value = 1; if (oFileSys.FileExists(strFilePath)) { oFile = oFileSys.OpenTextFile(strFilePath, Scripting.IOMode.ForReading, false, Scripting.Tristate.TristateUseDefault); System.Windows.Forms.Application.DoEvents(); while (!oFile.AtEndOfLine) { System.Windows.Forms.Application.DoEvents(); if (prgUpdate.Value == prgUpdate.Maximum) { System.Windows.Forms.Application.DoEvents(); prgUpdate.Value = 0; } else { prgUpdate.Value = prgUpdate.Value + 1; System.Windows.Forms.Application.DoEvents(); } blEmpty = false; strCSV = oFile.ReadLine; strFV = strCSV; System.Windows.Forms.Application.DoEvents(); if (blTrue == false) { strFldName = "HandHeldID Number,Handheld_Barcode Text(50), Quantity Currency"; System.Windows.Forms.Application.DoEvents(); modRecordSet.cnnDB.Execute("CREATE TABLE " + st_Name + " (" + strFldName + ")"); blTrue = true; dReceipt = true; } if (strCSV != Constants.vbNullString) { //Repeat 2 Times // // strStr_1 = strCSV // x = Len(strCSV) - Len(Right(strCSV, Len(strCSV) - InStr(strCSV, ","))) // strStr_1 = mID$(strStr_1, 1, x - 1) // DoEvents // strStr_2 = Right(strCSV, Len(strCSV) - InStr(strCSV, ",")) // temp = strStr_2 strStr_1 = Strings.Split(strCSV, ",")[0]; // If CCur(Split(strCSV, ",")(5)) = 0 Then // strStr_2 = CCur(Split(strCSV, ",")(3)) // ElseIf CCur(Split(strCSV, ",")(3)) = 0 Then // strStr_2 = CCur(Split(strCSV, ",")(5)) // Else // strStr_2 = CCur(Split(strCSV, ",")(3)) - CCur(Split(strCSV, ",")(5)) // End If strStr_2 = Strings.Split(strCSV, ",")[5]; Temp = strStr_2; System.Windows.Forms.Application.DoEvents(); rs = modRecordSet.getRS(ref "SELECT * FROM " + st_Name + " WHERE Handheld_Barcode = '" + Strings.Trim(strStr_1) + "'"); if (rs.RecordCount > 0) { strIn = "UPDATE " + st_Name + " SET Quantity = " + rs.Fields("Quantity").Value + Convert.ToDecimal(strStr_2) + " WHERE Handheld_Barcode = '" + Strings.Trim(strStr_1) + "'"; } else { strIn = "INSERT INTO " + st_Name + " (Handheld_Barcode,Quantity) VALUES " + "('" + Strings.Trim(strStr_1) + "'," + Convert.ToDecimal(strStr_2) + ")"; } System.Windows.Forms.Application.DoEvents(); modRecordSet.cnnDB.Execute(strIn); System.Windows.Forms.Application.DoEvents(); } } if (blEmpty == true) { Interaction.MsgBox("Your CSV file is empty", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake"); functionReturnValue = false; return(functionReturnValue); } modRecordSet.cnnDB.Execute("INSERT INTO StockGroup (StockGroup_Name) VALUES ('" + st_Name + "')"); System.Windows.Forms.Application.DoEvents(); functionReturnValue = true; return(functionReturnValue); } else if (!oFileSys.FileExists(strFilePath)) { Interaction.MsgBox("CSV File does not exist", MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title); functionReturnValue = false; return(functionReturnValue); } ImportError: Interaction.MsgBox("Export aborted because " + Err().Description, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Handheld StockTake"); if (dReceipt == true) { modRecordSet.cnnDB.Execute("DROP TABLE " + st_Name); } return(functionReturnValue); // ERROR: Not supported in C#: ResumeStatement return(functionReturnValue); }
private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs) { string dbText = null; string sql = null; string stFileName = null; string lOrder = null; ADODB.Recordset rs = default(ADODB.Recordset); ADODB.Recordset rsData = default(ADODB.Recordset); //Exporting file... string lne = null; short n = 0; Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); switch (this.cmbSortField.SelectedIndex) { case 0: lOrder = "StockItem_Name"; break; case 1: lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"; break; case 2: lOrder = "[exclusiveSum]-[depositSum]"; break; case 3: lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"; break; case 4: lOrder = "IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum])"; break; case 5: lOrder = "StockList.quantitySum"; break; } if (this.cmbSort.SelectedIndex) { lOrder = lOrder + " DESC"; } lOrder = " ORDER BY " + lOrder; System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1"); if (_optType_0.Checked) { sql = "SELECT aStockItem.StockItemID, aStockItem.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department FROM StockList INNER JOIN (aStockItem INNER JOIN aStockGroup ON aStockItem.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem.StockItemID "; } else { sql = "SELECT aStockItem.StockItemID, aStockItem.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department FROM StockList INNER JOIN (aStockItem INNER JOIN aStockGroup ON aStockItem.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem.StockItemID "; switch (this.cmbGroup.SelectedIndex) { case 0: sql = Strings.Replace(sql, "StockGroup", "PricingGroup"); break; //Report.txtTitle.SetText "Product Performance - by Pricing Group" case 1: break; //Report.txtTitle.SetText "Product Performance - by Stock Group" case 2: sql = Strings.Replace(sql, "StockGroup", "Supplier"); sql = Strings.Replace(sql, "aSupplier", "Supplier"); break; //Report.txtTitle.SetText "Product Performance - by Supplier" } } if (string.IsNullOrEmpty(rs.Fields("Link_SQL").Value)) { } else { sql = sql + rs.Fields("Link_SQL").Value; } sql = sql + lOrder; string ptbl = null; string t_day = null; string t_Mon = null; if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today)))) == 1) { t_day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); } else { t_day = Convert.ToString(DateAndTime.Day(DateAndTime.Today)); } if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today)))) == 1) { t_Mon = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); } else { t_Mon = Conversion.Str(DateAndTime.Month(DateAndTime.Today)); } ptbl = modRecordSet.serverPath + "4POSProd" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Mon) + Strings.Trim(t_day); if (fso.FileExists(ptbl + ".csv")) { fso.DeleteFile((ptbl + ".csv")); } FileSystem.FileOpen(1, ptbl + ".csv", OpenMode.Output); //Open serverPath & "ProductPerformace.csv" For Output As #1 rs = modReport.getRSreport(ref sql); //Write Out CSV if (rs.BOF | rs.EOF) { Interaction.MsgBox("There are no recods to export, Try Changing Day End date range", MsgBoxStyle.ApplicationModal + MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Export Product Performance"); System.Windows.Forms.Cursor.Current = Cursors.Default; return; } else { //First line as column headings for (n = 0; n <= rs.Fields.Count - 1; n++) { lne = lne + Strings.Chr(34) + rs.Fields(n).Name + Strings.Chr(34) + ","; } FileSystem.PrintLine(1, lne); while (!rs.EOF) { lne = ""; for (n = 0; n <= rs.Fields.Count - 1; n++) { if (rs.Fields(n).Type == dbText) { lne = lne + Strings.Chr(34) + rs.Fields(n).Value + Strings.Chr(34) + ","; } else { lne = lne + rs.Fields(n).Value + ","; } } lne = Strings.Left(lne, Strings.Len(lne) - 1); //get rid of last comma FileSystem.PrintLine(1, lne); rs.moveNext(); } FileSystem.FileClose(1); Interaction.MsgBox("Product performance CSV File, was successfully exported to : " + ptbl + ".csv"); } System.Windows.Forms.Cursor.Current = Cursors.Default; }
/// <summary> /// Get Report of the Dip input values for print /// </summary> /// <param name="tillNumber">Till number</param> /// <param name="shiftNumber">Shift number</param> /// <param name="registerNumber">Register number</param> /// <param name="userCode">User code</param> /// <param name="error">Error message</param> /// <returns>Dip input report</returns> public Report PrintDipReport(int tillNumber, int shiftNumber, int registerNumber, string userCode, out ErrorMessage error) { error = new ErrorMessage(); var user = _loginManager.GetExistingUser(userCode); var report = new Report { ReportName = Utilities.Constants.TankDipFile, Copies = 1 }; var offSet = _policyManager.LoadStoreInfo().OffSet; string timeFormatHm = string.Empty; string timeFormatHms = string.Empty; GetTimeFormats(ref timeFormatHm, ref timeFormatHms); var store = _policyManager.LoadStoreInfo(); var strDate = DateAndTime.Year(DateAndTime.Today) + Strings.Right("00" + Convert.ToString(DateAndTime.Month(DateAndTime.Today)), 2) + Strings.Right("00" + Convert.ToString(DateAndTime.Day(DateAndTime.Today)), 2); var strFileName = Path.GetTempPath() + "\\Dip" + $"{DateTime.Now:yyyy-MM-dd_hh-mm-ss-tt}.txt"; var dipInputs = _dipInputService.GetDipInputsForReport(strDate); if (dipInputs.Count > 0) { short sWidth = 20; short aWidth = 20; short hWidth = 40; var just = Strings.Left(Convert.ToString(_policyManager.REC_JUSTIFY), 1).ToUpper(); var nH = FileSystem.FreeFile(); FileSystem.FileOpen(nH, strFileName, OpenMode.Output, OpenAccess.Write); // - store code printing should be based on policy - Gasking will enter store code as part of store name - so they don't want to see store code in the beginning // If Policy.PRN_CO_NAME Then Print #nH, PadIt(Just, Store.Code & " " & Store.Name, H_Width) if (_policyManager.PRN_CO_NAME) { FileSystem.PrintLine(nH, modStringPad.PadIt(just, (_policyManager.PRN_CO_CODE ? store.Code + " " : "") + store.Name, hWidth)); } if (_policyManager.PRN_CO_ADDR) { FileSystem.PrintLine(nH, modStringPad.PadIt(just, Convert.ToString(store.Address.Street1), hWidth)); if (store.Address.Street2 != "") { FileSystem.PrintLine(nH, modStringPad.PadIt(just, Convert.ToString(store.Address.Street2), hWidth)); } FileSystem.PrintLine(nH, modStringPad.PadIt(just, Strings.Trim(Convert.ToString(store.Address.City)) + ", " + store.Address.ProvState, hWidth) + "\r\n" + modStringPad.PadIt(just, Convert.ToString(store.Address.PostalCode), hWidth)); } if (_policyManager.PRN_CO_PHONE) { foreach (Phone tempLoopVarPhoneRenamed in store.Address.Phones) { var phoneRenamed = tempLoopVarPhoneRenamed; if (phoneRenamed.Number.Trim() != "") { FileSystem.PrintLine(nH, modStringPad.PadC(phoneRenamed.PhoneName + " " + phoneRenamed.Number, hWidth)); } } } FileSystem.PrintLine(nH, modStringPad.PadIt(just, Strings.Trim(Convert.ToString(store.RegName)) + " " + store.RegNum, hWidth)); //& vbCrLf if (store.SecRegName != "") { FileSystem.PrintLine(nH, modStringPad.PadIt(just, Strings.Trim(Convert.ToString(store.SecRegName)) + " " + store.SecRegNum, hWidth)); } FileSystem.PrintLine(nH); FileSystem.PrintLine(nH, _policyManager.PRN_UName ? modStringPad.PadIt(just, _resourceManager.GetResString(offSet, 225) + ": " + user.Name + " (" + Strings.Left(_resourceManager.GetResString(offSet, 132), 1) + Convert.ToString(registerNumber) + "/" + Strings.Left(_resourceManager.GetResString(offSet, 131), 1) + Convert.ToString(tillNumber) + "/" + Strings.Left(_resourceManager.GetResString(offSet, 346), 1) + Convert.ToString(shiftNumber) + ")", hWidth) : modStringPad.PadIt(just, _resourceManager.GetResString(offSet, 225) + ": " + user.Code + " (" + Strings.Left(_resourceManager.GetResString(offSet, 132), 1) + Convert.ToString(registerNumber) + "/" + Strings.Left(_resourceManager.GetResString(offSet, 131), 1) + Convert.ToString(tillNumber) + "/" + Strings.Left(_resourceManager.GetResString(offSet, 346), 1) + Convert.ToString(shiftNumber) + ")", hWidth)); // FileSystem.PrintLine(nH, modStringPad.PadIt(just, DateAndTime.Today.ToString("dd-MMM-yyyy") + _resourceManager.GetResString(offSet, 208) + DateAndTime.TimeOfDay.ToString(timeFormatHm), hWidth) + "\r\n"); //" at " ' FileSystem.PrintLine(nH, modStringPad.PadIt(just, _resourceManager.GetResString(offSet, 3403) + " " + DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss"), hWidth)); //"DIP READING @ " FileSystem.PrintLine(nH, modStringPad.PadL("=", hWidth, "=") + "\r\n"); FileSystem.PrintLine(nH, modStringPad.PadC(_resourceManager.GetResString(offSet, 3401), sWidth) + modStringPad.PadC(_resourceManager.GetResString(offSet, 3402), aWidth)); //"Tank ID","DIP Value" FileSystem.PrintLine(nH, modStringPad.PadL("-", hWidth, "-")); //& vbCrLf foreach (DipInput dipInput in dipInputs) { FileSystem.PrintLine(nH, modStringPad.PadC(dipInput.TankId, sWidth) + modStringPad.PadC(dipInput.DipValue, aWidth)); } // Advance the specified number of lines. short i; for (i = 1; i <= _policyManager.ADV_LINES; i++) { FileSystem.PrintLine(nH); } FileSystem.FileClose(nH); var stream = File.OpenRead(strFileName); report.ReportContent = Helper.CreateBytes(stream); report.Copies = 1; //modPrint.Dump_To_Printer((new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.DirectoryPath + "\\" + File_Name, 1, true, true, false); } else { //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.Critical + MsgBoxStyle.OkOnly; //Chaps_Main.DisplayMessage(this, 60, temp_VbStyle, null, 0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 34, 60, null, CriticalOkMessageType), StatusCode = HttpStatusCode.NotFound }; } return(report); }
/// <summary> /// Get Dip Input values /// </summary> /// <returns>List of dip input</returns> public List <DipInput> GetDipInputValues() { List <DipInput> dipInputs = new List <DipInput>(); var strDate = DateAndTime.Year(DateAndTime.Today) + Strings.Right("00" + CommonUtility.GetStringValue(DateAndTime.Month(DateAndTime.Today)), 2) + Strings.Right("00" + CommonUtility.GetStringValue(DateAndTime.Day(DateAndTime.Today)), 2); var strSql = "select A.ID, A.GradeID, B.FullName from TankInfo as A INNER JOIN Grade as B ON A.GradeID=B.ID where B.FuelType=\'G\'"; var dt = GetRecords(strSql, DataSource.CSCPump); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { DipInput input = new DipInput { TankId = CommonUtility.GetStringValue(dr["ID"]), Grade = CommonUtility.GetStringValue(dr["FullName"]), GradeId = CommonUtility.GetStringValue(dr["GradeID"]) }; string query = "select * from DipInput where TankID=" + CommonUtility.GetStringValue(dr["ID"]) + " and CONVERT(char(8), DipDate, 112)=\'" + strDate + "\'"; var rsDip = GetRecords(query, DataSource.CSCTrans); if (rsDip == null || rsDip.Rows.Count == 0) { input.DipValue = ""; } else { input.DipValue = CommonUtility.GetStringValue(rsDip.Rows[0]["DipValue"]); } dipInputs.Add(input); } } return(dipInputs); }
/// <summary> /// Get Installed Date /// </summary> /// <param name="security">Security</param> public void GetInstallDate(ref Security security) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,LoginManager,GetInstallDate,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); var dl = ""; var strRenamed = security.Install_Date_Encrypt; if (strRenamed.Length >= 60) { short i; for (i = 21; i <= 40; i += 2) { dl = dl + Convert.ToString(Strings.Chr((int)(Conversion.Val(strRenamed.Substring(i - 1, 2)) - 7))); } strRenamed = DateAndTime.Month(DateTime.Parse(dl)).ToString("00") + "/" + DateAndTime.Day(DateTime.Parse(dl)).ToString("00") + "/" + DateAndTime.Year(DateTime.Parse(dl)).ToString("0000"); security.Install_Date = DateTime.Parse(strRenamed); // Me.Install_Date = Format(DL, "mm/dd/yyyy") } else { security.Install_Date = Convert.ToDateTime(DateTime.FromOADate(0)); } Performancelog.Debug($"End,LoginManager,GetInstallDate,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); }
private void CustomerStatement(ref int id) { ADODB.Recordset rsInterest = default(ADODB.Recordset); ADODB.Recordset rsCustTransCheck = default(ADODB.Recordset); ADODB.Recordset rsTransaction = default(ADODB.Recordset); ADODB.Recordset rsCompany = default(ADODB.Recordset); string lNumber = null; string lAddress = null; ADODB.Recordset rs = new ADODB.Recordset(); string sql = null; //Dim Report As New cryCustomerStatement_AGING 'cryCustomerStatement CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); Report.Load("cryCustomerStatement_AGING.rpt"); System.DateTime lDate = default(System.DateTime); rs = modRecordSet.getRS(ref "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth - (this.cmbMonthEnd.SelectedIndex - 1) + "));"); Report.SetParameterValue("txtStatementDate", Strings.Format(rs.Fields("MonthEnd_Date").Value, "dd mmm yyyy")); lDate = rs.Fields("MonthEnd_Date").Value; rs.Close(); rs = modRecordSet.getRS(ref "SELECT * FROM Company"); lDate = System.Date.FromOADate(lDate.ToOADate() + 10); lDate = System.Date.FromOADate(lDate.ToOADate() - DateAndTime.Day(lDate)) + rs.Fields("Company_PaymentDay").Value; if (chkFields.CheckState) { Report.SetParameterValue("txtPaymentDate", " "); Report.SetParameterValue("Text7", " "); } else { Report.SetParameterValue("txtPaymentDate", Strings.Format(lDate, "dd mmm yyyy")); } lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", "); if (Strings.Right(lAddress, 2) == ", ") { lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2); } Report.Database.Tables(1).SetDataSource(rs); Report.SetParameterValue("txtAddress", lAddress); lNumber = ""; if (!string.IsNullOrEmpty(rs.Fields("Company_Telephone").Value)) { lNumber = lNumber + "Tel: " + rs.Fields("Company_Telephone").Value; } if (!string.IsNullOrEmpty(rs.Fields("Company_Fax").Value)) { if (!string.IsNullOrEmpty(lNumber)) { lNumber = lNumber + " / "; } lNumber = lNumber + "Fax: " + rs.Fields("Company_Fax").Value; } if (!string.IsNullOrEmpty(rs.Fields("Company_Email").Value)) { if (!string.IsNullOrEmpty(lNumber)) { lNumber = lNumber + " / "; } lNumber = lNumber + "Email: " + rs.Fields("Company_Email").Value; } Report.SetParameterValue("txtNumbers", lNumber); //New banking details if (Information.IsDBNull(rs.Fields("Company_BankName").Value)) { } else { Report.SetParameterValue("txtBankName", rs.Fields("Company_BankName")); } if (Information.IsDBNull(rs.Fields("Company_BranchName").Value)) { } else { Report.SetParameterValue("txtBranchName", rs.Fields("Company_BranchName")); } if (Information.IsDBNull(rs.Fields("Company_BranchCode").Value)) { } else { Report.SetParameterValue("txtBranchCode", rs.Fields("Company_BranchCode")); } if (Information.IsDBNull(rs.Fields("Company_AccountNumber").Value)) { } else { Report.SetParameterValue("txtAccountNumber", rs.Fields("Company_AccountNumber")); } //................... rsCompany = new ADODB.Recordset(); rsCompany.Open("SELECT * FROM Customer Where CustomerID = " + id, cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); Report.SetParameterValue("txtDaysCurr", "R " + Strings.FormatNumber(rsCompany("Customer_Current"), 2)); Report.SetParameterValue("txtDays30", "R " + Strings.FormatNumber(rsCompany("Customer_30Days"), 2)); Report.SetParameterValue("txtDays60", "R " + Strings.FormatNumber(rsCompany("Customer_60Days"), 2)); Report.SetParameterValue("txtDays90", "R " + Strings.FormatNumber(rsCompany("Customer_90Days"), 2)); Report.SetParameterValue("txtDays120", "R " + Strings.FormatNumber(rsCompany("Customer_120Days"), 2)); Report.SetParameterValue("txtDays150", "R " + Strings.FormatNumber(rsCompany("Customer_150Days"), 2)); rsCompany.Close(); rsCompany.Open("SELECT * FROM Customer Where CustomerID = " + id, modRecordSet.cnnDB, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); Report.Database.Tables(2).SetDataSource(rsCompany); rsTransaction = new ADODB.Recordset(); //rsTransaction.Open "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," & _ //'" TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" & id & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText //changed for OPEN ITEM //rsTransaction.Open "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," & _ //'" TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" & id & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText rsCustTransCheck = new ADODB.Recordset(); rsCustTransCheck.Open("SELECT * FROM CustomerTransaction Where CustomerTransaction_CustomerID = " + id, cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rsCustTransCheck.Fields.Count <= 12) { rsTransaction.Open("SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," + " TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit, 0, 0, 0 FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + id + "));", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); } else { rsTransaction.Open("SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated]), CustomerTransaction.CustomerTransaction_Reference & IIf([CustomerTransaction.CustomerTransaction_Allocated]<>[CustomerTransaction_Amount] AND [CustomerTransaction.CustomerTransaction_Allocated]<>0,' (P)',Null), CustomerTransaction.CustomerTransaction_PersonName, TransactionType.TransactionType_Name," + " IIf(([CustomerTransaction_Amount]-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated]))>0,([CustomerTransaction_Amount]-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated])),Null) AS debit," + " IIf(([CustomerTransaction_Amount]-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated]))<0,([CustomerTransaction_Amount]-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated])),Null) AS credit, CustomerTransaction.CustomerTransaction_Main, CustomerTransaction.CustomerTransaction_Child, CustomerTransaction.CustomerTransaction_Allocated FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + id + ") AND ((CustomerTransaction.CustomerTransaction_Amount-IIf(IsNull([CustomerTransaction.CustomerTransaction_Allocated]),0,[CustomerTransaction.CustomerTransaction_Allocated]))<>0));", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); } //Report.Database.Tables(3).SetDataSource rsTransaction, 3 if (rsTransaction.BOF | rsTransaction.EOF) { rsTransaction = new ADODB.Recordset(); rsTransaction.Open("SELECT 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0," + " 0, 0 AS debit, 0 AS credit;", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); Report.Database.Tables(3).SetDataSource(rsTransaction); //Exit Sub } else { Report.Database.Tables(3).SetDataSource(rsTransaction); } if (rsTransaction.BOF | rsTransaction.EOF) { return; } //Set rsInterest = New Recordset //rsInterest.Open ("SELECT * FROM Interest WHERE (((CustomerID)=" & id & ")) and (Debit>0);"), cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText rsInterest = modRecordSet.getRS(ref "SELECT * FROM Interest WHERE (((CustomerID)=" + id + ")) and (Debit>0);"); //If rsInterest.BOF Or rsInterest.EOF Then if (rsInterest.RecordCount > 0) { Report.ReportDefinition.ReportObjects("Field20").Top = 280; Report.ReportDefinition.ReportObjects("Field21").Top = 280; Report.ReportDefinition.ReportObjects("Field22").Top = 280; Report.ReportDefinition.ReportObjects("Field23").Top = 280; Report.Database.Tables(4).SetDataSource(rsInterest); } else { //Set rsInterest = New Recordset //rsInterest.Open "SELECT 0 AS CustomerID, 0 AS CDate, 0 AS Description, 0 AS Debit, 0 AS Credit, 0 AS SumIntBal ;", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText rsInterest = modRecordSet.getRS(ref "SELECT 0 AS CustomerID, 0 AS CDate, 0 AS Description, 0 AS Debit, 0 AS Credit, 0 AS SumIntBal ;"); Report.ReportDefinition.Sections("Field20").SectionFormat.EnableSuppress = true; Report.ReportDefinition.Sections("Field21").SectionFormat.EnableSuppress = true; Report.ReportDefinition.Sections("Field22").SectionFormat.EnableSuppress = true; Report.ReportDefinition.Sections("Field23").SectionFormat.EnableSuppress = true; Report.Database.Tables(4).SetDataSource(rsInterest); //Exit Sub //Set rsInterest = New Recordset //rsInterest.Open "SELECT * FROM Interest WHERE (((CustomerID)=" & id & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText } if (rs.Fields("Company_DebtorPrintBal").Value == true) { CrystalDecisions.CrystalReports.Engine.TextObject tObj = Report.ReportDefinition.ReportObjects("Text5"); tObj.Color = Color.White; } My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report; My.MyProject.Forms.frmReportShow.mReport = Report; My.MyProject.Forms.frmReportShow.sMode = "0"; // frmReportShow.CRViewer1.PrintReport My.MyProject.Forms.frmReportShow.CRViewer1.Refresh(); // Unload frmReportShow System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; My.MyProject.Forms.frmReportShow.ShowDialog(); }
public void SetDate(string str) { if (str == null) { return; } if (str.Equals("today", StringComparison.CurrentCultureIgnoreCase)) { str = DateTime.Now.ToShortDateString(); } var bits = str.Split(' ', '-', '/', '.', '\\', '_', ',', '%', '#', '!', '~', ';', ':'); var strDate = String.Join(" ", bits); int count = 0; foreach (string s in bits) { if (!String.IsNullOrEmpty(s)) { count++; } } DateTime dt; string bldate = null; if (Information.IsDate(strDate)) { dt = Microsoft.VisualBasic.DateAndTime.DateValue(strDate); if (DateAndTime.Day(dt) == 1) { switch (count) { case 1: bldate = string.Format("{0:4}0000", dt.Year); break; case 2: bldate = string.Format("{0:0000}{1:00}00", dt.Year, dt.Month); break; case 3: bldate = DateUtils.DateToBLDate(dt); break; default: break; } } else { bldate = DateUtils.DateToBLDate(dt); } } else { int year; if (Int32.TryParse(str, out year)) { if (year > 0 && year <= 9999) { var tempDate = "01 jan " + str; if (DateTime.TryParse(tempDate, out dt)) { bldate = string.Format("{0:0000}0000", dt.Year); } } } } _selfSet = true; if (bldate != null) { this.Date = bldate; } else { this.Date = "0"; } _selfSet = false; }
public void ExportToCSV(bool PrintHeader = true) { string ExportFilePath = null; ADODB.Recordset rs = default(ADODB.Recordset); int i = 0; int TotalRecords = 0; bool ErrorOccured = false; short NumberOfFields = 0; const string quote = "\""; //Faster then Chr$(34) string sql = null; Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); cmdStart.Enabled = false; cmdExit.Enabled = false; txtPassword.Enabled = false; string ptbl = null; string t_day = null; string t_Mon = null; if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today)))) == 1) { t_day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))); } else { t_day = Convert.ToString(DateAndTime.Day(DateAndTime.Today)); } if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today)))) == 1) { t_Mon = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))); } else { t_Mon = Conversion.Str(DateAndTime.Month(DateAndTime.Today)); } ExportFilePath = modRecordSet.serverPath + "4POSDebtor" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Mon) + Strings.Trim(t_day); if (fso.FileExists(ExportFilePath + ".csv")) { fso.DeleteFile((ExportFilePath + ".csv")); } rs = modRecordSet.getRS(ref "SELECT CustomerID, Customer_InvoiceName, Customer_DepartmentName, Customer_FirstName, Customer_Surname, Customer_PhysicalAddress, Customer_PostalAddress, Customer_Telephone, Customer_Current as CurrentBalance,Customer_30Days as 30Days, Customer_60Days as 60days, Customer_90Days as 90Days, Customer_120Days as 120Days,Customer_150Days as 150Days FROM Customer"); prgBar.Maximum = rs.RecordCount; if (rs.RecordCount > 0) { FileSystem.FileOpen(1, ExportFilePath + ".csv", OpenMode.Output); var _with2 = modRecordSet.getRS(ref ref "SELECT CustomerID, Customer_InvoiceName, Customer_DepartmentName, Customer_FirstName, Customer_Surname, Customer_PhysicalAddress, Customer_PostalAddress, Customer_Telephone, Customer_Current as CurrentBalance,Customer_30Days as 30Days, Customer_60Days as 60days, Customer_90Days as 90Days, Customer_120Days as 120Days,Customer_150Days as 150Days FROM Customer"); rs.MoveFirst(); NumberOfFields = rs.Fields.Count - 1; if (PrintHeader) { //Now add the field names for (i = 0; i <= NumberOfFields - 1; i++) { FileSystem.Print(1, rs.Fields(i).name + ","); //similar to the ones below } FileSystem.PrintLine(1, rs.Fields(NumberOfFields).name); } while (!rs.EOF) { prgBar.Value = prgBar.Value + 1; // ERROR: Not supported in C#: OnErrorStatement TotalRecords = TotalRecords + 1; //If there is an emty field, for (i = 0; i <= NumberOfFields; i++) { //add a , to indicate it is if ((Information.IsDBNull(rs.Fields(i).Value))) { FileSystem.Print(1, ","); //empty } else { if (i == NumberOfFields) { FileSystem.Print(1, quote + Strings.Trim(Convert.ToString(rs.Fields(i).Value)) + quote); } else { FileSystem.Print(1, quote + Strings.Trim(Convert.ToString(rs.Fields(i).Value)) + quote + ","); } } //Putting data under "" will not } //confuse the reader of the file DoEventsEx(); //between Dhaka, Bangladesh as two FileSystem.PrintLine(1); //fields or as one field. rs.moveNext(); } FileSystem.FileClose(1); Interaction.MsgBox("Customer details were successfully exported to : " + FilePath + "" + "4POSProd" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Mon) + Strings.Trim(t_day) + ".csv", MsgBoxStyle.OkOnly, "Customers"); // DoEvents // DoEvents // MsgBox "Now Zeroising...", vbOKOnly, "Customers" // cmdStart.Enabled = False // cmdExit.Enabled = False // Set rsZ = getRS("SELECT CustomerID FROM Customer") // Do While Not rsZ.EOF // DoEvents // cmdProcess_Click (rsZ("CustomerID")) // DoEvents // rsZ.moveNext // Loop //MsgBox "Completed", vbOKOnly, "Customers" //cmdStart.Enabled = True //cmdExit.Enabled = True this.Close(); } System.Windows.Forms.Cursor.Current = Cursors.Default; rs.Close(); //cnnDB.Close //Set cnnDB = Nothing //closeConnection }
/// <summary> /// Check Security /// </summary> /// <param name="security">Security</param> /// <param name="store">Store</param> /// <returns>True or false</returns> private bool CheckSecurity(ref Security security, Store store) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,LoginManager,CheckSecurity,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); SetPolicyFeatures(security); var offSet = _policyManager.LoadStoreInfo().OffSet; if (security.Security_Key.Length == 0 && security.Install_Date != DateTime.FromOADate(0)) // first time { // We dont give them permission to work without security key if (DateAndTime.DateDiff(DateInterval.Day, security.Install_Date, DateTime.Now) < 0 && security.Install_Date <= DateAndTime.Today) // installation time { security.Message = $"System Is Going To Shut Down in {5 - DateAndTime.DateDiff("d", security.Install_Date, DateTime.Now)} days"; security.ExpireDate = DateTime.FromOADate(security.Install_Date.ToOADate() + 5); return(true); } //"License Expired. Please get a Valid Security Code from your Dealer." security.Message = _resourceManager.CreateCaption(offSet, 5, 83, null, 0); return(false); // installation time is over } if (security.Install_Date == DateTime.FromOADate(0) || security.Install_Date > DateAndTime.Today) { //"You don't have permission to login to POS. Please contact your Dealer."; security.Message = _resourceManager.CreateCaption(offSet, 6, 83, null, 0); return(false); } if (security.Security_Key.Length > 0) { //"You don't have permission to login to POS. Please contact your Dealer."; security.Message = _resourceManager.CreateCaption(offSet, 6, 83, null, 0); var secStr = Convert.ToString(store.Name); secStr = secStr + store.Address.Street1; secStr = secStr + store.Address.City; secStr = secStr + store.Address.PostalCode; secStr = secStr + store.RegNum; secStr = secStr + DateAndTime.Month(security.Install_Date).ToString("00") + "/" + DateAndTime.Day(security.Install_Date).ToString("00") + "/" + DateAndTime.Year(security.Install_Date).ToString("0000"); secStr = secStr + security.POS_BO_Features; secStr = secStr + security.Pump_Features; var secStrNoNic = secStr; secStr = secStr + security.NIC_Number; var strTmp = security.Number_OF_POS.ToString(); strTmp = strTmp + Convert.ToString(security.MaxConcurrentPOS); strTmp = strTmp + _utilityService.GetIpAddresses(); secStr = secStr + strTmp; secStrNoNic = secStrNoNic + strTmp; short i; for (i = 1; i <= security.Limit.Length - 1; i++) { if (Helper.GetKey(secStr + security.Limit[i].Trim()) == security.Security_Key) { switch (security.Limit[i].Trim()) { case "30": case "45": case "60": case "75": case "90": case "120": case "180": if (DateAndTime.DateDiff(DateInterval.Day, security.Install_Date, DateTime.Now) <= Conversion.Val(security.Limit[i])) { // $"System Is Going To Shut Down in {Convert.ToInt64(security.Limit[i]) - DateAndTime.DateDiff("d", security.Install_Date, DateTime.Now)} days"; security.Message = _resourceManager.CreateCaption(offSet, 4, 83, Conversion.Val(security.Limit[i]) - DateAndTime.DateDiff(DateInterval.Day, security.Install_Date, DateTime.Now), 0); security.ExpireDate = DateTime.FromOADate(security.Install_Date.ToOADate() + Conversion.Val(security.Limit[i])); return(true); } //"License Expired. Please Contact your Dealer."; security.Message = _resourceManager.CreateCaption(offSet, 7, 83, null, 0); return(false); case "PAID": security.Message = string.Empty; security.ExpireDate = DateTime.FromOADate(security.Install_Date.ToOADate() + 50 * 365); // 50 Year return(true); } } } if (Helper.GetKey(secStrNoNic + "3") == security.Security_Key) { if (DateAndTime.DateDiff(DateInterval.Day, security.Install_Date, DateTime.Now) <= 3) { var strInsDate = LoadTempInstallDate(); if (string.IsNullOrEmpty(strInsDate)) { SaveTempInstallDate(security.Install_Date); } else if (strInsDate != security.Install_Date.ToString("MM/dd/yyyy")) { //"You don't have permission to login to POS. Please contact your Dealer."; security.Message = _resourceManager.CreateCaption(offSet, 6, 83, null, 0); return(false); } //$"System Is Going To Shut Down in {3 - DateAndTime.DateDiff("d", security.Install_Date, DateTime.Now)} days"; security.Message = _resourceManager.CreateCaption(offSet, 4, 83, 3 - DateAndTime.DateDiff(DateInterval.Day, security.Install_Date, DateTime.Now), 0); security.ExpireDate = DateTime.FromOADate(security.Install_Date.ToOADate() + 3); return(true); } //"License Expired. Please Contact your Dealer."; security.Message = _resourceManager.CreateCaption(offSet, 7, 83, null, 0); return(false); } } Performancelog.Debug($"End,LoginManager,CheckSecurity,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(false); }
private void frmStockTakeCSV_Load(System.Object eventSender, System.EventArgs eventArgs) { // ERROR: Not supported in C#: OnErrorStatement if (modRecordSet.cnnDB == null) { if (openConnection() == true) { } } //creating table name Te_Name = "HandHeld" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today))) + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today))) + Strings.Trim(Convert.ToString(DateAndTime.Hour(DateAndTime.Now))) + Strings.Trim(Convert.ToString(DateAndTime.Minute(DateAndTime.Now))) + Strings.Trim(Convert.ToString(DateAndTime.Second(DateAndTime.Now))) + "_" + My.MyProject.Forms.frmMenu.lblUser.Tag; loadLanguage(); lMWNo = My.MyProject.Forms.frmMWSelect.getMWNo(); if (lMWNo > 1) { //Set rsWH = getRS("SELECT * FROM Warehouse WHERE WarehouseID=" & lMWNo & ";") //Report.txtWH.SetText rsWH("Warehouse_Name") } }