You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.0 KiB
91 lines
3.0 KiB
3 months ago
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using Point_Of_Sale_Managment;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Drawing;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace BiskLog_Point_Of_Sale.Company_Setup
|
||
|
{
|
||
|
public partial class SelectBranch : Form
|
||
|
{
|
||
|
SqlConnection cn;
|
||
|
SqlCommand cm;
|
||
|
SqlDataReader dr;
|
||
|
DatabaseConn conn = new DatabaseConn();
|
||
|
public SelectBranch()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
cn = new SqlConnection(conn.MyConnection());
|
||
|
}
|
||
|
|
||
|
private async void SelectBranch_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
Task<int> task = new Task<int>(() =>
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
cn.Open();
|
||
|
cm = new SqlCommand("Select branchID,branchName,city,branch_telephone from tblBranches", cn);
|
||
|
dr = cm.ExecuteReader();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
BranchDetails branch = new BranchDetails();
|
||
|
branch.branchID = dr[0].ToString();
|
||
|
branch.Text = dr[1].ToString();
|
||
|
branch.branchCity = dr[2].ToString();
|
||
|
branch.branchTelephone = dr[3].ToString();
|
||
|
branches.Invoke(new Action(() =>
|
||
|
{
|
||
|
branches.Items.Add(branch);
|
||
|
}));
|
||
|
}
|
||
|
dr.Close();
|
||
|
cn.Close();
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
cn.Close();
|
||
|
}
|
||
|
return 1;
|
||
|
});
|
||
|
btnSave.Visible = false;
|
||
|
loading.Visible = true;
|
||
|
task.Start();
|
||
|
await task;
|
||
|
loading.Visible = false;
|
||
|
btnSave.Visible = true;
|
||
|
}
|
||
|
|
||
|
private void Branches_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (!String.IsNullOrEmpty(branches.Text))
|
||
|
{
|
||
|
btnSave.Enabled = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
btnSave.Enabled = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void BtnSave_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
Settings.Default.BranchID = (branches.SelectedItem as BranchDetails).branchID.ToString();
|
||
|
Settings.Default.BranchName = (branches.SelectedItem as BranchDetails).Text.ToString();
|
||
|
Settings.Default.BranchTelephone = (branches.SelectedItem as BranchDetails).branchTelephone.ToString();
|
||
|
Settings.Default.BranchCity = (branches.SelectedItem as BranchDetails).branchCity.ToString();
|
||
|
Settings.Default.Configured = true;
|
||
|
Settings.Default.CompanyName = DatabaseLocation.company;
|
||
|
Settings.Default.Save();
|
||
|
this.Close();
|
||
|
}
|
||
|
}
|
||
|
}
|