-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConGameSett.cs
191 lines (158 loc) · 8.02 KB
/
ConGameSett.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
namespace FighyGym2
{
public partial class ConGameSett : DevExpress.XtraEditors.XtraUserControl
{
private static ConGameSett _instance;
Database db = new Database();
DataTable tbl = new DataTable();
public static ConGameSett Instance
{
get
{
if (_instance == null)
_instance = new ConGameSett();
return _instance;
}
}
int User_id;
string datecurrent;
public ConGameSett()
{
InitializeComponent();
}
private void GetSet()
{
txtSenf.Items.Clear();
tbl.Clear();
tbl = db.readData("SELECT Distinct [Senf] FROM [fightGym].[dbo].[Set_fatrat] ", "");
for (int i = 0; tbl.Rows.Count > i; i++)
{
//DataGridViewComboBoxColumn cbx = (DataGridViewComboBoxColumn)dataGridView1.Rows[0].Cells[4].OwningColumn;
//cbx.Items.Add(tbl.Rows[i][0].ToString());
txtSenf.Items.Add(tbl.Rows[i][0].ToString());
}
//tbl.Clear();
//tbl = db.readData("SELECT Distinct [Ftrah] FROM [fightGym].[dbo].[Set_fatrat] ", "");
//for (int i = 0; tbl.Rows.Count > i; i++)
//{
// DataGridViewComboBoxColumn cbx1 = (DataGridViewComboBoxColumn)dataGridView1.Rows[0].Cells[3].OwningColumn;
// cbx1.Items.Add(tbl.Rows[i][0].ToString());
//}
//tbl.Clear();
//tbl = db.readData("SELECT Distinct [Feaah] FROM [fightGym].[dbo].[Set_fatrat] ", "");
//for (int i = 0; tbl.Rows.Count > i; i++)
//{
// DataGridViewComboBoxColumn cbx2 = (DataGridViewComboBoxColumn)dataGridView1.Rows[0].Cells[2].OwningColumn;
// cbx2.Items.Add(tbl.Rows[i][0].ToString());
//}
}
private void ConGameSett_Load(object sender, EventArgs e)
{
GetSet();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "") { XtraMessageBox.Show("يجب تعبئة حقل البحث", "تنوية", MessageBoxButtons.OK, MessageBoxIcon.Information); }
else
{
// tbl = db.readData("SELECT DISTINCT Penf_ID,[Emp_ID] ,[Penf_Name] ,HC_ID,[TBL_Departments].Dpt_Name,TBL_penfType.NametypePenf FROM [HC_YC].[dbo].[TBL_penfdata] ,[TBL_Departments],TBL_penfType where Emp_ID='" + txtaddrow.Text + "' And Penf_ID ='" + txthealth.Text + "' ", "");
tbl = db.readData("SELECT [ID] ,[Senf] ,[Ftrah] ,[Feaah] ,[user_id] ,[Entertime],Days FROM [fightGym].[dbo].[Set_fatrat] where Senf like '%" + textBox1.Text + "%' ", "");
dataGridView2.DataSource = tbl;
//if (tbl.Rows.Count > 0)
//{
// txtSenf.Text = tbl.Rows[0][1].ToString();
// txtfatrah.Text = tbl.Rows[0][2].ToString();
// txtfeaah.Text = tbl.Rows[0][3].ToString();
// txtid.Text = tbl.Rows[0][0].ToString();
// txtDays.Text= tbl.Rows[0][6].ToString();
//}
}
}
string ConString = System.Configuration.ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ConnectionString;
public void getuserid()
{
User_id = 0;
try
{
SqlConnection conn = new SqlConnection(ConString);
string selectCmd = " SELECT [role_Id] FROM [fightGym].[dbo].[Roles] where Employee_Name='" + Properties.Settings.Default.USER_NAME + "' ";
// string da = "SELECT dbo.Tbl_eshtrackat.ID, dbo.Students.Student_Name, dbo.Tbl_eshtrackat.class_name, dbo.Tbl_eshtrackat.[From], dbo.Tbl_eshtrackat.[To], dbo.Tbl_eshtrackat.mount FROM dbo.Students INNER JOIN dbo.Tbl_eshtrackat ON dbo.Students.Student_Id = dbo.Tbl_eshtrackat.Student_id INNER JOIN dbo.Employees ON dbo.Tbl_eshtrackat.emp_id = dbo.Employees.Employee_Id where dbo.Tbl_eshtrackat.[From] between '" + date1 + "' and '" + date2 + "' ";
SqlCommand comandReader = new SqlCommand(selectCmd, conn);
conn.Open();
comandReader.ExecuteNonQuery();
// conn.Open();
DataTable dt = new DataTable();
SqlDataAdapter adapt = new SqlDataAdapter(comandReader);
adapt.Fill(dt);
User_id = Convert.ToInt16(dt.Rows[0][0].ToString());
// User_id = Convert.ToInt16(db.readData("select User_ID from Users where User_Name=N'" + Properties.Settings.Default.USER_NAME + "'", "").Rows[0][0]);
datecurrent = DateTime.Now.ToString("yyyy-MM-dd ");
}
catch { }
}
private void btnSave_Click(object sender, EventArgs e)
{
getuserid();
db.executeData(" update [dbo].[Set_fatrat] set [Senf] ='" + txtSenf.Text + "',[Ftrah] ='" + txtfatrah.Text + "' ,[Feaah]='" + txtfeaah.Text + "',user_id='" + User_id + "',Entertime ='" + datecurrent + "',Days ='" + txtDays.Text + "' where ID='" + txtid.Text + "')", "تم التعديل بنجاح");
}
private void simpleButton2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("هل انت متاكد من المسح ", "تأكيد", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (txtid.Text == "")
{
MessageBox.Show("لاتوجد بيانات");
}
else
{
getuserid();
db.executeData(" delete [dbo].[Set_fatrat] where ID='" + txtid.Text + "'", "تم المسح بنجاح");
}
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
getuserid();
db.executeData(" INSERT INTO [dbo].[Set_fatrat] ([Senf] ,[Ftrah] ,[Feaah],user_id,Entertime,Days) VALUES( '" + txtSenf.Text + "' ,'" + txtfatrah.Text + "' ,'" + txtfeaah.Text + "','" + User_id + "','" + datecurrent + "','" + txtDays.Text + "')", "تم الحفظ بنجاح");
GetSet();
}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 6)
{
getuserid();
db.executeData(" update [dbo].[Set_fatrat] set [Senf] ='" + dataGridView2.CurrentRow.Cells[4].Value + "',[Ftrah] ='" + dataGridView2.CurrentRow.Cells[3].Value + "' ,[Feaah]='" + dataGridView2.CurrentRow.Cells[2].Value + "',user_id='" + User_id + "',Entertime ='" + datecurrent + "',Days ='" + dataGridView2.CurrentRow.Cells[5].Value + "' where ID='" + dataGridView2.CurrentRow.Cells[1].Value + "'", "تم التعديل بنجاح");
}
if (e.ColumnIndex == 7)
{
if (MessageBox.Show("هل انت متاكد من المسح ", "تأكيد", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (dataGridView2.Rows.Count <= 0) { }
else
{
db.executeData("DELETE FROM [dbo].[Set_fatrat] WHERE [ID]='" + dataGridView2.CurrentRow.Cells[1].Value + "'", "تم الحذف بنجاح");
dataGridView2.Rows.RemoveAt(dataGridView2.CurrentRow.Index);
//GmNm();
}
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
}
}
}