I made a language switch (English, Polski) and I wanted to if tabpage contains word "New " then change it to "Nowy " and vice-versa, but I have one problem. This tabPage is made programmatically and I don't know, how to change it's header's text. I made this:
private void englishToolStripMenuItem_Click(object sender, EventArgs e)
{
Class1.LangNumber = 2;
Class1.ChangeLanguage(2);
polskiToolStripMenuItem.Checked = false;
englishToolStripMenuItem.Checked = true;
fileToolStripMenuItem.Text = Class1.file;
openToolStripMenuItem.Text = Class1.open;
saveToolStripMenuItem.Text = Class1.save;
saveAsToolStripMenuItem.Text = Class1.saveas;
edjtToolStripMenuItem.Text = Class1.edit;
cutToolStripMenuItem.Text = Class1.cut;
copyToolStripMenuItem.Text = Class1.copy;
pasteToolStripMenuItem.Text = Class1.paste;
selectAllToolStripMenuItem.Text = Class1.selectall;
deselectAllToolStripMenuItem.Text = Class1.deselectall;
dateAndTimeToolStripMenuItem.Text = Class1.dateandtime;
nicknameToolStripMenuItem.Text = Class1.nickname;
autoWordSelectionToolStripMenuItem.Text = Class1.awsel;
tabManagementToolStripMenuItem.Text = Class1.tabmgmt;
newTabToolStripMenuItem.Text = Class1.ntab;
deleteSelectedTabToolStripMenuItem.Text = Class1.dtab;
infoToolStripMenuItem.Text = Class1.iands;
electryNotepadInfoToolStripMenuItem.Text = Class1.info;
setNicknameToolStripMenuItem.Text = Class1.setnickname;
languagesToolStripMenuItem.Text = Class1.lang;
nicknamerror = Class1.nicknameloaderror;
savedialog = Class1.saved;
savedialogcap = Class1.savecap;
nicknameerrorcap = Class1.nlecap;
ncreate = Class1.ncreation;
ncreatecap = Class1.ncreationcap;
setnicknamedialog = Class1.setnicknamedialog;
newtab = Class1.nev;
for (int i = 0; i <= tabControl1.TabCount - 1; i++)
{
TabPage t = tabControl1.TabPages[i];
if (t.Text.Contains("Nowy"))
{
t.Text.Replace("Nowy", "New");
}
Application.DoEvents();
}
}
private void polskiToolStripMenuItem_Click(object sender, EventArgs
e)
{
Class1.LangNumber = 1;
Class1.ChangeLanguage(1);
polskiToolStripMenuItem.Checked = true;
englishToolStripMenuItem.Checked = false;
fileToolStripMenuItem.Text = Class1.file;
openToolStripMenuItem.Text = Class1.open;
saveToolStripMenuItem.Text = Class1.save;
saveAsToolStripMenuItem.Text = Class1.saveas;
edjtToolStripMenuItem.Text = Class1.edit;
cutToolStripMenuItem.Text = Class1.cut;
copyToolStripMenuItem.Text = Class1.copy;
pasteToolStripMenuItem.Text = Class1.paste;
selectAllToolStripMenuItem.Text = Class1.selectall;
deselectAllToolStripMenuItem.Text = Class1.deselectall;
dateAndTimeToolStripMenuItem.Text = Class1.dateandtime;
nicknameToolStripMenuItem.Text = Class1.nickname;
autoWordSelectionToolStripMenuItem.Text = Class1.awsel;
tabManagementToolStripMenuItem.Text = Class1.tabmgmt;
newTabToolStripMenuItem.Text = Class1.ntab;
deleteSelectedTabToolStripMenuItem.Text = Class1.dtab;
infoToolStripMenuItem.Text = Class1.iands;
electryNotepadInfoToolStripMenuItem.Text = Class1.info;
setNicknameToolStripMenuItem.Text = Class1.setnickname;
languagesToolStripMenuItem.Text = Class1.lang;
nicknamerror = Class1.nicknameloaderror;
savedialog = Class1.saved;
savedialogcap = Class1.savecap;
nicknameerrorcap = Class1.nlecap;
ncreate = Class1.ncreation;
ncreatecap = Class1.ncreationcap;
setnicknamedialog = Class1.setnicknamedialog;
newtab = Class1.nev;
for(int i = 0; i <= tabControl1.TabCount - 1; i++)
{
TabPage t = tabControl1.TabPages[i];
if(t.Text.Contains("New"))
{
t.Text.Replace("New", "Nowy");
}
Application.DoEvents();
}
}
The Class1 file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectryNotepad
{
public static class Class1
{
public static string file = "Plik";
public static string open = "Otwórz";
public static string save = "Zapisz";
public static string saveas = "Zapisz jako";
public static string edit = "Edycja";
public static string cut = "Wytnij";
public static string copy = "Kopiuj";
public static string paste = "Wklej";
public static string selectall = "Zaznacz wszystko";
public static string deselectall = "Odznacz wszystko";
public static string dateandtime = "Data i Godzina";
public static string nickname = "Nazwa";
public static string awsel = "Automatyczne zaznaczanie słów";
public static string tabmgmt = "Zarządzanie zakładkami";
public static string ntab = "Nowa zakładka";
public static string dtab = "Usuń zaznaczoną zakładkę";
public static string iands = "Informacje i ustawienia";
public static string info = "ElectryNotepad - Informacje";
public static string setnickname = "Ustaw nazwę";
public static string nicknameloaderror = "Nie ustawiłeś swojej nazwy.
Proszę kliknąć opcję \"Ustaw nazwę\" w \"Informacje i Ustawienia\".";
public static string nlecap = "Błąd nazwy";
public static string setnicknamedialog = "Proszę wpisz swoją nazwę w
pole tekstowe poniżej (max 32 znaki) \n \n UWAGA! POPRZEDNIA NAZWA
ZOSTANIE USUNIĘTA!";
public static string ncreation = "\n \n Czy na chcesz ustawić tą
nazwę?";
public static string ncreationcap = "Asystent ustawiania nazwy";
public static string nev = "Nowy ";
public static string saved = "Czy chcesz zapisać swoją pracę?";
public static string savecap = "Zapisywanie";
public static string lang = "Język";
public static bool Polish = true;
public static int LangNumber = 1;
public static void ChangeLanguage(int l)
{
switch(l)
{
case 1:
Polish = true;
lang = "Język";
file = "Plik";
open = "Otwórz";
save = "Zapisz";
saveas = "Zapisz jako";
edit = "Edycja";
cut = "Wytnij";
copy = "Kopiuj";
paste = "Wklej";
selectall = "Zaznacz wszystko";
deselectall = "Odznacz wszystko";
dateandtime = "Data i Godzina";
awsel = "Automatyczne zaznaczanie słów";
tabmgmt = "Zarządzanie zakładkami";
nickname = "Nazwa";
ntab = "Nowa zakładka";
dtab = "Usuń zaznaczoną zakładkę";
iands = "Informacje i ustawienia";
info = "ElectryNotepad - Informacje";
setnickname = "Ustaw nazwę";
nicknameloaderror = "Nie ustawiłeś swojej nazwy. Proszę
kliknąć opcję \"Ustaw nazwę\" w \"Informacje i
Ustawienia\".";
nlecap = "Błąd nazwy";
setnicknamedialog = "Proszę wpisz swoją nazwę w pole
tekstowe poniżej (max 32 znaki) \n \n UWAGA! POPRZEDNIA
NAZWA ZOSTANIE USUNIĘTA!";
ncreation = "\n \n Czy na chcesz ustawić tą nazwę?";
ncreationcap = "Asystent ustawiania nazwy";
nev = "Nowy ";
saved = "Czy chcesz zapisać swoją pracę?";
savecap = "Zapisywanie";
break;
case 2:
Polish = false;
lang = "Language";
file = "File";
open = "Open";
save = "Save";
saveas = "Save as";
edit = "Edit";
cut = "Cut";
copy = "Copy";
paste = "Paste";
dateandtime = "Date and time";
selectall = "Select All";
deselectall = "Deselect All";
awsel = "Auto Word Selection";
tabmgmt = "Tab Management";
nickname = "Nickname";
ntab = "New Tab";
dtab = "Delete Selected Tab";
iands = "Info and Settings";
info = "ElectryNotepad - Info";
setnickname = "Set Nickname";
nicknameloaderror = "You didn't set nickname. Please, press
\"Set Nickname\" in \"Info and Settings\".";
nlecap = "Nickname error";
setnicknamedialog = "Please type your nickname in text field
below (max 32 characters) \n \n CAUTION! PREVIOUS NICKNAME
WILL BE DELETED!";
ncreation = "\n \n Are you sure you want to set this
nickname?";
ncreationcap = "Nickname creation assistant";
nev = "New ";
saved = "Do you want to save this?";
savecap = "Saving";
break;
}
}
}
}
But it doesn't work. When I click button for Polski, or for English it doesn't change anything. Help me, please.
Your all concept is wrong. You should use translation mechanism for such work.
Externalizing the translation of a WinForms application?
OK, ok. I realized I cam make another way to translate my program. I can make reading from file in search for text and applying it to these strings. Thread closed
Related
I am setting a CustomRoomProperties when a new game is started. Here:
public void startGame()
{
RoomOptions options = new RoomOptions();
options.CleanupCacheOnLeave = true;
options.MaxPlayers = 8;
options.IsOpen = true;
options.IsVisible = true;
Hashtable RoomCustomProps = new Hashtable();
RoomCustomProps.Add("availablePods", gameLenghtsIs);
options.CustomRoomProperties = RoomCustomProps;
PhotonNetwork.JoinOrCreateRoom(createInput.text, options, TypedLobby.Default);
}
And this is the RoomInfo displayed in the Lobby once a game is created:
public void SetRoomInfo(RoomInfo roomInfo)
{
RoomInfo = roomInfo;
maxPlayetTxt.text = roomInfo.MaxPlayers + ",";
nameRoomText.text = roomInfo.Name + ",";
payerNumberText.text = roomInfo.PlayerCount+ "/8";
}
To this RoomInfo i would want to add the created Custom Property but not really sure how. I tried:
podsTxt.text = roomInfo.CustomProperties["availablePods"] + ",";
This resulted in nothingness.
And i tried this:
podsTxt.text = roomInfo.CustomProperties["availablePods"].GetHashCode() + ",";
Resulted in a error.
Tried a few other things but can't get it to work.
P.S. I am using the Hashtable and the hastable does what it's sopposto to do. I would just want this value that i set at startGame()
"availablePods"
to bi displayed when getting the room list in the lobby.
Anyone can help?
If this help anybody, this is what wroked for me:
public void startGame()
{
RoomOptions options = new RoomOptions();
options.CleanupCacheOnLeave = true;
options.MaxPlayers = 8;
options.IsOpen = true;
options.IsVisible = true;
Hashtable RoomCustomProps = new Hashtable();
RoomCustomProps.Add("availablePods", gameLenghtsIs);
options.CustomRoomProperties = RoomCustomProps;
options.CustomRoomProperties.Add("availablePods", allPods);
options.CustomRoomPropertiesForLobby = new string[1] { "availablePods" };
PhotonNetwork.JoinOrCreateRoom(createInput.text, options, TypedLobby.Default);
}
Room Info:
public void SetRoomInfo(RoomInfo roomInfo)
{
RoomInfo = roomInfo;
maxPlayetTxt.text = roomInfo.MaxPlayers + ",";
nameRoomText.text = roomInfo.Name + ",";
payerNumberText.text = roomInfo.PlayerCount+ "/8";
podsTxt.text = roomInfo.CustomProperties["availablePods"].ToString();
}
Thanks to hijinxbassist, i got this working.
Need help to get the 1st row record and return record as string in the << >> after while() loop.
There are a lot of columns in one row, I'm having a problem to declare it as string st? like usually string st = new string() please help to correct it
Thanks
public string Get_aodIdeal(string SubmittedBy)
{
String errMsg = "";
Guid? rguid = null;
int isOnContract = 0;
int isFreeMM = 0;
string _FileName;
DateTime InstallDateTime = DateTime.Now;
string FileDate = ToYYYYMMDD(DateTime.Now);
errMsg = "Unknown Error.";
SqlConnection conn = null; SqlCommand cmd = null;
string st = null;
conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["iDeal"].ConnectionString);
cmd = new SqlCommand();
string SQL = "select TOP 1 * from table1 Order by SubmittedOn desc";
SqlDataAdapter sqd = new SqlDataAdapter(SQL, conn);
cmd.CommandTimeout = 1200;
conn.Open();
SqlDataReader sqr;
//sqd.SelectCommand.Parameters.Add("#Submitted", SqlDbType.Int).Value = PostID;
sqr = sqd.SelectCommand.ExecuteReader();
while (sqr.Read())
st = new string{
rguid = cmd.Parameters["#rguid"].Value as Guid?,
ridno = int.Parse(sqr["ridno"].ToString()),
SubmittedOn= DateTime.Parse(sqr["SubmittedOn"].ToString()),
SubmittingHost = sqr["SubmittingHost"].ToString(),
ServiceAgreementNo = sqr["ServiceAgreementNo"].ToString(),
DocumentID = sqr["DocumentID"].ToString(),
Source = sqr["Source"].ToString(),
FileName = sqr["FileName"].ToString(),
FileType = sqr["FileType"].ToString(),
FileDate = DateTime.Parse(sqr["FileDate"].ToString()),
InstallTime = DateTime.Parse(sqr["InstallTime"].ToString()),
CalenderCode = cmd.Parameters["CalenderCode"].Value as Guid,
isFreeMM = bool.Parse(sqr["isFreeMM"].ToString()),
isOnContract = bool.Parse(sqr["isOnContract"].ToString()),
isProcessed = bool.Parse(sqr["isProcessed"].ToString()),
ProcessedByFullName = sqr["ProcessedByFullName"].ToString(),
isDelete = bool.Parse(sqr["isDelete"].ToString()),
version = int.Parse(sqr["Version"].ToString()),
LastUpdatedBy = DateTime.Parse(sqr["LastUpdatedBy"].ToString()),
LastUpdatedOn = DateTime.Parse(sqr["LastUpdatedOn"].ToString()),
shopGuid = sqr["shopGuid"].ToString(),
MacID = sqr["MacID"].ToString(),
MSISDN = sqr["MSISDN"].ToString()
}
You can use a StringBuilder for this purpose as like the following:
StringBuilder strBuilder= new StringBuilder();
while (sqr.Read())
{
strBuilder.AppendFormat("PostID : {0}{1}",sqr["PostID"].ToString(),Environment.NewLine);
strBuilder.AppendFormat("dateposted : {0}{1}",sqr["dateposted"].ToString(),Environment.NewLine);
// And so on Build your string
}
Finally the strBuilder.ToString() will give you the required string. But More smarter way is Create a Class with necessary properties and an Overrided .ToString method for display the output.
Let AodIdeal be a class with an overrided ToString() method. And Let me defined it like the following :
public class AodIdeal
{
public int PostID { get; set; }
public string dateposted { get; set; }
public string Source { get; set; }
// Rest of properties here
public override string ToString()
{
StringBuilder ObjectStringBuilder = new StringBuilder();
ObjectStringBuilder.AppendFormat("PostID : {0}{1}", PostID, Environment.NewLine);
ObjectStringBuilder.AppendFormat("dateposted : {0}{1}",dateposted, Environment.NewLine);
ObjectStringBuilder.AppendFormat("Source : {0}{1}", Source, Environment.NewLine);
// and so on
return ObjectStringBuilder.ToString();
}
}
Then you can create an object of the class(let it be objAodIdeal), and make use of its properties instead for the local variables. And finally objAodIdeal.ToString() will give you the required output.
Example usage
AodIdeal objAodIdeal= new AodIdeal();
while (sqr.Read())
{
objAodIdeal.PostID = int.Parse(sqr["PostID"].ToString());
objAodIdeal.dateposted= sqr["dateposted"].ToString();
// assign rest of properties
}
string requiredString= objAodIdeal.ToString();
I have a Program which should save permanently values to a .txt file. When I debug it by putting a breakpoint into the code it works fine. But when letting it work for a while it only saves the last value caught instead of the last 3.
The method ExecuteStrategy is being executed every minute.
Here is the code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Bot_V1._0
{
public class SaveAllMinuteBarsStrategy : IStrategy
{
public Guid StrategyGuid { get; set; }
//private static string[] Data = new string[8];
private string DataDax { get; set; }
private string DataDow { get; set; }
private string DataOil { get; set; }
private string DataGold { get; set; }
private string DataSpy { get; set; }
private string DataEsd { get; set; }
private string DataEgp { get; set; }
private string DataUpy { get; set; }
private string xPath = #"G:\TradingBot\Saved Candles folder";
private DateTime firstEnter;
const char LF = '\n';
public SaveAllMinuteBarsStrategy (Guid StrategyCGuid)
{
this.StrategyGuid = StrategyGuid;
}
public List<ShareAndTimeRange> InitStrategy (Guid stratGuid)
{
firstEnter = DateTime.Now;
var Dax = new ShareAndTimeRange("DAX", 1, stratGuid, null, false);
var Dow = new ShareAndTimeRange("DOW", 1, stratGuid, null, false);
var Oil = new ShareAndTimeRange("OIL", 1, stratGuid, null, false);
var Gold = new ShareAndTimeRange("GOLD", 1, stratGuid, null, false);
var Spy = new ShareAndTimeRange("SPY", 1, stratGuid, null, false);
var Esd = new ShareAndTimeRange("EUR/USD", 1, stratGuid, null, false);
var Egb = new ShareAndTimeRange("EUR/GBP", 1, stratGuid, null, false);
var Ujp = new ShareAndTimeRange("USD/JPY", 1, stratGuid, null, false);
var ElementList = new List<ShareAndTimeRange>();
ElementList.Add(Dax);
ElementList.Add(Dow);
ElementList.Add(Oil);
ElementList.Add(Gold);
ElementList.Add(Spy);
ElementList.Add(Esd);
ElementList.Add(Egb);
ElementList.Add(Ujp);
return ElementList;
}
public void ExecuteStrategy(ShareAndTimeRange Share)
{
SaveDataHourly(Share);
}
private void SaveDataHourly(ShareAndTimeRange Share)
{
if (Share.Candle == null)
return;
var PreparedString = Share.Candle.Time.ToString("yyyyMMdd HHmmss") + ";";
PreparedString = PreparedString + Share.Candle.Open + ";" + Share.Candle.High + ";";
PreparedString = PreparedString + Share.Candle.Low + ";" + Share.Candle.Close;
PreparedString = PreparedString + LF;
switch (Share.ShareName)
{
case ("DAX"):
{
DataDax = DataDax + PreparedString;
//Data[0] = Data[0] +
bool reset = HDMYSaving(Share, DataDax);
if (reset)
DataDax = "";
break;
}
case ("DOW"):
{
DataDow = DataDow + PreparedString;
bool reset = HDMYSaving(Share, DataDow);
if (reset)
DataDow = "";
break;
}
case ("OIL"):
{
DataOil = DataOil + PreparedString;
bool reset = HDMYSaving(Share, DataOil);
if (reset)
DataOil = "";
break;
}
case ("GOLD"):
{
DataGold = DataGold + PreparedString;
bool reset = HDMYSaving(Share, DataGold);
if (reset)
DataGold = "";
break;
}
case ("SPY"):
{
DataSpy = DataSpy + PreparedString;
bool reset = HDMYSaving(Share, DataSpy);
if (reset)
DataSpy = "";
break;
}
case ("EUR/USD"):
{
DataEsd = DataEsd + PreparedString;
bool reset = HDMYSaving(Share, DataEsd);
if (reset)
DataEsd = "";
break;
}
case ("EUR/GBP"):
{
DataEgp = DataEgp + PreparedString;
bool reset = HDMYSaving(Share, DataEgp);
if (reset)
DataEgp = "";
break;
}
case ("USD/JPY"):
{
DataUpy = DataUpy + PreparedString;
bool reset = HDMYSaving(Share, DataUpy);
if (reset)
DataUpy = "";
break;
}
}
}
private void SavePersistentData (string FolderName , string FileName, string Share )
{
if (!System.IO.File.Exists(FolderName))
{
Directory.CreateDirectory(FolderName);
}
string fullPath = System.IO.Path.Combine(FolderName, FileName);
if (!System.IO.File.Exists(fullPath))
{
FileStream fs = File.Create(fullPath);
fs.Dispose();
}
using (StreamWriter sw = new StreamWriter(fullPath, false))
{
sw.Write(Share);
sw.Dispose();
}
//System.IO.File.WriteAllText(fullPath, Share);
}
private void SavePersistent (string ReadFolder , string WriteFolder , string WriteFolderFile)
{
DirectoryInfo ParDir = new DirectoryInfo(ReadFolder);
string dat = "";
foreach (var item in ParDir.GetFiles())
{
var elem = System.IO.Path.Combine(ReadFolder, item.Name);
dat += System.IO.File.ReadAllText(elem);
}
SavePersistentData(WriteFolder, WriteFolderFile, dat);
foreach (var item in ParDir.GetFiles())
{
var del = System.IO.Path.Combine(ReadFolder, item.Name);
File.Delete(del);
}
}
private bool HDMYSaving(ShareAndTimeRange Share, string Values)
{
if (Share.Candle == null)
return false;
bool toReset = false;
string SharePath = System.IO.Path.Combine(xPath, Share.ShareName);//c:\TradingBot\Saved Candles folder\"Sharename"\
string HourPath = System.IO.Path.Combine(SharePath, "Hour Data");//c:\TradingBot\Saved Candles folder\"Sharename"\Hour Data
int res;
int resuzt = Math.DivRem(Share.Candle.Time.Minute,3,out res);
if ( res == 0) //0 Share.Candle.Time.Minute == 0
{
DateTime DateToWriteH = Share.Candle.Time;
string HourFilePath = DateToWriteH.ToString("yyyyMMddHHmm") + ".txt";
SavePersistentData(HourPath, HourFilePath, Values);
toReset = true;
}
DateTime DateToWriteD = Share.Candle.Time.AddDays(-1);
string DayPath = System.IO.Path.Combine(SharePath, "Day Data");//c:\TradingBot\Saved Candles folder\"Sharename"\Day Data
string DayFilePath = System.IO.Path.Combine(DayPath, DateToWriteD.ToString("yyyyMMdd") + ".txt");
if (Share.Candle.Time.Hour == 0 && Share.Candle.Time.Minute == 0 && !System.IO.File.Exists(DayFilePath))
{
SavePersistent(HourPath, DayPath, DateToWriteD.ToString("yyyyMMdd") + ".txt");
}
DateTime DateToWriteM = Share.Candle.Time.AddMonths(-1);
string MonthPath = System.IO.Path.Combine(SharePath, "Month Data");//c:\TradingBot\Saved Candles folder\"Sharename"\Month Data
string MonthFilePath = System.IO.Path.Combine(MonthPath, DateToWriteM.ToString("yyyyMM") + ".txt");
if (Share.Candle.Time.Day == 1 && Share.Candle.Time.Hour == 0 && Share.Candle.Time.Minute == 0 && !System.IO.File.Exists(MonthFilePath))
{
SavePersistent(DayPath, MonthPath, DateToWriteM.ToString("yyyyMM") + ".txt");
}
DateTime DateToWriteY = Share.Candle.Time.AddYears(-1);
string YearPath = System.IO.Path.Combine(SharePath, "Year Data");//c:\TradingBot\Saved Candles folder\"Sharename"\Year Data
string YearFilePath = System.IO.Path.Combine(YearPath, DateToWriteY.ToString("yyyy") + ".txt");
if (Share.Candle.Time.Month == 1 && Share.Candle.Time.Day == 1 && Share.Candle.Time.Hour == 0 && Share.Candle.Time.Minute == 0 && !System.IO.File.Exists(YearFilePath))
{
SavePersistent(MonthPath, YearPath, DateToWriteY.ToString("yyyy") + ".txt");
}
return toReset;
}
}
Is there a problem having a lot of Events which are fired every 2 seconds or every minute?
Thanks!!
i found the problem. It was on another Class. The Fault was firing an event every time the program colleted a new value, but the program schould wait for the other "WebsTakenInCare".
Here is the Code before:
if (DataList.Count() == WebsTakenInCare)
{
FinalizedData = ShortenUpData(DataList);
DataList.Clear();
}
BuildCandles(FinalizedData);
and after changing:
if (DataList.Count() == WebsTakenInCare)
{
FinalizedData = ShortenUpData(DataList);
DataList.Clear();
BuildCandles(FinalizedData);
}
else
return;
regards!
I have following Grid where it populates InquiryDetails in the Win Form Load event
private void frmInquiryManagement_Load(object sender, EventArgs e)
{
InquiryService inquiry = new InquiryService();
clearGetInquiry();
DataTable dt = InfoPCMS.db.executeSelectQuery("select * from Inquiry");
gridInquiryList.DataSource = dt;
DataTable dt2 = InfoPCMS.db.executeSelectQuery("select * from Customer");
txtCustomer.Properties.DataSource = dt2;
txtCustomer.Properties.ValueMember = "Id";
txtCustomer.Properties.DisplayMember = "CustomerName";
txtCustomer.Properties.NullText = "Please Select Customer";
txtCustomer.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CustomerName"));
txtCustomer.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Address"));
txtCustomer.Properties.ShowHeader = false;
int nextid = inquiry.getNextId();
txtInquiryNo.Text = nextid.ToString();
}
By double clicking on a row, it searches for all the details and displays in "Get Inquiries" Tab as follows, code of that is below the image
private void selectInquiry(object sender, EventArgs e)
{
btnAddInquiry.Enabled = false;
btnUpdate.Enabled = true;
txtInquiryNo.Enabled = false;
String inquiryno = gridView1.GetFocusedDataRow()["InquiryNumber"].ToString();
InquiryService inquiry = new InquiryService();
inquiry = inquiry.searchInquiry(inquiryno);
if (inquiry != null)
{
txtInquiryNo.Text = inquiry.InquiryNumber.ToString();
//txtDate.Text = inquiry.InquiryDate;
txtDate.Text = InfoPCMS.conversion.convertDate(inquiry.InquiryDate);
txtCustomer.EditValue = inquiry.CustomerID.ToString();
txtInquiryTaken.Text = inquiry.InquiryTaken;
txtInspectionDetails.Text = inquiry.InspectionDetails;
txtProblemNature.Text = inquiry.ProblemNature;
txtProblemSource.Text = inquiry.ProblemSource;
txtSiteResponsible.Text = inquiry.SiteResponsible;
txtQuotationNo.Text = inquiry.QuotationNumber.ToString();
txtFollowupDetails.Text = inquiry.FollowupDetails;
txtInspectionDone.Text = inquiry.InspectionDone;
tabInquiryManagement.SelectedTabPage = xtraTabPage2;
}
else
{
MessageBox.Show(InfoPCMS.message.GET_NO_SUCH_RECORD_INFORMATION(), "Information");
}
}
First time you search it works fine, But after when you clear all the fields and the page and try another record it will give all the records but the Lookupedit value to its null state as follows,
private void clearGetInquiry() {
txtInquiryNo.Text = "";
txtDate.Text = "";
txtCustomer.EditValue = null;
txtInquiryTaken.Text = "";
txtInspectionDetails.Text = "";
txtProblemNature.Text = "";
txtProblemSource.Text = "";
txtSiteResponsible.Text = "";
txtQuotationNo.Text = "";
txtFollowupDetails.Text = "";
txtInspectionDone.Text = "";
btnAddInquiry.Text = "Add Inquiry";
InquiryService inquiry = new InquiryService();
int nextid = inquiry.getNextId();
txtInquiryNo.Text = nextid.ToString();
tabInquiryManagement.SelectedTabPage = xtraTabPage1;
btnAddInquiry.Enabled = true;
btnUpdate.Enabled = false;
txtInquiryNo.Enabled = true;
}
How can I get rid of this issue? (This happens even when you do the search after going into the "Get Inquiries" Tab and come.
I run the code and it will not store the values it stops immediately at the loadingfromscreen. What its supposed to do is a multi-page application form that will reinput the values to the texbox's on the back button from the next form.
The ASP.net code is too long to post, but basically its just texbox's and dropboxes. If needed i can post it, but the main issue im 90% sure is the C# code.
UPDATE: When i say stop it continues the code but will not run the dictionary method...i have put a arrow where the method stops in DICTIONARY ONLY
C#:
public partial class employment_driversapplication_personalinfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Dictionary<string, string> DriversApplicationData = (Dictionary<string, string>) Session["DriversApp"];
try
{
if (Page.IsPostBack)
{
LoadMemoryFromScreen(DriversApplicationData);
}
else
{
LoadScreenFromMemory(DriversApplicationData);
}
}
catch //(Exception ex)
{
// throw new Exception("Exception occured in employment_driversapplication_personalinfo.aspx - Page_Load" + ex.Message);
}
finally
{
}
}
private void LoadMemoryFromScreen(Dictionary<string, string> DicDriversApp)
{
DicDriversApp["position"] = position.Text; <---Stops here (won't even store this)
DicDriversApp["fname"] = fname.Text;
DicDriversApp["middleinitial"] = middleinitial.Text;
DicDriversApp["lname"] = lname.Text;
DicDriversApp["birthday"] = birthday.Text;
DicDriversApp["proofofage"] = proofofage.SelectedValue;
DicDriversApp["address"] = address.Text;
DicDriversApp["city"] = city.Text;
DicDriversApp["state"] = state.Text;
DicDriversApp["email"] = email.Text;
DicDriversApp["phone"] = phone.Text;
DicDriversApp["altphone"] = altphone.Text;
DicDriversApp["citizen"] = citizen.SelectedValue;
DicDriversApp["whoreferred"] = whoreferred.Text;
DicDriversApp["famfriend"] = famfriend.Text;
DicDriversApp["relationship"] = relationship.Text;
DicDriversApp["rateofpayexpected"] = rateofpayexpected.Text;
DicDriversApp["rateofpaytype"] = RadioButtonList1.SelectedValue;
DicDriversApp["employedNow"] = employednow.SelectedValue;
DicDriversApp["curremployment"] = curremployment.Text;
DicDriversApp["pastAddress"] = pastaddress.SelectedValue;
DicDriversApp["previousAddress"] = previousaddress.Text;
DicDriversApp["previousCity"] = previouscity.Text;
DicDriversApp["previousZip"] = previouszip.Text;
DicDriversApp["previousState"] = previousstate.Text;
DicDriversApp["previousDuration"] = previousduration.Text;
DicDriversApp["previousAddress1"] = previousaddress1.Text;
DicDriversApp["previousCity1"] = previouscity1.Text;
DicDriversApp["previousZip1"] = previouszip1.Text;
DicDriversApp["previousState1"] = previousstate1.Text;
DicDriversApp["previousDuration1"] = previousduration1.Text;
Session["DriversApp"] = DicDriversApp;
}
private void LoadScreenFromMemory(Dictionary<string, string> DicDriversApp)
{
position.Text = DicDriversApp["position"];
fname.Text = DicDriversApp["fname"] ;
middleinitial.Text = DicDriversApp["middleinitial"];
lname.Text = DicDriversApp["lname"];
birthday.Text = DicDriversApp["birthday"];
proofofage.SelectedValue = DicDriversApp["proofofage"];
address.Text = DicDriversApp["address"];
city.Text = DicDriversApp["city"];
state.Text = DicDriversApp["state"];
email.Text = DicDriversApp["email"];
phone.Text = DicDriversApp["phone"];
altphone.Text = DicDriversApp["altphone"];
citizen.SelectedValue = DicDriversApp["citizen"];
whoreferred.Text = DicDriversApp["whoreferred"];
famfriend.Text = DicDriversApp["famfriend"];
relationship.Text = DicDriversApp["relationship"];
rateofpayexpected.Text = DicDriversApp["rateofpayexpected"];
RadioButtonList1.SelectedValue = DicDriversApp["rateofpaytype"];
employednow.SelectedValue = DicDriversApp["employedNow"];
curremployment.Text = DicDriversApp["curremployment"];
pastaddress.SelectedValue = DicDriversApp["pastAddress"];
previousaddress.Text = DicDriversApp["previousAddress"];
previouscity.Text = DicDriversApp["previousCity"];
previouszip.Text = DicDriversApp["previousZip"];
previousstate.Text = DicDriversApp["previousState"];
previousduration.Text = DicDriversApp["previousDuration"];
previousaddress1.Text = DicDriversApp["previousAddress1"];
previouscity1.Text = DicDriversApp["previousCity1"];
previouszip1.Text = DicDriversApp["previousZip1"];
previousstate1.Text = DicDriversApp["previousState1"];
previousduration1.Text = DicDriversApp["previousDuration1"];
}
try something like this:
private void LoadMemoryFromScreen()
{
Dictionary<string, string> driver = new Dictionary<string, string>();
driver.Add("position", position.Text);
driver.Add("othervalue",value.Text); ///etc..
Session["dict"] = driver;
}
then, later on if you want to access the values in your dictionary, use something like this:
var dict = (Dictionary<string, string>)Session["dict"];
problem with this is that you're going to have to use dict.GetElementAt(index) in order to retrieve values, and i don't think that's a very good approach.
This will work, but i kinda dont understand why you are using a dictionary to do this. I assume you are only loading data from 1 person on your page? Then you might as well just make a class with all the properties in it, and then you can just pass that around instead of using this dictionary/session hack.
public class DriversApplicationData
{
public string position {get;set;}
public string firstname {get;set;}
//etc
}
then, you can just do something like
DriversApplicationData data = new DriversApplicationData();
data.position = position.Text;
data.firstname = fname.Text;
this is gonna be alot easier to maintain and to retrieve/insert values.