Beispiel #1
0
 private void DeleteClientGridButton_Click(object sender, RoutedEventArgs e)
 {
     if (mangaclientgrid.SelectedItems.Count != 1)
     {
         MessageBox.Show("Please select 1 client to delete", "Error");
         return;
     }
     if (MessageBox.Show("Are you sure you want to delete this client?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         Client client = (Client)mangaclientgrid.SelectedItem;
         client = db.Clients.SingleOrDefault(x => x.CLCODE == client.CLCODE);
         if (client == null)
         {
             MessageBox.Show("This client does not exists.", "Error");
             return;
         }
         if (client.CLCODE == "<NONE>" || client.CLCODE == "<DTDC>")
         {
             MessageBox.Show("This client cannot be deleted");
             return;
         }
         db.Clients.DeleteOnSubmit(client);
         try
         {
             db.SubmitChanges();
             MessageBox.Show("Client deleted.", "Success");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Deletion failed with error : " + ex.Message, "Failure");
         }
         DataSources.refreshClientList();
         ReloadClientGridButton_Click(null, null);
     }
 }
Beispiel #2
0
 private void ReloadClientGridButton_Click(object sender, RoutedEventArgs e)
 {
     DataSources.refreshClientList();
     clients           = DataSources.ClientCopy;
     viewsource        = (CollectionViewSource)FindResource("ClienTable");
     viewsource.Source = clients;
 }
Beispiel #3
0
        public void add()
        {
            string errorMsg = validate();

            if (errorMsg == "")
            {
                client           = new Client();
                client.CLNAME    = ClientName.Text;
                client.Status    = 'A';
                client.ADDRESS   = ClientAddress.Text;
                client.CONTACTNO = ClientPhoneNo.Text;
                client.EMAILID   = CLientEmailAddress.Text;
                client.CLCODE    = ClientCode.Text;
                client.FUEL      = float.Parse(ClientFuel.Text);
                client.INTRODATE = DateTime.Now;
                client.STAX      = float.Parse(ServiceTax.Text);
                client.AMTDISC   = float.Parse(DiscountBox.Text);

                db.Clients.InsertOnSubmit(client);
                try
                {
                    db.SubmitChanges();
                    DataSources.refreshClientList();
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); return; }
                this.Close();
            }
            else
            {
                MessageBox.Show("Please correct following errors: " + errorMsg);
            }
        }
Beispiel #4
0
        public void setDataSource(Filter filterObj, IEnumerable <string> ConnNo)
        {
            InitializeComponent();
            this.filterObj = filterObj;
            BillingDataDataContext db = new BillingDataDataContext();

            StartConnNoList = (CollectionViewSource)FindResource("StartConnNoList");
            List <String> ConnNoList = ConnNo.OrderBy(x => x).ToList();

            StartConnNoList.Source = ConnNoList;
            EndConnoList           = (CollectionViewSource)FindResource("EndConnoList");
            EndConnoList.Source    = ConnNoList;
            DataSources.refreshClientList();
            List <Client> fClientList = DataSources.ClientCopy;

            SelectClientBox.AllListSource      = fClientList.Where(x => !filterObj.selectedClientList.Select(y => y.CLCODE).Contains(x.CLCODE)).ToList();
            SelectClientBox.SelectedListSource = filterObj.selectedClientList;
            SelectClientBox.DisplayValuePath   = "NameAndCode";
            switch (filterObj.showBilled)
            {
            case true:
            {
                BilledRadio.IsChecked = true;
                break;
            }

            case false:
            {
                UnBilledRadio.IsChecked = true;
                break;
            }

            case null:
            {
                AllRadio.IsChecked = true;
                break;
            }
            }
            if (filterObj.startConnNo != "" && ConnNo.Contains(filterObj.startConnNo))
            {
                StartConnNo.Text = filterObj.startConnNo;
            }
            else
            {
                StartConnNo.Text = ConnNo.FirstOrDefault() ?? "";
            }
            if (filterObj.endConnNo != "" && ConnNo.Contains(filterObj.endConnNo))
            {
                EndConnNo.Text = filterObj.endConnNo;
            }
            else
            {
                EndConnNo.Text = ConnNo.LastOrDefault() ?? "";
            }
            ToDate.SelectedDate   = filterObj.toDate;
            FromDate.SelectedDate = filterObj.fromDate;
            StartPriceValue.Text  = filterObj.startPrice.ToString();
            EndPriceValue.Text    = filterObj.endPrice.ToString();
            StartWeightValue.Text = filterObj.startWeight.ToString();
            EndWeightValue.Text   = filterObj.endWeight.ToString();
        }
Beispiel #5
0
 private void AddClient_close(object sender, EventArgs e)
 {
     DataSources.refreshClientList();
     clientViewSource.Source = DataSources.ClientCopy;
     ClientCombo.Items.Refresh();
 }