اسم الملف | لينك |
---|---|
تعلم لغة c sharp من البداية الى الاحتراف مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98xzr_x2vafMGx9_gCIkZhM6 |
كورس Object-oriented programming C Sharp مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98yRqBvoBB2Wi3mNro5DDdOL |
Database Analysis and design Full course - ERD schema مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98zl-h_NvnQAs8BW8QRMIw-P |
تعلم باحتراف MS SQL server 2019 مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98zuTzQXSZYomkE-RLntASLB |
كورس Windows Desktop Applications in c sharp مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98yVy2t1hE3t4t1zKAxAvpkW |
مهنس بديع موسى راجى dbase in c sharp سى شارب و قواعد البيانات ِADO.NET مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98y_tlKzFvxJXLY_2VHlzdz6 |
مهنس بديع موسى راجى dbase in c sharp سى شارب و قواعد البيانات ِ LINQ.NET مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98yLGrgsN5WdmMQGzzyU4E_Y |
Entity Framework and C Sharp كورس مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98wyhsQuDejKvsfdVtVf_Uef |
مشروع المبيعات سوبر ماركت وصيدليات سى شارب و Entity Framework مهندس بديع موسى راجى | https://www.youtube.com/playlist?list=PLMmy9Ec9B98wtu-NuSF_mWk90DxuyY5ax |
001 مشروع المبيعات باحتراف Entity Framework مهندس بديع موسى راجى | https://youtu.be/Z2osNeyZCNY |
002 C Sharp AND DevExpress BarManager | https://youtu.be/ikj8GNJMDIQ |
003 C sharp AND DevExpress LayOut Control TextEdit | https://youtu.be/Hdyk2FArx-M |
004 CSharp AND DevExpress GetData SaveData in DBase EF | https://youtu.be/19yfwP7mUI0 |
13 | 13 |
using DevExpress.XtraEditors;
using ex001.db;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ex001
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
POSTutEntities db = new POSTutEntities();
string imagePath = "";
int i;
Customer cust;
public Form1()
{
InitializeComponent();
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e)
{
GetData();
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
Save();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F1)
{
Save();
}
}
void Save()
{
// in case of no data
if (cust==null)
{
cust = new Customer();
db.Customers.Add(cust);
db.SaveChanges();
}
cust.Name = txtName.Text;
if (txtName.Text.Trim() == string.Empty)
{
txtName.ErrorText = "Plz enter Name of Customer";
return;
}
cust.Address = txtAddress.Text;
cust.Notes = txtNotes.Text;
cust.Phone = txtPhone.Text;
cust.Company = txtCompany.Text;
cust.Email = txtEmail.Text;
cust.IsActive = isActive.Checked;
if (imagePath != "")
{
// string destPath = Environment.CurrentDirectory + "\\images\\products\\" + p.Id + ".jpg";
string destPath = "images\\Customers\\" + cust.id + ".jpg";
File.Copy(imagePath, destPath, true);
cust.Image = destPath;
}
db.SaveChanges();
XtraMessageBox.Show("Done Successfully");
// cust.Image= pictureBox1.ImageLocation ;
}
void GetData()
{
Customer cust = db.Customers.FirstOrDefault(); // first get error in no data
if (cust == null) return; // in case of no data
txtName.Text = cust.Name;
txtAddress.Text = cust.Address;
txtNotes.Text = cust.Notes;
txtPhone.Text = cust.Phone;
txtCompany.Text = cust.Company;
txtEmail.Text = cust.Email;
isActive.Checked = (bool)cust.IsActive;
pictureBox1.ImageLocation = cust.Image;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
imagePath = dialog.FileName;
pictureBox1.ImageLocation = dialog.FileName;
}
}
}
}