|
KaKoten wrote: i'am trying to opening sub form but main form must be reduce how to add the code You mean "minimized"? I wouldn't recommend that, as a minimized form should not be displaying stuff.
You might want to set the parent of the sub-form though;
fo.ShowDialog(this);
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks for the answer
|
|
|
|
|
When I load my page it shows error:
<pre>Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'UserInfoaa' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 176: }
Line 177:
Line 178: public virtual UserInfoaa UserInfoaa {
Line 179: get {
Line 180: return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c367d58a\7b408850\App_Code.d_07k52h.1.cs Line: 178 </pre>
My default.aspx Code is:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using System.Text;
namespace WebApplication2
{
public partial class Dfault : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void submit_Click(object sender, EventArgs e)
{
MembershipCreateStatus createStatus;
MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text, null, null, true, out createStatus);
saveprofile();
}
public void saveprofile()
{
ProfileCommonaa Profile = new ProfileCommonaa();
Profile.UserInfoaa.Name = name.Text;
Profile.Save();
}
}
}</pre>
My UserInfoaa class code is:
<pre lang="css">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2
{
[Serializable()]
public class UserInfoaa
{
#region variables
private string name;
private string dateofbirth;
private string birthplace;
private string place;
private string languages;
private string aboutme;
private string employer;
private string project;
private string designation;
private string university;
#endregion variables
#region Properties
public string Name
{
get { return name; }
set { name = value; }
}
public string DateofBirth
{
get { return dateofbirth; }
set { dateofbirth = value; }
}
public string Languages
{
get { return languages; }
set { languages = value; }
}
public string BirthPlace
{
get { return birthplace; }
set { birthplace = value; }
}
public string Place
{
get { return place; }
set { place = value; }
}
public string AboutMe
{
get { return aboutme; }
set { aboutme = value; }
}
public string Employer
{
get { return employer; }
set { employer = value; }
}
public string Project
{
get { return project; }
set { project = value; }
}
public string Designation
{
get { return designation; }
set { designation = value; }
}
public string University
{
get { return university; }
set { university = value; }
}
#endregion Properties
#region Constructors
public UserInfoaa()
{
}
public UserInfoaa(string _name, string _dateofbirth, string _birthplace, string _place, string _languages, string _aboutme, string _employer, string _project, string _designation, string _university)
{
name = _name;
dateofbirth = _dateofbirth;
birthplace = _birthplace;
place = _place;
languages = _languages;
aboutme = _aboutme;
employer = _employer;
project = _project;
designation = _designation;
university = _university;
}
#endregion Constructors
}
}</pre>
Class1 for ProfileCommonaa is:
<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Text;
using System.Web.Security;
using System.Web.UI;
namespace WebApplication2
{
public class ProfileGroupBasicInfoaa : System.Web.Profile.ProfileGroupBase
{
public virtual string Place
{
get
{
return ((string)(this.GetPropertyValue("Place")));
}
set
{
this.SetPropertyValue("Place", value);
}
}
public virtual string BirthPlace
{
get
{
return ((string)(this.GetPropertyValue("BirthPlace")));
}
set
{
this.SetPropertyValue("BirthPlace", value);
}
}
public virtual System.DateTime DateofBirth
{
get
{
return ((System.DateTime)(this.GetPropertyValue("DateofBirth")));
}
set
{
this.SetPropertyValue("DateofBirth", value);
}
}
public virtual string Name
{
get
{
return ((string)(this.GetPropertyValue("Name")));
}
set
{
this.SetPropertyValue("Name", value);
}
}
public virtual string AboutMe
{
get
{
return ((string)(this.GetPropertyValue("AboutMe")));
}
set
{
this.SetPropertyValue("AboutMe", value);
}
}
public virtual string Languages
{
get
{
return ((string)(this.GetPropertyValue("Languages")));
}
set
{
this.SetPropertyValue("Languages", value);
}
}
}
public class ProfileGroupProfessionlProfileaa : System.Web.Profile.ProfileGroupBase
{
public virtual string Designation
{
get
{
return ((string)(this.GetPropertyValue("Designation")));
}
set
{
this.SetPropertyValue("Designation", value);
}
}
public virtual string Employer
{
get
{
return ((string)(this.GetPropertyValue("Employer")));
}
set
{
this.SetPropertyValue("Employer", value);
}
}
public virtual string University
{
get
{
return ((string)(this.GetPropertyValue("University")));
}
set
{
this.SetPropertyValue("University", value);
}
}
public virtual string Project
{
get
{
return ((string)(this.GetPropertyValue("Project")));
}
set
{
this.SetPropertyValue("Project", value);
}
}
}
public class ProfileCommonaa : System.Web.Profile.ProfileBase
{
public virtual string Employer
{
get
{
return ((string)(this.GetPropertyValue("Employer")));
}
set
{
this.SetPropertyValue("Employer", value);
}
}
public virtual string Name
{
get
{
return ((string)(this.GetPropertyValue("Name")));
}
set
{
this.SetPropertyValue("Name", value);
}
}
public virtual string Place
{
get
{
return ((string)(this.GetPropertyValue("Place")));
}
set
{
this.SetPropertyValue("Place", value);
}
}
public virtual string Languages
{
get
{
return ((string)(this.GetPropertyValue("Languages")));
}
set
{
this.SetPropertyValue("Languages", value);
}
}
public virtual UserInfoaa UserInfoaa
{
get
{
return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
}
set
{
this.SetPropertyValue("UserInfoaa", value);
}
}
public virtual string AboutMe
{
get
{
return ((string)(this.GetPropertyValue("AboutMe")));
}
set
{
this.SetPropertyValue("AboutMe", value);
}
}
public virtual string Project
{
get
{
return ((string)(this.GetPropertyValue("Project")));
}
set
{
this.SetPropertyValue("Project", value);
}
}
public virtual string BirthPlace
{
get
{
return ((string)(this.GetPropertyValue("BirthPlace")));
}
set
{
this.SetPropertyValue("BirthPlace", value);
}
}
public virtual System.DateTime DateofBirth
{
get
{
return ((System.DateTime)(this.GetPropertyValue("DateofBirth")));
}
set
{
this.SetPropertyValue("DateofBirth", value);
}
}
public virtual string Designation
{
get
{
return ((string)(this.GetPropertyValue("Designation")));
}
set
{
this.SetPropertyValue("Designation", value);
}
}
public virtual string University
{
get
{
return ((string)(this.GetPropertyValue("University")));
}
set
{
this.SetPropertyValue("University", value);
}
}
public virtual ProfileGroupBasicInfoaa BasicInfo
{
get
{
return ((ProfileGroupBasicInfoaa)(this.GetProfileGroup("BasicInfo")));
}
}
public virtual ProfileGroupProfessionlProfileaa ProfessionlProfile
{
get
{
return ((ProfileGroupProfessionlProfileaa)(this.GetProfileGroup("ProfessionlProfile")));
}
}
public virtual ProfileCommonaa GetProfileaa(string username)
{
return ((ProfileCommonaa)(ProfileBase.Create(username)));
}
}
}</pre>
Please help! thanks in advance
|
|
|
|
|
Quote: are you missing a using directive or an assembly reference? Add the assembly (dll) where UserInfoaa is defined.
Make sure that that assembly does not have a "zone identifier" with the value of "Internet" (on the level of the NTFS file system).
|
|
|
|
|
how to adding code message box to successful message sending and i'am have to failed sent but successful nothing. this is the source code use c# 2008. Thanks for help me
private void button_Send(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == quot;" || textBox3.Text == "")
{
MessageBox.Show("Please Fill Required field");
}
else
try
{
obj_SMTPClient = new SmtpClient("smtp.gmail.com");
Obj_MailMsg = new MailMessage();
obj_Attachment = new System.Net.Mail.Attachment(label3.Text);
Obj_MailMsg.From = new MailAddress(textBox1.Text);
Obj_MailMsg.To.Add(textBox3.Text);
Obj_MailMsg.Body = textBox5.Text;
Obj_MailMsg.Attachments.Add(obj_Attachment);
Obj_MailMsg.Subject = textBox4.Text;
SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
obj_SMTPClient.Credentials = new NetworkCredential();
obj_SMTPClient.Port = 587;
obj_SMTPClient.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
}
catch
{
MessageBox.Show("Sorry TimeOut");
}
}
|
|
|
|
|
Try:
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
MessageBox.Show("Sent successfully");
}
catch
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
Hi ALL !
I want to execute this by OledbDataReader when I want to take ... :
string CalcQuery = @"SELECT SUM(BuyAmount) From SubTblMetal WHERE IDMetal=" + int.Parse(txtId.ToString());
OleDbCommand cmdCacl;
cnnCalc.Open();
cmdCacl = new OleDbCommand(CalcQuery, cnnCalc);
OleDbDataReader dr;
dr = cmdCacl.ExecuteReader();
if (dr.HasRows==false)
{
txtBuyAmount.Text = "0";
throw new Exception();
}
else if (dr.Read())
{
txtBuyAmount.Text = dr[0].ToString();
}
But when my DataReader has not any row ,I have an error for the value of txtBuAmount.Text
please Help , how can get the value of Zero (0) , when dataRow has not any row(value).
Thanks a lot !
|
|
|
|
|
First off, please use a parameterized query rather than concatenating the value into the statement.
Next, don't trust HasRows.
Also, why is that throw in there?
As you are expecting at most one value, you might do better with ExecuteScalar and then test for DBNull.Value (for when ther are no matching records).
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Very nicely explained
If You Never Try You’ll Never Know
|
|
|
|
|
I want To do This :
BuyAmount.Text = "0";
When there is No Row in dataReader
thanks
|
|
|
|
|
I understand, but are there ever no rows? Or do you get a NULL (DBNull.Value) when there are no matching rows?
Even if you do get no rows, it's better to handle that with an else on the other if . You don't need two if s; you don't need to test HasRows .
HasRows is not a member of the IDataReader[^] interface so you can't count on it being in every database system you use (if you ever have to use multiple database system, like I do). Every time I've tried to use HasRows I got burnt.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes , thanks , I use If and else when dbIsNull . It works .
|
|
|
|
|
Hello everybody!
At first, I was making a mood(emotion) detection desktop app in real time from a web camera using Human Emotion Detection from Image[^] as reference, but unfortunately, I failed at this.
Then , I tried something else ; I searched for a pre-made mood detection in real time app to integrate it as out-tool program. So, I found at http://www.ginktage.com/2011/08/using-face-api-in-c/[^] that there was an API web site called www.face.com which provided what I wanted and a library for c# . But again, unfortunately, it doesn't exist anymore.
So, my question is:
Do you know something similar to www.face.com for mood detection in real time , which can be used in c# and can you give examples how to use it in c#? Or at least, a c# open source program for mood detection in real time?
Thank you in advance for your help!
|
|
|
|
|
Intel provides the RealSense SDK which has this capability.
|
|
|
|
|
I´ve set up business logic handling a connection of a clientsoftware to a serversoftware.
That BL is encapsulated in this interface:
public interface IServerConnectionLogic
{
IObservable<bool> Connected { get; }
Task Connect();
...
}
Connect());
In my viewmodel (based on ReactiveObject) I create my commands, that should trigger the server-connection:
CmdConnectToService = new ReactiveCommand(ServerConnectionLogic.Connected.Select(connected => !connected));
CmdConnectToService.Subscribe(_ => ServerConnectionLogic.Connect());
The command is bound to a button in my UI-XAML.
When pressing the button the subscribed lamda is hit and the "Connect" method is called.
Inside the Observable "Connected" is set to "true.
Also the lambda in the "CanExecute"-parameter of the constructor of the ReactiveCommand is hit.
But the UI is not updated. I would have expected the button to get disabled, sinde the observable "Connected" turns to "true" and the "Select" statement inverts my boolean value...
I´ve tried that with the "RibbonButton" from the WpfToolkit as well as with a "normal" Button. Both are not getting updated.
The same IObservable<bool> is also bound to a member field:
m_ServerConnected = new ObservableAsPropertyHelper<bool>(ServerConnectionLogic.Connected, _ => raisePropertyChanged("ServerConnected"));
while "m_ServerConnected" is bound to a CheckBox (for testing) via a property. That one is working fine, so the observable must be working...
Does anyone have an idea what could be my issue?
|
|
|
|
|
public class Sample{
BindingList<something> Some;
public Sample(ref BindingList<something> some)
{
Some = some;
}
}
That class should be keep alive until the application will be closed "hmm that was a bad practice!" but i need it because it will monitor the db if there is a changes in data.
then i have this:
public static Sample s = new Sample(ref SomeVariable)
Now when i passes the SomeVariable with data it is working fine, any changes of the variable "Some" of the Sample class it is reflected to the SomeVariable.
Now the problem rise if the SomeVariable has a 0(zero) items on it and passed to constructor (SomeVariable here is properly initiated), then if the Sample class found changes in the db the SomeVariable is not updated.
I will appreciate for any help will come.
Thank you,
Gilbert
|
|
|
|
|
Sorry?
That is a little confused to me - remember that we can't see your screen, access your HDD, or read your mind.
If you want a class instance that exists until the application is closed, then that won't necessarily do it: you want to use a static class, because your existing example can still be Disposed by the GC if there are no references to it. Or just declare an instance in your main form.
Other than that, I can;t work out what you are saying...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
sorry for that, i will include now the real code
public abstract class DBSynchronizer<T> : IDBSynchronizer
where T : GCSC.Interface.IEditableObject
{
protected EditableObjectEventHandler onEditableObjectRaised;
protected EditableList<T> referencedItem;
protected bool hasNewItems, hasModifiedItems, hasRemovedItems;
protected List<int> idsNew, idsOld;
protected EditableList<T> tempSourceType;
protected StringBuilder tempSB;
protected MySQLSelect tempMySQLSelect;
Timer Ticker;
int track, defaultIterationBeforeSleep, cycle;
bool isTickerStarted;
int kickStarter;
public DBSynchronizer(ref EditableList<T> itemCollection)
{
referencedItem = itemCollection;
IsInitialized = referencedItem.Count < 1 ? false : true;
IterationBeforeSleep = 5;
MaxSleepTime = 60000;
Interval = 1000;
}
protected virtual void CollectNewItems(string query)
{
tempMySQLSelect = new MySQLSelect(query);
if (tempMySQLSelect.RowCount < 1)
{
hasNewItems = false;
return;
}
hasNewItems = true;
tempSourceType = new EditableList<T>(tempMySQLSelect.Reader());
tempMySQLSelect.Clear();
foreach (var ni in tempSourceType)
referencedItem.Add(ni);
tempSourceType = null;
}
public virtual void ForceCollectNewItem()
{
CollectNewItems(NewItemQuery);
}
protected abstract void CollectModifiedItems();
protected abstract void CollectRemovedItems();
public abstract void NotifyAllSubscriber();
private void Ticker_Tick(object sender, EventArgs e)
{
if (referencedItem.Count > 0)
{
CollectRemovedItems();
CollectModifiedItems();
}
CollectNewItems(NewItemQuery);
}
protected virtual void Initialize()
{
if (isTickerStarted)
return;
defaultIterationBeforeSleep = IterationBeforeSleep;
IsInitialized = true;
isTickerStarted = true;
Ticker = new Timer() { Interval = Interval, Enabled = true };
Ticker.Tick += Ticker_Tick;
Ticker.Start();
}
public virtual void ForceAwake()
{
if (!isTickerStarted)
return;
if (Ticker != null)
if (Ticker.Interval == Interval)
return;
Ticker.Dispose();
Ticker = new Timer() { Interval = Interval, Enabled = true };
Ticker.Tick += Ticker_Tick;
Ticker.Start();
}
public virtual void Shutdown()
{
if (Ticker == null) return;
Ticker.Dispose();
}
protected virtual int Timing()
{
if (MaxSleepTime < 1000) throw new ArgumentException("MaxSleepTime must not be less than or equal 1000", "MaxSleepTime");
return new RandomNumber(1000, MaxSleepTime).GetRandomNumber();
}
public int IterationBeforeSleep { get; set; }
public bool IsInitialized { get; protected set; }
public bool IsSleep { get; protected set; }
public int Interval { get; set; }
public int ForceShutdownAt { get; set; }
public int MaxSleepTime { get; set; }
protected abstract string NewItemQuery { get; }
public event EditableObjectEventHandler EditableObjectRaised
{
add
{
Initialize();
onEditableObjectRaised += value;
}
remove { onEditableObjectRaised -= value; }
}
}
Then it was inhereted here
internal sealed class SynchronizePersonClass : DBSynchronizer<PersonsClass>
{
static readonly object _locker = new object();
public SynchronizePersonClass(ref EditableList<PersonsClass> itemCollection)
: base(ref itemCollection) { }
protected override void CollectModifiedItems()
{
}
protected override void CollectRemovedItems()
{
}
protected override void Initialize()
{
lock (_locker)
{
if (!IsInitialized)
ProcessClass<PersonsClass>.PopulateCollection(ref ClassCollections.PersonClassColletction,
ReadOnlyStrings.TBL_PERSON + " WHERE `is_deleted` = 0 ORDER BY `registration_date` DESC");
base.Initialize();
}
}
public override void NotifyAllSubscriber()
{
if (onEditableObjectRaised == null) return;
onEditableObjectRaised(this, new EditableObjectEventArgs(referencedItem));
referencedItem.Finalized();
}
protected override string NewItemQuery
{
get
{
return ReadOnlyStrings.TBL_PERSON + " WHERE `is_deleted` = 0 AND `tbl_person_id` NOT IN(" +
getIDCollectionString() + ") ORDER BY `registration_date` DESC";
}
}
private string getIDCollectionString()
{
if (referencedItem.Count < 1) return "0";
tempSB = new StringBuilder(referencedItem.Count * 2);
foreach (var ri in referencedItem)
tempSB.Append(ri.PersonID + ", ");
return tempSB.Remove(tempSB.Length - 2, 2).ToString();
}
}
then create a static object of it
internal class Synchronizers
{
public static SynchronizePersonClass PersonClassSynchronizer;
}
the initializing the bindinglist
ProcessClass<PersonsClass>.PopulateCollection(ref ClassCollections.PersonClassColletction, query);
then initial the static synchronizer with the bindinglist from above
Synchronizers.PersonClassSynchronizer = new SynchronizePersonClass(ref ClassCollections.PersonClassColletction);
Synchronizers.PersonClassSynchronizer.IterationBeforeSleep = 15;
Synchronizers.PersonClassSynchronizer.MaxSleepTime = 10000;
now my big problem that i dont understand is if the ClassCollections.PersonClassCollection has no items on it, then if the synchronizer found new record it doesnt update the ClassCollection.PersonClass then i tried to debug it, the varible "referencedItem" has some items.
but if the classCollection.PersonClass has an item even just 1 before it was passed to the synchronizer there is no problem about it, any moodification in referencedItem will be reflected to ClassCollection.PersonClass and vice versa.
What your thought about that.
Sorry for my bad english and long post.
Thank you
Gilbert
|
|
|
|
|
I don't understand what you're actually asking, but I suspect you don't fully understand what ref does, because the way you used it it's not doing anything.
Parameters passed with ref let the called function modify the variable which was passed by ref. For example:
static void modify(ref int x)
{
x += 10;
}
static void main()
{
int y = 5;
modify(ref y);
Console.WriteLine(y);
}
Since BindingList is a reference type, Some will refer to the same object as was passed in anyway, regardless of ref. And if it had been a value type (which it isn't, but if) then the assignment from some to Some would have copied it anyway. Reference types and value types are something completely separate from and orthogonal to ref.
|
|
|
|
|
I post much more detailed post above, have a look on it. Please ; and what is your thought about it
Thanks
|
|
|
|
|
nice example
Sankarsan Parida
|
|
|
|
|
ok, i think this post is dead
|
|
|
|
|