Anda di halaman 1dari 17

Anexa 1

Cod surs
Codul 1 Forma principal
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public int id_user;
public string baza="";
public string fisierul;
public MySqlConnection con;
public MySqlCommand cmd;
public MySqlDataAdapter adap;
int i = 0;
int j = 0;
public int saptamaini;// Week Count-ul la calendarControl
public int schimb = 0; // Pentru a afla care criteriu pentru date a fost
ales
DateTime d; // Data de comparatie Pentru interogre an,zi,luna
DateTime d1; // Data de comparatie interogare peronalziat si saptamina;
public DateTime data1;
public DateTime data2;
public double zile_ramase;
public int luna_curenta=0;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
d = DateTime.Now;
d1 = DateTime.Now;
var now = DateTime.Now;
var startOfMonth = new DateTime(now.Year, now.Month, 1);
var DaysInMonth = DateTime.DaysInMonth(now.Year, now.Month);
var lastDay = new DateTime(now.Year, now.Month, DaysInMonth);
schedulerControl1.Start = startOfMonth;
schedulerControl1.LimitInterval.Start = startOfMonth;
schedulerControl1.LimitInterval.End = lastDay;
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
if (string.IsNullOrEmpty(baza) == false)
{
salvareToolStripMenuItem_Click(sender, e);
sterge();
}
Application.Exit();
}
private void dropDownButton4_Click(object sender, EventArgs e)
{
if (i == 0) { panelControl6.Hide(); i = 1; }
else { panelControl6.Show(); i = 0; }
}
private void dropDownButton5_Click(object sender, EventArgs e)
{
if (j == 0) { panelControl2.Hide(); j = 1; }
else { panelControl2.Show(); j = 0; }
}
private void toolStripMenuItem8_Click(object sender, EventArgs e)
{

Continuare Anexa 1
if (schimb == 3)
{
schedulerControl1.Views.MonthView.WeekCount = 6;
}
if (schimb == 4)
{
DateTime ddd;
DateTime ddd1;
ddd = data1;
ddd1 = data2;
int dayofweek = (int)ddd.DayOfWeek;
if (dayofweek != 0)
{
ddd = ddd.AddDays(1 - dayofweek);
}
else { ddd = ddd.AddDays(-6); }
int dayofweek1 = (int)ddd1.DayOfWeek;
if (dayofweek1 != 0)
{
ddd1 = ddd1.AddDays(1 - dayofweek1);
}
else { ddd1 = ddd1.AddDays(-6); }
ddd1 = ddd1.AddDays(6);
TimeSpan t1;
t1 = ddd1 - ddd;
double zile_ramase1 = t1.TotalDays;
zile_ramase1 = zile_ramase1 + 1;
saptamaini = (int)zile_ramase1 / 7;
}
}
}
private void toolStripMenuItem9_Click(object sender, EventArgs e)
{
d = DateTime.Now;
schimb = 1;
var data=DateTime.Now;
string ziua = String.Format("{0:MMMM d, yyyy}", data);
char[] a = ziua.ToCharArray();
a[0] = char.ToUpper(a[0]);
button1.Text = new string(a);
private void toolStripMenuItem10_Click(object sender, EventArgs e)
{
schimb = 2;
d = DateTime.Now;
int dayofweek =(int) d.DayOfWeek;
if (dayofweek != 0)
{
d = d.AddDays(1 - dayofweek);
}
else { d = d.AddDays(-6); }
d1 = d.AddDays(6);
button1.Text = String.Format("{0:dd.MM.yyyy}", d) + " - " +
String.Format("{0:dd.MM.yyyy}", d1);
if (luna_curenta == 1)
{
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = false;
schedulerControl1.Views.MonthView.WeekCount = 1;
var startOfMonth = new DateTime(d.Year, d.Month, d.Day);
schedulerControl1.LimitInterval.Start = d;
schedulerControl1.LimitInterval.End = d1;
schedulerControl1.Start = startOfMonth;
}

Continuare Anexa 1
}
private void toolStripMenuItem11_Click(object sender, EventArgs e)
{
d = DateTime.Now;
schimb = 3;
var data = DateTime.Now;
string ziua = String.Format("{0:MMMM, yyyy}", data);
char[] a = ziua.ToCharArray();
a[0] = char.ToUpper(a[0]);
button1.Text = new string(a);
}
private void toolStripMenuItem13_Click(object sender, EventArgs e)
{
d = DateTime.Now;
schimb = 0;
var data = DateTime.Now;
string ziua = String.Format("{0:yyyy}", data);
button1.Text = ziua;
}
private void button3_Click(object sender, EventArgs e)
{
if (schimb == 0) {
d=d.AddYears(-1);
string ziua = String.Format("{0:yyyy}", d);
button1.Text = ziua;
if (luna_curenta == 1)
{
schedulerControl1.Views.MonthView.WeekCount = 6;
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = true;
var startOfMonth = new DateTime(d.Year, d.Month, 1);
var limit1 = new DateTime(d.Year, 1, 1);
var limit2 = new DateTime(d.Year, 12, 31);
schedulerControl1.LimitInterval.Start = limit1;
schedulerControl1.LimitInterval.End = limit2;
schedulerControl1.Start = startOfMonth;
} }
if (schimb == 3)
{
d= d.AddMonths(-1);
string ziua = String.Format("{0:MMMM, yyyy}", d);
char[] a = ziua.ToCharArray();
a[0] = char.ToUpper(a[0]);
button1.Text = new string(a);
if (luna_curenta == 1)
{
schedulerControl1.Views.MonthView.WeekCount = 6;
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = false;
var startOfMonth = new DateTime(d.Year, d.Month, 1);
var DaysInMonth = DateTime.DaysInMonth(d.Year, d.Month);
var lastDay = new DateTime(d.Year, d.Month, DaysInMonth);
schedulerControl1.Start = startOfMonth;
schedulerControl1.LimitInterval.Start = startOfMonth;
schedulerControl1.LimitInterval.End = lastDay;
}
}
if (schimb == 1)
{
d = d.AddDays(-1);
string ziua = String.Format("{0:MMMM d, yyyy}", d);
char[] a = ziua.ToCharArray();
a[0] = char.ToUpper(a[0]);
button1.Text = new string(a);
if (luna_curenta == 1)

Continuare Anexa 1
{

schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = false;
schedulerControl1.Views.MonthView.WeekCount = 1;
var startOfMonth = new DateTime(d.Year, d.Month, d.Day);
schedulerControl1.LimitInterval.Start = startOfMonth;
schedulerControl1.LimitInterval.End = startOfMonth;
schedulerControl1.Start = startOfMonth;
schedulerControl1.GoToDate(startOfMonth); }}
if(schimb==2){
d = d.AddDays(-7);
d1 = d1.AddDays(-7);
button1.Text = String.Format("{0:dd.MM.yyyy}", d) + " - " +
String.Format("{0:dd.MM.yyyy}", d1); if (luna_curenta == 1)
{
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = false;
schedulerControl1.Views.MonthView.WeekCount = 1;
var startOfMonth = new DateTime(d.Year, d.Month, d.Day);
schedulerControl1.LimitInterval.Start = d;
schedulerControl1.LimitInterval.End = d1;
schedulerControl1.Start = startOfMonth;
}
}
if (schimb == 4)
{
double a =zile_ramase+1;
data1 = data1.AddDays(-a);
data2 = data2.AddDays(-a);
button1.Text = String.Format("{0:dd.MM.yyyy}",data1) + " - " +
String.Format("{0:dd.MM.yyyy}", data2);
if (luna_curenta == 1){
DateTime ddd;
DateTime ddd1;
ddd = data1;
ddd1 = data2;
int dayofweek = (int)ddd.DayOfWeek;
if (dayofweek != 0)
{
ddd = ddd.AddDays(1 - dayofweek);
}
else { ddd = ddd.AddDays(-6); }
int dayofweek1 = (int)ddd1.DayOfWeek;
if (dayofweek1 != 0)
{
ddd1 = ddd1.AddDays(1 - dayofweek1);
}
else { ddd1 = ddd1.AddDays(-6); }
ddd1 = ddd1.AddDays(6);
TimeSpan t1;
t1 = ddd1 - ddd;
double zile_ramase1 = t1.TotalDays;
zile_ramase1 = zile_ramase1 + 1;
saptamaini = (int)zile_ramase1 / 7;
if (saptamaini <= 6)
{
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = false;
schedulerControl1.Views.MonthView.WeekCount = saptamaini;
schedulerControl1.LimitInterval.Start = data1;
schedulerControl1.LimitInterval.End = data2;
schedulerControl1.GoToDate(data1);
}
else
{
schedulerControl1.Views.MonthView.WeekCount = 6;

Continuare Anexa 1
schedulerControl1.Views.MonthView.DateTimeScrollbarVisible = true;
schedulerControl1.LimitInterval.Start = data1;
schedulerControl1.LimitInterval.End = data2;
schedulerControl1.GoToDate(data1);
}
}
} }
private void nouToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Dorii s creai o baz de date goal", "Confirm",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory =
Convert.ToString(Environment.SpecialFolder.MyDocuments);
saveFileDialog1.Filter = "KeyBudget database (*.KB)|*.KB|All Files (*.*)|
*.*";
saveFileDialog1.FilterIndex = 1;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
baza=Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
fisierul = saveFileDialog1.FileName;
con = new MySqlConnection();
try
{
con.ConnectionString = "server=localhost;user Id=root;Persist Security
Info=yes;";
con.Open();
cmd = con.CreateCommand();
cmd.CommandText = "drop DATABASE if exists " + baza.ToString();
cmd.ExecuteNonQuery();
cmd.CommandText = "CREATE DATABASE " + baza.ToString();
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception e1)
{
MessageBox.Show("Conection failed" + e1.ToString());
}
string startupPath = '"' + Environment.CurrentDirectory.ToString()
+ @"\buget_demo.KB" + '"';
fisierul='"'+fisierul+'"';
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
string a = @"/C cd C:\Program Files\MySQL\MySQL Server 5.5\bin & mysql -u
root " + baza + " < " + startupPath;
startInfo.Arguments = a;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
salvareToolStripMenuItem_Click(sender,e); }
}
}
private void salvareToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
string a = @"/C cd C:\Program Files\MySQL\MySQL Server 5.5\bin &
mysqldump -u root " + baza + " > " + fisierul;

Continuare Anexa 1
startInfo.Arguments = a;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
private void salvareCaToolStripMenuItem_Click(object sender, EventArgs e){
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory =
Convert.ToString(Environment.SpecialFolder.MyDocuments);
saveFileDialog1.Filter = "KeyBudget database (*.KB)|*.KB|All Files (*.*)|
*.*";
saveFileDialog1.FilterIndex = 1;
if (saveFileDialog1.ShowDialog() == DialogResult.OK){
fisierul = saveFileDialog1.FileName;
fisierul='"'+fisierul+'"';
salvareToolStripMenuItem_Click(sender, e);
this.Text = "KeyBudget " + fisierul;
} }
private void button4_Click(object sender, EventArgs e)
{
Form6 f6 = new Form6(this);
f6.ShowDialog();
}
private void treeList1_CustomDrawRowFooter(object sender,
DevExpress.XtraTreeList.CustomDrawRowFooterEventArgs e)
{
LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds,
Color.White,
Color.White, LinearGradientMode.Vertical);
e.Graphics.FillRectangle(backBrush, e.Bounds.X - 18, e.Bounds.Y,
e.Bounds.Width + 18, e.Bounds.Height);
// painting 3D borders
// prohibiting default painting
e.Handled = true;
}
private void treeList1_CustomDrawNodeCell(object sender,
CustomDrawNodeCellEventArgs e)
{
Brush foreBrush;
if (e.Node == (sender as TreeList).FocusedNode && e.Node.Level != 0)
{
Brush backBrush = new SolidBrush(SystemColors.MenuHighlight);
foreBrush = new SolidBrush(Color.White); e.Graphics.FillRectangle(backBrush,
e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
//e.Graphics.DrawString(e.CellText, e.Appearance.Font, foreBrush,e.Bounds);
e.Appearance.ForeColor = Color.White; e.Handled = true;
treeList1.Painter.DefaultPaintHelper.DrawNodeCell(e); // Prohibit default
painting.
}
}
private void button7_Click(object sender, EventArgs e)
{
if (treeList1.FocusedNode.Level != 0)
{
if (treeList1.FocusedNode.NextNode == null && treeList1.FocusedNode.PrevNode
== null )
{
treeList1.DeleteNode(treeList1.FocusedNode.ParentNode);
treeList1.DeleteNode(treeList1.FocusedNode); }
else
{
treeList1.DeleteNode(treeList1.FocusedNode);
}

Continuare Anexa 1
}
}
private void treeList1_CompareNodeValues(object sender,
CompareNodeValuesEventArgs e)
{
if (e.Node1.Level == 0 || e.Node2.Level == 0)
e.Result = 0;
}
private void treeList1_NodeCellStyle(object sender,
GetCustomNodeCellStyleEventArgs e)
{
if (e.Column.FieldName != "Sum") return;
if (Convert.ToInt32(e.Node.GetValue(e.Column.AbsoluteIndex)) < 0)
{ e.Appearance.ForeColor = Color.Red;
}

}
}}

Anexa 2
Cod surs
Codul 2 Gestionarea valutelor
public partial class Form10 : Form
{
public Form10()
{
InitializeComponent();
}
public int id_moneda = -1;
public int prestabilit;
public string moneda;
public decimal valoare;
MySqlConnection con;
MySqlCommand cmd;
MySqlDataAdapter adap;
public Form2 f2;
public Form10(Form2 f2){
InitializeComponent();
this.f2=f2;
}
private void Form10_Load(object sender, EventArgs e)
{
button8.Enabled = false; button2.Enabled = false;
con = new MySqlConnection();
con.ConnectionString = "server=localhost;user Id=root;Persist
Security Info=True;Database=" +f2.baza;
try
{
con.Open();
cmd = new MySqlCommand("Select *from moneda order by activ
DESC, Nume ASC", con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
treeList1.Nodes.Clear();
foreach (DataRow dr in dt.Rows)
{
TreeListNode node = treeList1.AppendNode(null, null);
node.SetValue("Nume", dr["Nume"]);
node.SetValue("Simbol", dr["Simbol"]);
node.SetValue("id", dr["id_moneda"]);
node.SetValue("activ", dr["activ"]);
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally {
con.Close();
}
try
{
con.Open();
cmd = new MySqlCommand("Select a.id_moneda from moneda a
inner join buget b on b.id_valuta=a.id_moneda", con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);

Continuare Anexa 2
foreach (DataRow dr in dt.Rows)
{
prestabilit = Convert.ToInt32(dr["id_moneda"].ToString());
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally
{
con.Close();
}
}
private void treeList1_CustomDrawNodeCell(object sender,
CustomDrawNodeCellEventArgs e)
{
if (Convert.ToInt32(e.Node["activ"].ToString())==0)
{
e.Appearance.ForeColor = Color.Gray;
}
Brush foreBrush;
if (Convert.ToInt32(e.Node["id"].ToString()) == prestabilit)
{
Brush backBrush = new SolidBrush(Color.Red);
foreBrush = new SolidBrush(Color.White);
e.Graphics.FillRectangle(backBrush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width,
e.Bounds.Height);
e.Appearance.ForeColor = Color.White;
}
if (e.Node == (sender as TreeList).FocusedNode &&
Convert.ToInt32(e.Node["id"])!=prestabilit)
{
id_moneda = Convert.ToInt32(e.Node["id"].ToString());
button8.Enabled = true; button2.Enabled = true;
if (Convert.ToInt32(e.Node["activ"].ToString()) > 0)
{
button3.Text = "Dezactivai";
button3.Image = KeyBudget.Properties.Resources.off;
}
else{
button3.Text = "Activai";
button3.Image = KeyBudget.Properties.Resources.on;
}
Brush backBrush = new SolidBrush(SystemColors.MenuHighlight);
foreBrush = new SolidBrush(Color.White);
e.Graphics.FillRectangle(backBrush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width,
e.Bounds.Height);
//e.Graphics.DrawString(e.CellText, e.Appearance.Font,
foreBrush,e.Bounds);
e.Appearance.ForeColor = Color.White;
e.Handled = true;
treeList1.Painter.DefaultPaintHelper.DrawNodeCell(e);
}
}
private void button3_Click(object sender, EventArgs e)
{
con = new MySqlConnection();
con.ConnectionString = "server=localhost;user Id=root;Persist
Security Info=True;Database=" +f2.baza;
if (button3.Text == "Activai")
{

Continuare Anexa 2
try{

con.Open();
cmd = new MySqlCommand("UPDATE moneda set activ=1 where
id_moneda=@id_moneda", con);
cmd.Parameters.AddWithValue("@id_moneda", id_moneda);
cmd.ExecuteNonQuery();
con.Close();
treeList1.FocusedNode.SetValue("activ", "1");
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
}
else
{
try
{
con.Open();
cmd = new MySqlCommand("UPDATE moneda set activ=0 where
id_moneda=@id_moneda", con);
cmd.Parameters.AddWithValue("@id_moneda", id_moneda);
cmd.ExecuteNonQuery();
con.Close();
treeList1.FocusedNode.SetValue("activ", "0");
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
}
treeList1.BeginSort();
treeList1.Columns["activ"].SortOrder = SortOrder.Descending;
treeList1.Columns["Nume"].SortOrder = SortOrder.Ascending;
treeList1.EndSort();
treeList1.FocusedNode = treeList1.Nodes[0];
}
private void button1_Click(object sender, EventArgs e)
{
Form5 f5 = new Form5(this);
f5.ShowDialog();
}
private void searchControl1_TextChanged(object sender, EventArgs e)
{
int n = treeList1.Nodes.Count();
int k = 0;
string text = searchControl1.Text;
try
{
con.Open();
cmd = new MySqlCommand("select *from moneda where Simbol like
+'%" + text + "%' or Nume like '%" + text + "%' ", con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
for (int i = 0; i < n; i++)
{
k = 0;
foreach (DataRow dr in dt.Rows)
{

Continuare Anexa 2
if (treeList1.Nodes[i]["id"].ToString() == dr["id_moneda"].ToString())
{
treeList1.Nodes[i].Visible = true;
k = 1;
break;
}
}
if (k == 0) { treeList1.Nodes[i].Visible = false; }
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally
{
con.Close();
}
treeList1.FocusedNode = treeList1.MoveFirst();
int n1 = treeList1.VisibleNodesCount;
if (n1 > 0)
{ button8.Enabled = true; button2.Enabled = true;}
else { button8.Enabled = false; button2.Enabled = false;}
}
private void button4_Click(object sender, EventArgs e)
{
try
{
con.Open();
cmd = new MySqlCommand("Select a.id_moneda, a.simbol,
a.valoare from moneda a inner join buget b on b.id_valuta=a.id_moneda", con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
prestabilit = Convert.ToInt32(dr["id_moneda"].ToString());
moneda = dr["simbol"].ToString();
valoare = Convert.ToDecimal(dr["valoare"].ToString());
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally
{
con.Close();
}
try
{
con.Open();
cmd = new MySqlCommand("Select *from moneda where activ>0 order by Nume",
con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
f2.treeList2.ClearNodes();
foreach (DataRow dr in dt.Rows)
{
TreeListNode node = f2.treeList2.AppendNode(null, null);
node.SetValue("treeListColumn13", dr["Nume"]);
decimal final = Convert.ToDecimal(dr["valoare"].ToString())/valoare;
node.SetValue("treeListColumn15", moneda + " " + string.Format("{0:0.00}",
Math.Round(final,2)));
}

Continuare Anexa 2
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally
{
con.Close();
}
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
con = new MySqlConnection();
con.ConnectionString = "server=localhost;user Id=root;Persist
Security Info=True;Database=" + f2.baza;
try
{
con.Open();
cmd = new MySqlCommand("UPDATE buget set id_valuta=" +
treeList1.FocusedNode["id"].ToString(), con);
cmd.ExecuteNonQuery();
prestabilit =
Convert.ToInt32(treeList1.FocusedNode["id"].ToString());
treeList1.Refresh();
}
catch (Exception e1)
{
MessageBox.Show("Conexiune nereusita" + e1.ToString());
}
finally
{
con.Close();
}
}
private void button8_Click(object sender, EventArgs e)
{
Form11 f11 = new Form11(this);
f11.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
{
id_categorie = 0;
Form8 f8 = new Form8(this);
f8.ShowDialog();
}
private void button7_Click(object sender, EventArgs e)
{
con = new MySqlConnection();
con.ConnectionString = "server=localhost;user Id=root;Persist
Security Info=True;Database=" + f6.f2.baza;
try
{
con.Open();
cmd = new MySqlCommand("Delete from categorie where
id_categorie=@id_cat", con);
cmd.Parameters.AddWithValue("@id_cat", id_categorie);
cmd.ExecuteNonQuery();
}
catch (Exception e1)
{

Continuare Anexa 2
MessageBox.Show("S-a ntmplat o eroare cu textul urmtor " + e1.ToString());
}
finally
{
con.Close();
}
treeList1.DeleteNode(treeList1.FocusedNode);
button6.Enabled = false;
button7.Enabled = false;
}
private void button6_Click(object sender, EventArgs e)
{
Form8 f8 = new Form8(this);
f8.ShowDialog();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
f6.id_categorie = id_categorie;
con = new MySqlConnection();
try
{
con.ConnectionString = "server=localhost;user Id=root;Persist
Security Info=True;Database=" + f6.f2.baza;
}
catch (Exception e1)
{
MessageBox.Show("Conection failed" + e1.ToString());
}
if (id_categorie != 0)
{
try
{
con.Open();
cmd = new MySqlCommand("Select *from categorie where
id_categorie=@id", con);
cmd.Parameters.AddWithValue("@id", id_categorie);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
if (string.IsNullOrEmpty(dr["iconita"].ToString()) == false)
{
ImageList myImageList12 = new ImageList();
myImageList12.ColorDepth = ColorDepth.Depth32Bit;
myImageList12.ImageSize = new Size(25, 25);
myImageList12.TransparentColor = Color.Transparent;
myImageList12.Images.Clear();
myImageList12.Images.Add(Image.FromFile(dr["iconita"].ToString()));
f6.dropDownButton1.ImageList = myImageList12;
f6.dropDownButton1.ImageIndex = 0;
iconita = dr["iconita"].ToString();
}
6.dropDownButton1.Text = dr["Nume"].ToString();
}
con.Close();

}
catch (Exception e1)
{
MessageBox.Show("Conection failed" + e1.ToString());
}

Continuare Anexa 2
}
else
{
}

f6.dropDownButton1.ImageIndex = -1;
f6.dropDownButton1.Text ="Categorie" ;
this.Close();

}
private void simpleButton2_Click(object sender, EventArgs e)
{
f6.id_categorie = 0;
f6.dropDownButton1.ImageIndex = -1;
f6.dropDownButton1.Text = "Categorie";
this.Close();
}
private void searchControl1_TextChanged(object sender, EventArgs e)
{
int n = treeList1.Nodes.Count();
int k = 0;
string text = searchControl1.Text;
try
{
con.Open();
cmd = new MySqlCommand("select *from Categorie where Nume
like +'%" + text + "%' or Comentariu like '%" + text + "%' ", con);
adap = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adap.Fill(dt);
for (int i = 0; i < n; i++)
{
k = 0;
foreach (DataRow dr in dt.Rows)
{
if (treeList1.Nodes[i]["id"].ToString() ==
dr["id_categorie"].ToString())
{
treeList1.Nodes[i].Visible = true;
k = 1;
break;
}
}
if (k == 0)
{
treeList1.Nodes[i].Visible = false;
}
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());
}
finally
{
con.Close();
}
treeList1.FocusedNode = treeList1.MoveFirst();
int n1 = treeList1.VisibleNodesCount;
}}}}

Anexa 3
Cod surs
Codul 3 Actualizarea ratelor de schimb de pe internet
namespace WindowsFormsApplication1
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
DateTime d;
String data;
string xmlResult;
XmlDocument doc;
XmlNodeList elemList;
XmlNodeList Nume;
MySqlConnection con;
MySqlCommand cmd;
public Form10 f10;
public Form5(Form10 f10)
{
InitializeComponent();
this.f10 = f10;
}
private void button2_Click(object sender, EventArgs e)
{
progressBar1.Value = 0;
d = DateTime.Now;
data = string.Format("{0:dd.MM.yyyy}", d);
backgroundWorker1.RunWorkerAsync();
button3.Visible = true;
button2.Visible = false;
xmlResult = null;
string url;
url = "http://www.bnm.md/md/official_exchange_rates?get_xml=1&date=" + data;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader resStream1 = new StreamReader(response.GetResponseStream());
doc = new XmlDocument();
xmlResult = resStream1.ReadToEnd();
doc.LoadXml(xmlResult);
elemList = doc.GetElementsByTagName("Value");
Nume = doc.GetElementsByTagName("CharCode");
con = new MySqlConnection();
con.ConnectionString = "server=localhost;user Id=root;Persist Security
Info=True;Database=" + f10.f2.baza;
try
{
con.Open();
for (int i = 0; i < elemList.Count; i++) {
cmd = new MySqlCommand("UPDATE moneda set valoare="+elemList[i].InnerText+"
where Simbol=@Simbol", con);
cmd.Parameters.AddWithValue("@Simbol",Nume[i].InnerText);
cmd.ExecuteNonQuery();
}
}
catch (Exception e1)
{
MessageBox.Show("Conection failed " + e1.ToString());

Continuare Anexa 3
}
finally
{

con.Close();

}
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void backgroundWorker1_DoWork_1(object sender, DoWorkEventArgs e)
{
try
{
string url;
url = "http://www.bnm.md/md/official_exchange_rates?get_xml=1&date="+data;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Int64 iSize = response.ContentLength;
Int64 iRunningByteTotal = 0;
StreamReader resStream = new
StreamReader(response.GetResponseStream());
// loop the stream and get the file into the byte buffer
int iByteSize = 0;
byte[] byteBuffer = new byte[iSize];
while ((iByteSize = resStream.BaseStream.Read(byteBuffer, 0,
byteBuffer.Length)) > 0)
{
iRunningByteTotal += iByteSize;
// calculate the progress out of a base "100"
double dIndex = (double)(iRunningByteTotal);
double dTotal = (double)byteBuffer.Length;
double dProgressPercentage = (dIndex / dTotal);
int iProgressPercentage = (int)(dProgressPercentage *
100);
// update the progress bar
backgroundWorker1.ReportProgress(iProgressPercentage);
}
catch

{
MessageBox.Show("A aparut o eroare, verificati Conexiunea la Internet");
}
}
private void backgroundWorker1_ProgressChanged_1(object sender,
ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void backgroundWorker1_RunWorkerCompleted_1(object sender,
RunWorkerCompletedEventArgs e)
{
button2.Visible = true;
button3.Visible = false;
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
backgroundWorker1.CancelAsync();
}}

PLANULUL CALENDARISTIC DE ELABORARE A LUCRRII DE DIPLOM

Nr.

1)
2)

3)
4)
5)
6)
7)
8)
9)

10)

11)
12)

13)

PLANUL
calendaristic al elaborrii lucrrii de diplom
Coninutul
Termenul
Forma
Nota coordonatorului
de
rezultatelor
activitilor
Termenul efectiv
executare activitilor
de executare
Semntura
Selectarea temei de ctre elev i
depunerea cererii
Aprobarea
temei
lucrrii
i
coordonatorului tiinific fiecrui
elev
Stabilirea obiectivelor i aprobarea
planului iniial al lucrrii de diplom
Selectarea i studierea literaturii de
specialitate
Colectarea i sistematizarea datelor
statistice i materialului practic
Elaborarea i prezentarea primului
capitol coordonatorului tiinific
Elaborarea i prezentarea capitolului
doi coordonatorului tiinific
Elaborarea i prezentarea capitolului
trei coordonatorului tiinific
Elaborarea
i
prezentarea
Introducerii i Concluziilor generale
i recomandrilor coordonatorului
tiinific
Transmiterea lucrrii de diplom
copertat coordonatorului tiinific
pentru avizare
Elaborarea avizului de
ctre
coordonatorul tiinific
Depunerea oficial a lucrrii de
diplom de ctre elev la catedr

Septembrie

Cerere

Octombrie

Ordinul
directorului

Noiembrie

Plan
calendaristic
Lista
bibliografiei
Baze de date

Susinerea public a lucrrii de


diplom

Conform
orarului
sesiunii de
examinare

25 ianuarie
15
februarie
15 martie
15 aprilie
1 mai
5 mai

Expunere
scris
Expunere
scris
Expunere
scris
Expunere
scris

20 mai

Lucrare
copertat

25 mai

Aviz

26 mai

Teza
copertat i
avizat
Aprecierea
comisiei de
examinare i
calificare

Data______________
______________
(semntura elevului)