Sei sulla pagina 1di 37

Pharmacy Management System

Documentation

Prepared by:
Safaa Shaaban Hasan
INTRODUCTION:
This project is insight into the design and implementation of a Pharmacy Management System. The
primary aim of is to improve accuracy and enhance safety and efficiency in the pharmaceutical store.
Today management is one of the most essential features of all form. Management provides
sophistication to perform any kind of task in a particular form. This is pharmacy management system; it
is used to manage most pharmacy related activities in the pharmacy.

The main aim of the project is the management of the database of the pharmay . This project is insight
into the design and implementation of a Pharmacy Management System. This is done by creating a
database of the available medicines in the shop. The primary aim of pharmacy management system is to
improve accuracy and enhance safety and efficiency in the pharmaceutical store.

. The database is then connected to the main program by using interconnection of the C# program and
the database already created. Pharmacy management system is useful to maintain correct database by
providing an option to update the drugs in stock. This is pharmacy management system; it is used to
manage most pharmacy related activities in the pharmacy.

Pharmacy management system is a management system that is designed to improve accuracy and to
enhance safety and efficiency in the pharmaceutical store. This program can be used in any
pharmaceutical shops having a database to maintain. It is a computer based system which helps the
Pharmacist to improve inventory management, cost, medical safety etc. The software used can generate
reports, as per the user’s requirements. Using this pharmacy management system user is also able to
generate report within a specified period of time. The system allows the user to enter a manufacturing
and expiry date for a particular product or drug during opening stock and sales transaction. The software
can print invoices, bills, receipts etc. It can also maintain the record of supplies sent in by the supplier.
The system will also give report showing the list of products expiry after a specified date before the
product eventually expires. The system services and goals are established by consultation with system
user. It also involves manual entry upon arrival of new batches of drugs and upon drug movement out of
the pharmacy for a certain period. Pharmacy management system is being build. Pharmacy
management system is robust, integrated technology. every month, the pharmacist may want to
generate report for the movement of drugs in and out of the pharmacy, getting information about the
drugs e.g. expiry date, date purchased, number of drug type left, location of a drug in the pharmacy.
Pharmacy management system deals with the maintenance of drugs and consumables in the pharmacy
unit. This pharmacy management system is user friendly.

Objectives of pharmacy management system project:


It is the user friendly application for Pharmacist which reduces the burden and helps to manage all
sections of Pharmacy like Medicine management and Billing etc., which improve the processing
efficiency.

It deals with the automating tasks of maintaining of Bills. In Pharmacy, Billing management is the key
process. In addition, Pharmacy management system will be able to process drug prescription with ease.

Including safe data store about medicine as well as fast searching, delete and update of medicines. The
pharmacy management system is built for the sake of ensuring effective and clear data saving and
manipulating as well as neat work on the pharmacy medical products. The pharmacy management
system is easy for use so the user can do pharmacy actions without ambiguities

his refers the pharmacy management system project highly minimize time and resource by which,
searching the medicine data you can get the data in quickest time. The main Objectives of the PMS is
making the pharmacy organizations computerized by creating neat work through minimizing or
eliminating wasting of time as well as removing the resources such as papers for data saving

At present, manual system is being utilized in the pharmacy. It requires the pharmacist to manually
monitor each drug that is available in the pharmacy. Pharmacy management has kept paper record in
filing cabinets. Managing a very large pharmacy with records on papers will be tedious and difficult to
keep track of inventories with regards to the drugs in the store, expiry date, quantity of drugs available
based on the categories and their functions. This implies that these services will be manually completed
by the pharmacist. This usually leads to mistakes as the workload of the pharmacist increases. This
system also ensures that there exists a level of restricted access based on functionality and role. This
system also provides optimal drug inventory management by monitoring the drug movement in the
pharmacy.

SYSTEM REQUIREMENT -

Hardware Requirements:
· Computer with either Intel Pentium processor or AMD processor.
· 128MB DDR RAM
· 40GB hard disk drive
Software Requirements:
· Windows 8.1 operating system.
· Microsoft Office package.
· Microsoft Visual Studio2013

Interface of Phramcy sytem:

First Login To System :

Enter User Name and Password and click ->Login


Fig. Login Screen
Fig. MAIN Menu
The above screen displays the option available under the Master menu.

The options are:

 Product Management
 Suppliers Management
 Users Management
 Purchase Management
 Sell Management
 Customer Management
 Exit

 When You select : Product Management


Fig. Transactions Menu

The above screen displays the options under the Transaction menu.

The options are:

 Add New Product


 Display All Product
 Update Product
 Show Product Image
 Show Expire Date
 Print All Product
 Print Selected Product
 Export In Excel
 Exit
Fig. ADD Product Interface

The Medical and General stores module basically deals with the information of medicine and general
store products. The minimum stock level can be set here as shown in above figure. The minimum stock
level will help the user to be warned when the stock level falls below the specified value.

In this module the product ID i.e. code for each section is automatically generated. This is done when
the user clicks on ADD NEW button.

The navigation buttons provided helps the user to navigate through the records. The option to edit,
delete and save are also given so that the user can modify the records. And you can add image of
product and to save click ok
Fig. Update Product Interface

The Edit Product Module is for checking whether the entries made were correct or not. . . The user can
then edit the particular record and then save it.

The user can search for particular record by entering the name of product or barcode
Fig. Delelte Product Interface
You delete the product click delete and system want to sure you want to delete it by click yes product
will deleted

Fig. Show Image Of Product Interface


You can show image avaible above of product.

Fig. Show Expire Date


Show the expire date of product .

Fig. Print All Product


Print all product .
Fig. Print Selected Product

Fig. Export Product To Excel


Fig. Supplier Mangment

Fig. Add New Supplier


The Supplier’s module deals with all the supplier’s information. This information will be used
when we want to check which company supplies what products. The basic information such as
address, telephone number, etc.
Whenever we add new supplier’s information by clicking on ADD NEW button the suppliers ID is
generated automatically.

The suppliers ID textbox is locked so that the user will not enter an invalid code.
Fig. Update New Supplier

Fig. Delete Supplier


Fig. Add Purchase

The Medicine Purchase module deals with the purchase of the medicine from the suppliers.
These medicines are then updated in the stock table.
In the above figure, user enters the supplier’s code and the supplier’s name automatically
is displayed.
Fig. select Supplier name for Purchase operation

Fig. select Product info for Purchase operation


Fig. sells operation
The Sales Module deals with the sales of products. Whether the product is of type Medicine or
General Store is dependent on the action selected.

When we click on ADD NEW button and then select customer then select product or pass the
barcodes and then enter QTY of product the click enter the QTY will multiply in sell price
Fig. sells operation(enter qty)
Fig. User Mangment
Fig. User Update Data
Fig. Delete User Mangment
Fig. Order Detalis

Fig. Customer Mangment

Customer Management you can add or upadate or delete or exit


Fig. Add New Custmoer

Add New customer enter info And click Add button.

Database structure
The tables used are as follows:
 Product – keeps Product information.
 Supplier – keeps Supplier information.
 Expire date – keeps date of product .
 Request – purchase register, which store information on purchase of goods for pharmacy.
 Request details: purchase details.
 Order – sales register, which store information on sales made.
 Order details: details of order
 Tblcatgories: product tblcatgories
 customer – keeps customer information.
 Users: – keeps customer information.
 Permission: permission of user
SAMPLE SOURCE CODE OF THE SYSTEM:
Add Product Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyFinal.BL;
using System.IO;
namespace MyFinal.PL
{
public partial class FRM_ADDNEWPRODUCT : Form
{
bool _ISUpdate;
public FRM_ADDNEWPRODUCT(bool ISUpdate)
{

InitializeComponent();
this._ISUpdate = ISUpdate;
DataTable DTCAT = class_product.SP_FILLCATCMB();
CMBCAT.DataSource = DTCAT;
CMBCAT.DisplayMember = "cat_name";
CMBCAT.ValueMember = "cat_id";
DataTable DTSN = class_product.SP_FILLSNCMB();
CMBSN.DataSource = DTSN;
CMBSN.DisplayMember = "sn_name";
CMBSN.ValueMember = "sn_id";

if (_ISUpdate == true)
{
this.Text = "Update the Product";
BTNADD.Text = "update";
DataTable dt =
class_product.SP_GETSELECTEDPRODUCT(FRM_PRODUCTMANAGMENT.ID);
foreach (DataRow dr in dt.Rows)
{
CMBCAT.Text = dr["cat_name"].ToString();
TXTPRODUCTNAME.Text = dr["p_name"].ToString();
TXTPRODUCTDESC.Text = dr["p_desp"].ToString();
TXTBUYPRICE.Text = dr["buyprice"].ToString();
TXTSELLPRICE.Text = dr["sellprice"].ToString();
txtlocation.Text = dr["location"].ToString();
CMBSN.Text = dr["sn_name"].ToString();
txtbarcode.Text = dr["barcodes"].ToString();
byte[] arr = (byte[])dr["p_image"];
MemoryStream ms = new MemoryStream(arr);
PICIMAGE.Image = Image.FromStream(ms);

}
else
{
this.Text = "Add New Product";
BTNADD.Text = "ADD";
}
}

private void BTNCHOOSE_Click(object sender, EventArgs e)


{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "ALL Files |*.*|JPG|*.jpg|PNG|*.png";
ofd.ShowDialog();
PICIMAGE.Image = Image.FromFile(ofd.FileName);
}

private void BTNADD_Click(object sender, EventArgs e)


{
if ( TXTPRODUCTNAME.Text == string.Empty)
{
MessageBox.Show("Product Must Be entry");
return;
}
else if (TXTBUYPRICE.Text == string.Empty)
{
MessageBox.Show("Must enterd price");
}
MemoryStream ms = new MemoryStream();
PICIMAGE.Image.Save(ms, PICIMAGE.Image.RawFormat);
byte[] arr = ms.ToArray();
if (_ISUpdate == false)
{
class_product.sp_ADDNEWSPRODUCTS(TXTPRODUCTNAME.Text,
TXTPRODUCTDESC.Text, arr, TXTBUYPRICE.Text, TXTSELLPRICE.Text,
(int)CMBCAT.SelectedValue, txtQTY.Text, (int)CMBSN.SelectedValue,
txtbarcode.Text, txtlocation.Text);

MessageBox.Show("Product Add Sucessfully ");


foreach (Control item in groupBox1.Controls)
{
if (item is TextBox)
item.Text = string.Empty;
}
}
else
{

class_product.SP_PPRODUCTSUPDATE(FRM_PRODUCTMANAGMENT.ID,
TXTPRODUCTNAME.Text, TXTPRODUCTDESC.Text, arr, TXTBUYPRICE.Text, TXTSELLPRICE.Text,
(int)CMBCAT.SelectedValue, txtQTY.Text, (int)CMBSN.SelectedValue,
txtbarcode.Text, txtlocation.Text);
MessageBox.Show("Updated susessfully ");

}
}

private void BTNCANEL_Click(object sender, EventArgs e)


{
this.Close();
}

ADD Purchase :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyFinal.PL
{
public partial class FRM_ADDNEWPURCH : Form
{
public FRM_ADDNEWPURCH()
{
InitializeComponent();
txtbuyername.Text = Program.UserFullName;

private void btnADDsipplier_Click(object sender, EventArgs e)


{
FRM_SEARCH frm = new FRM_SEARCH("Supplier");
frm.ShowDialog();
txtSU_ID.Text = frm.dataGridView1.CurrentRow.Cells[0].Value.ToString();
txtSU_NAME.Text = frm.dataGridView1.CurrentRow.Cells[1].Value.ToString();
txtSU_MOBILE.Text = frm.dataGridView1.CurrentRow.Cells[2].Value.ToString();

private void button2_Click(object sender, EventArgs e)


{
FRM_SEARCH frm = new FRM_SEARCH("Product");
frm.ShowDialog();
txtprodid.Text = frm.dataGridView1.CurrentRow.Cells[0].Value.ToString();
txtprodname.Text = frm.dataGridView1.CurrentRow.Cells[2].Value.ToString();
txtprodprice.Text = frm.dataGridView1.CurrentRow.Cells[5].Value.ToString();
}

private void txtprodqty_KeyPress(object sender, KeyPressEventArgs e)


{
char d =
char.Parse(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSe
parator);
if (!char.IsDigit(e.KeyChar) && e.KeyChar != 8 && e.KeyChar!=d)

e.Handled=true;

private void txtprodqty_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Enter)
{
if (txtprodid.Text == "")
{
MessageBox.Show("‫;)"الدواء اختيار يجب‬
return;
}
if (txtprodqty.Text == "" || double.Parse(txtprodqty.Text) <= 0)
{
MessageBox.Show("‫;)"الدواء كمية ادخال يجب‬

return;
}
for (int i = 0; i < gridproduct.Rows.Count; i++)
{
if (txtprodid.Text == gridproduct.Rows[i].Cells[0].Value.ToString())
{
MessageBox.Show("‫;)"موجود الدواء هذا‬

return;
}

}
string Data = "";
if (productexpiredata.Checked)
Data = productexpiredata.Text;
gridproduct.Rows.Add(txtprodid.Text, txtprodname.Text, Data,
txtprodprice.Text, txtprodqty.Text);
txtprodid.Text = txtprodname.Text = txtprodprice.Text = txtprodqty.Text =
"";
btndelete.Enabled = true;
calc();
}
}

private void btndelete_Click(object sender, EventArgs e)


{
gridproduct.Rows.Remove(gridproduct.CurrentRow);
calc();
}

private void gridproduct_CellDoubleClick(object sender, DataGridViewCellEventArgs


e)
{
txtprodid.Text = gridproduct.CurrentRow.Cells[0].Value.ToString();
txtprodname.Text = gridproduct.CurrentRow.Cells[1].Value.ToString();
if (gridproduct.CurrentRow.Cells[0].Value.ToString() == "")

productexpiredata.Checked = false;
else
productexpiredata.Text=gridproduct.CurrentRow.Cells[2].Value.ToString();
txtprodprice.Text = gridproduct.CurrentRow.Cells[3].Value.ToString();
txtprodqty.Text = gridproduct.CurrentRow.Cells[4].Value.ToString();
btndelete_Click(null, null);

void calc()
{
double total = 0;
for (int i = 0; i < gridproduct.Rows.Count; i++)
{
total += double.Parse(gridproduct.Rows[i].Cells[3].Value.ToString()) *
double.Parse(gridproduct.Rows[i].Cells[4].Value.ToString());
}
txtreqtotal.Text = total.ToString();
}

}
}

Login Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyFinal.BL;

namespace MyFinal.PL
{
public partial class FRM_LOGIN : Form
{
public FRM_LOGIN()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

if (txtname.Text == string.Empty)
{
MessageBox.Show("‫;)"المستخدم اسم ادخال يجب‬
return;
}
if (txtpass.Text == string.Empty)
{
MessageBox.Show("‫;)"المرور كلمه ادخال يجب‬
return;
}
DataTable dt = class_login.Splogin(txtname.Text, txtpass.Text);
if (dt.Rows.Count > 0)
{
/* FRM_MAIN.Check = true;
Program.UserFullName = dt.Rows[0]["UserFullName"].ToString();*/
this.Hide();
FRM_MAIN frm = new FRM_MAIN();
frm.ShowDialog();
}
else
MessageBox.Show("‫;)"خطأ المرور كلمه او المستخدم اسم‬
}

private void cancell_Click(object sender, EventArgs e)


{
this.Close();
}
}
}

Add New sells :


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyFinal.BL;
using MyFinal.DAL;
namespace MyFinal.PL
{
public partial class FRM_ADD_NEWSELLS : Form
{
public FRM_ADD_NEWSELLS()
{
InitializeComponent();
txtSellerName.Text = Program.UserFullName;
}

private void btnADDcustomer_Click(object sender, EventArgs e)


{
FRM_SEARCH frm = new FRM_SEARCH("Customer");
frm.ShowDialog();
txtCu_ID.Text = frm.dataGridView1.CurrentRow.Cells[0].Value.ToString();
txtCu_Name.Text = frm.dataGridView1.CurrentRow.Cells[1].Value.ToString();
txtCu_Mobile.Text = frm.dataGridView1.CurrentRow.Cells[2].Value.ToString();

private void btnNewSells_Click(object sender, EventArgs e)


{
btnADDcustomer.Enabled = btnAddProduct.Enabled = true;
btnNewSells.Enabled = false;
txtCu_ID.Text = txtCu_Mobile.Text = txtCu_Name.Text = txtProdID.Text =
txtProdName.Text = txtProdPrice.Text = TotalQty.Text = txtOrederTotal.Text = "";
gridproduct.Rows.Clear();
}
//float TotalyQty;
//float TotalQty;
float TotalQtys;
private void btnAddProduct_Click(object sender, EventArgs e)
{
FRM_SEARCH frm = new FRM_SEARCH("Product");
frm.ShowDialog();
txtProdID.Text = frm.dataGridView1.CurrentRow.Cells[0].Value.ToString();
txtProdName.Text = frm.dataGridView1.CurrentRow.Cells[2].Value.ToString();
txtProdPrice.Text = frm.dataGridView1.CurrentRow.Cells[6].Value.ToString();
TotalQtys =
float.Parse(frm.dataGridView1.CurrentRow.Cells[7].Value.ToString());

private void TotalQty_KeyPress(object sender, KeyPressEventArgs e)


{
char d =
char.Parse(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSe
parator);
if (!char.IsDigit(e.KeyChar) && e.KeyChar != d)
{
e.Handled = true;
}
}

private void TotalQty_KeyDown(object sender, KeyEventArgs e)


{

if (e.KeyCode == Keys.Enter)
{
if (txtProdID.Text == "")
{
MessageBox.Show("Must select Product");
return;

}
if (TotalQty.Text == "" || float.Parse(TotalQty.Text) <= 0)
{
MessageBox.Show("Qty Enter And in Postivte");
return;
}
if (float.Parse(TotalQty.Text) > TotalQtys)
{
MessageBox.Show(" Quantity Not Enough");
return;
}
for (int i = 0; i < gridproduct.Rows.Count; i++)
{
if (txtProdID.Text == gridproduct.Rows[i].Cells[0].Value.ToString())
{
MessageBox.Show("This product is founded!!");
return;
}
}
gridproduct.Rows.Add(txtProdID.Text, txtProdName.Text, txtProdPrice.Text,
TotalQty.Text);
btndelete.Enabled = true;
TotalQty.Text = txtProdPrice.Text = txtProdName.Text = txtProdID.Text =
"";
CalcOrderTotal();
btnSave.Enabled = true;
}
}
void CalcOrderTotal()
{
float total = 0;
for (int i = 0; i < gridproduct.Rows.Count; i++)
{
total += float.Parse(gridproduct.Rows[i].Cells[2].Value.ToString()) *
float.Parse(gridproduct.Rows[i].Cells[3].Value.ToString());
}

txtOrederTotal.Text = total.ToString();
}

private void btndelete_Click(object sender, EventArgs e)


{
gridproduct.Rows.Remove(gridproduct.CurrentRow);
CalcOrderTotal();
}

private void gridproduct_CellDoubleClick(object sender, DataGridViewCellEventArgs


e)
{

txtProdID.Text = gridproduct.CurrentRow.Cells[0].Value.ToString();
txtProdName.Text = gridproduct.CurrentRow.Cells[1].Value.ToString();
txtProdPrice.Text = gridproduct.CurrentRow.Cells[2].Value.ToString();
TotalQty.Text = gridproduct.CurrentRow.Cells[3].Value.ToString();
btndelete_Click(null, null);
}

private void btnSave_Click(object sender, EventArgs e)


{
try
{
DataTable OrderDet = new DataTable();
OrderDet.Columns.Add("p_id");
OrderDet.Columns.Add("qty");
OrderDet.Columns.Add("p_price");

for (int i = 0; i < gridproduct.Rows.Count; i++)


{
OrderDet.Rows.Add(gridproduct.Rows[i].Cells[0].Value,
gridproduct.Rows[i].Cells[3].Value,
gridproduct.Rows[i].Cells[2].Value);
}
CLASS_ORDER.sp_order_inserts2(OrderDate.Value, txtOrederTotal.Text,
int.Parse(txtCu_ID.Text),
txtSellerName.Text, OrderDet);
MessageBox.Show("success");

btnPrint.Enabled = btnNewSells.Enabled = true;


btnSave.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void btnPrint_Click(object sender, EventArgs e)


{
int order_id = CLASS_ORDER.Max_order_ID();
RPT.FRM_REP frm = new RPT.FRM_REP();
RPT.CrystalReport2 rpt = new RPT.CrystalReport2();
rpt.SetParameterValue("@Order_ID", order_id);
frm.crystalReportViewer1.ReportSource = rpt;
frm.ShowDialog();
}

private void txtSellerName_TextChanged(object sender, EventArgs e)


{

private void textBox1_KeyDown(object sender, KeyEventArgs e)


{

private void txtbarcode_TextChanged(object sender, EventArgs e)


{

private void txtbarcode_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyData == Keys.Enter)
{
if (txtbarcode.Text != "")
{
DataTable dt =
CLASS_ORDER.sp_get_product_by_barcode(txtbarcode.Text);

foreach (DataRow dr in dt.Rows)


{
txtProdID.Text = dr[0].ToString();
txtProdName.Text = dr[1].ToString();
txtProdPrice.Text = dr[2].ToString();

}
txtbarcode.Text = "";
}
}

private void button7_Click(object sender, EventArgs e)


{
this.Close();
}

}
}

Supplier Management:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyFinal.BL;
namespace MyFinal.PL
{
public partial class FRM_SUPPLIERMANGMENT : Form
{
public FRM_SUPPLIERMANGMENT()
{
InitializeComponent();
BTNDISPLAY_Click(null, null);
}

private void btnADD_Click(object sender, EventArgs e)


{
new FRM_SUPPLIER(true).ShowDialog();
}
public static int ID;

private void btnUPDATE_Click(object sender, EventArgs e)


{
ID = int.Parse(DGVDUPPLIERS.SelectedRows[0].Cells[0].Value.ToString());

new FRM_SUPPLIER(false).ShowDialog();
}

private void BTNDELETE_Click(object sender, EventArgs e)


{
ID = int.Parse(DGVDUPPLIERS.SelectedRows[0].Cells[0].Value.ToString());
DialogResult DR = MessageBox.Show("Are You Sure To Delelte ?", "Warring!!",
MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
if (DR == System.Windows.Forms.DialogResult.Yes)
{
CLASS_SUPPLIER.SP_SUPPLIERDELETE(ID);

MessageBox.Show("Delete SucessFully");
}
}

private void DGVDUPPLIERS_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{
DataTable DT = CLASS_SUPPLIER.SP_SUPPLIESSELECT();
DGVDUPPLIERS.DataSource = DT;
}

private void BTNDISPLAY_Click(object sender, EventArgs e)


{
DataTable DT = CLASS_SUPPLIER.SP_SUPPLIESSELECT();
DGVDUPPLIERS.DataSource = DT;
}

private void TXTSEARCH_TextChanged(object sender, EventArgs e)


{
DataTable DT = CLASS_SUPPLIER.SP_SUPPLIERSEAHRCH(TXTSEARCH.Text);
DGVDUPPLIERS.DataSource = DT;

}
}

Add New User:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyFinal.BL;
namespace MyFinal.PL
{
public partial class FRM_ADD_NEW_USER : Form

{
bool IsUpdate;
public FRM_ADD_NEW_USER(bool _IsUpdate)
{
InitializeComponent();
this.IsUpdate = _IsUpdate;
comboBox1.DataSource = CLASS_USER.sp_Permission();
comboBox1.DisplayMember = "Per_name";
comboBox1.ValueMember = "Per_id";
if (IsUpdate)
{
this.Text = "‫;"المستخدم بيانات تعديل‬
btn_adduser.Text = "‫;"تعديل‬

txt_U_name.Text = USER_MANGMENT.row.Cells[1].Value.ToString();
txt_U_password.Text = txt_U_check_password.Text =
USER_MANGMENT.row.Cells[2].Value.ToString();
txt_U_fullname.Text = USER_MANGMENT.row.Cells[3].Value.ToString();
comboBox1.Text = USER_MANGMENT.row.Cells[4].Value.ToString();

}
else
{
this.Text = "‫;"المستخدم بيانات اضافه‬
btn_adduser.Text = "‫;"اضافه‬
}

private void btn_adduser_Click(object sender, EventArgs e)


{
try
{
if (txt_U_name.Text == "")
{
MessageBox.Show("‫;)"المستخدم اسم ادخال يجب‬
return;
}
else if (txt_U_password.Text == "")
{
MessageBox.Show("‫;)"المرور كلمة ادخال يجب‬
return;

}
else if (txt_U_check_password.Text != txt_U_password.Text)
{
MessageBox.Show("‫;)"متطابقه غير المرور كلمة‬
return;

}
else if (txt_U_fullname.Text == "")
{
MessageBox.Show("‫;)"بالكامل االسم ادخال يجب‬
return;

if (IsUpdate)
{
CLASS_USER.sp_user_update(int.Parse(USER_MANGMENT.row.Cells[0].Value.ToString()),
txt_U_name.Text, txt_U_password.Text, txt_U_fullname.Text,
int.Parse(comboBox1.SelectedValue.ToString()));
MessageBox.Show("‫;)"بنجاح التعديل تم‬
}
else
{
CLASS_USER.sp_users_insert(txt_U_name.Text, txt_U_password.Text,
txt_U_fullname.Text,
int.Parse(comboBox1.SelectedValue.ToString()));
MessageBox.Show("‫;)"بنجاح االضافه تم‬
foreach (Control ctr in groupBox1.Controls)
{
if (ctr is TextBox)
ctr.Text = "";

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

}
}
‫تم بحمــــــــــــــــــــــــــــــــــد هللا‬

Potrebbero piacerti anche