private void FetchButton_Click(object sender, RoutedEventArgs e)
        {
            string errorMsg = "";
            CollectionViewSource   dataGridSource = (CollectionViewSource)FindResource("PaymentDetailsSourceGrid");
            CollectionViewSource   invoiceSource  = (CollectionViewSource)FindResource("InvoiceDetailsSourceGrid");
            BillingDataDataContext db             = new BillingDataDataContext();

            if (FromDatepicker.SelectedDate == null)
            {
                errorMsg += "Select From Date. \n";
            }
            if (ToDatePicker.SelectedDate == null)
            {
                errorMsg += "Select To Date. \n";
            }
            if (errorMsg == "")
            {
                EntryList = db.PaymentEntries.Where(x => x.Date >= (DateTime)FromDatepicker.SelectedDate && x.Date <= (DateTime)ToDatePicker.SelectedDate &&
                                                    x.ClientCode == ((Client)ClientComboBox.SelectedItem).CLCODE).ToList();
                dataGridSource.Source = EntryList;
                InvoiceLists          = db.Invoices.Where(x =>
                                                          x.Date >= (DateTime)FromDatepicker.SelectedDate && x.Date <= (DateTime)ToDatePicker.SelectedDate &&
                                                          x.ClientCode == ((Client)ClientComboBox.SelectedItem).CLCODE).ToList();
                invoiceSource.Source = InvoiceLists;
            }
            else
            {
                MessageBox.Show("Please correct the following errors: \n" + errorMsg);
            }
        }
Пример #2
0
        private void DeleteCityButton_Click(object sender, RoutedEventArgs e)
        {
            if (CityDataGrid.SelectedItems.Count != 1)
            {
                MessageBox.Show("Select 1 city to delete");
                return;
            }
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this city?", "Confirm", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                if (db == null)
                {
                    db = new BillingDataDataContext();
                }
                City city = db.Cities.SingleOrDefault(x => x.CITY_CODE == ((City)CityDataGrid.SelectedItem).CITY_CODE);
                if (city == null)
                {
                    MessageBox.Show("No such city exists.");
                    return;
                }
                db.Cities.DeleteOnSubmit(city);
                db.SubmitChanges();
            }
            ReloadCityButton_Click(null, null);
        }
Пример #3
0
        public void update()
        {
            string errorMsg = validate();

            if (errorMsg == "")
            {
                var db   = new BillingDataDataContext();
                var data = db.Clients.Single(x => x.CLCODE == client.CLCODE);
                data.CLNAME    = ClientName.Text ?? "";
                data.ADDRESS   = ClientAddress.Text ?? "";
                data.EMAILID   = CLientEmailAddress.Text ?? "";
                data.CONTACTNO = ClientPhoneNo.Text ?? "";
                data.FUEL      = double.Parse(ClientFuel.Text ?? "");
                data.STAX      = double.Parse(ServiceTax.Text);
                data.AMTDISC   = double.Parse(DiscountBox.Text);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); return; }
                this.Close();
            }
            else
            {
                MessageBox.Show("Please correct following errors: " + errorMsg);
            }
        }
Пример #4
0
        private void ExecuteSanitizingCommand(object sender, ExecutedRoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            if (dataGridHelper.currentDataSheet == null)
            {
                int key = dataGridHelper.addNewSheet(new List <RuntimeData>(), "");
                addingNewPage(key);
            }
            SanitizingWindow window;
            RuntimeData      dataToSend = null;

            if (dataGrid.SelectedItem != null)
            {
                dataToSend = (RuntimeData)dataGrid.SelectedItem;
            }

            concatinateAllRecordsInOnePage();
            Dictionary <string, List <string> > SubClientList = new Dictionary <string, List <string> >();
            List <RuntimeData> data    = dataGridHelper.getCurrentDataStack;
            List <string>      clients = data.Select(x => x.CustCode).Distinct().ToList();

            clients.ForEach(x =>
            {
                List <string> subClients = data.Where(y => y.CustCode == x).Select(z => z.SubClient).Distinct().ToList();
                SubClientList.Add(x, subClients);
            });
            List <string> ConsigneeList = data.Select(x => x.ConsigneeName).Distinct().ToList();
            List <string> ConsignerList = data.Select(x => x.ConsignerName).Distinct().ToList();

            window = new SanitizingWindow(dataGridHelper.getCurrentDataStack, db, dataGridHelper.currentSheetNumber, dataGrid, dataGridHelper, SubClientList, ConsigneeList, ConsignerList, dataToSend);

            window.Closed += SanitizingWindow_Closed;
            window.Show();
        }
Пример #5
0
        private void DeleteRule_Click(object sender, RoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            if (CostingRuleGrid.Visibility == Visibility.Visible && CostingRuleGrid.SelectedItems != null)
            {
                if (MessageBox.Show("Do you want delete " + CostingRuleGrid.SelectedItems.Count.ToString() + " Rule", "Confirm", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    List <CostingRule> dcr = CostingRuleGrid.SelectedItems.Cast <CostingRule>().ToList();
                    CostingRuleGrid.SelectedItem = null;
                    List <int>  Ids = dcr.Select(x => x.Id).ToList();
                    List <Rule> dr  = db.Rules.Where(x => Ids.Contains(x.ID)).ToList();
                    db.Rules.DeleteAllOnSubmit(dr);
                }
            }
            if (ServiceRuleGrid.Visibility == Visibility.Visible && ServiceRuleGrid.SelectedItems != null)
            {
                if (MessageBox.Show("Do you want delete " + ServiceRuleGrid.SelectedItems.Count.ToString() + " Rule", "Confirm", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    List <ServiceRule> dcr = ServiceRuleGrid.SelectedItems.Cast <ServiceRule>().ToList();
                    ServiceRuleGrid.SelectedItem = null;
                    List <int>  Ids = dcr.Select(x => x.Id).ToList();
                    List <Rule> dr  = db.Rules.Where(x => Ids.Contains(x.ID)).ToList();
                    db.Rules.DeleteAllOnSubmit(dr);
                }
            }
            db.SubmitChanges();
            LoadClientRules();
            this.CostingRuleGrid.Items.Refresh();
            this.ServiceRuleGrid.Items.Refresh();
        }
Пример #6
0
        private void EditRule_Click(object sender, RoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            if (CostingRuleGrid.Visibility == Visibility.Visible && CostingRuleGrid.SelectedItem != null)
            {
                if (MessageBox.Show("Do you Want edit this Rule", "", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    CostingRule dcr = (CostingRule)CostingRuleGrid.SelectedItem;
                    AddRule     win = new AddRule(dcr.Id);
                    win.Closed += win_Closed;
                    win.Show();
                    CostingRuleGrid.SelectedItem = null;
                }
            }
            if (ServiceRuleGrid.Visibility == Visibility.Visible && ServiceRuleGrid.SelectedItem != null)
            {
                if (MessageBox.Show("Do you Want edit this Rule", "", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    ServiceRule    dcr = (ServiceRule)ServiceRuleGrid.SelectedItem;
                    AddServiceRule win = new AddServiceRule(dcr.Id);
                    win.Closed += win_Closed;
                    win.Show();
                    ServiceRuleGrid.SelectedItem = null;
                }
            }
            db.SubmitChanges();
        }
Пример #7
0
        public static bool authenticate(string userName, string Password)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            permisstionList    = db.Permissions.ToList();
            userpermissionList = new List <Permission>();

            if (db.Employees.Where(x => x.UserName == userName && x.Password == Password).AsEnumerable().Where(y => y.UserName == userName && y.Password == Password && y.Status == 'A').Count() == 1)
            {
                employee           = db.Employees.Where(x => x.UserName == userName).FirstOrDefault();
                _currentUser       = employee.UserName;
                userpermissionList = employee.User_permissions.Select(x => x.Permission).ToList();
                if (userName == Configs.Default.SuperUser)
                {
                    isSuper = true;
                }
                else
                {
                    isSuper = false;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void DeleteEmployeeGrid_Click(object sender, RoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            if (mangaEmployeegrid.SelectedItem != null)
            {
                if (((Employee)mangaEmployeegrid.SelectedItem).UserName != Configs.Default.SuperUser)
                {
                    var emp = db.Employees.Where(x => x.Id == ((Employee)mangaEmployeegrid.SelectedItem).Id).FirstOrDefault();
                    emp.Status = 'D';
                    try
                    {
                        db.SubmitChanges();
                        reloadgrid(null, null);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Super User cannot be deleted");
                }
            }
        }
Пример #9
0
        static public List <RuntimeData> loadDataFromDatabase(DateTime startDate, DateTime endDate, int sheetNo)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            db.sp_LoadToRuntimeFromDate(SecurityModule.currentUserName, sheetNo, endDate, startDate);
            return(db.RuntimeDatas.Where(x => x.SheetNo == sheetNo && x.UserId == SecurityModule.currentUserName).OrderBy(y => y.ConsignmentNo).ToList());
        }
 private void DeleteInvoiceButton_Click(object sender, RoutedEventArgs e)
 {
     if (InvoiceDatagrid.SelectedItems.Count != 1)
     {
         MessageBox.Show("Please select 1 invoice to delete", "Message");
         return;
     }
     if (MessageBox.Show("Are you sure you want to delete this invoice?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         BillingDataDataContext db = new BillingDataDataContext();
         Invoice invoice           = db.Invoices.SingleOrDefault(x => x.BillId == ((Invoice)InvoiceDatagrid.SelectedItem).BillId);
         if (invoice == null)
         {
             MessageBox.Show("This invoice doesn't exists or has already been deleted..", "Error");
             return;
         }
         db.Invoices.DeleteOnSubmit(invoice);
         try
         {
             db.SubmitChanges();
             MessageBox.Show("Invoice successfully deleted. Click on fetch button to view the changes.", "Success");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error in deleting invoice. Error Message: " + ex.Message, "Error");
         }
     }
 }
Пример #11
0
        private void clientCode_LostFocus(object sender, RoutedEventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();
            Client cle = (Client)this.clientCode.SelectedItem;

            this.SubClientTextBox.ItemsSource = db.Transactions.Where(y => y.CustCode == cle.CLCODE).Select(x => x.SubClient).Distinct().ToList();
        }
Пример #12
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Func <Transaction, bool> whereQuery = (Func <Transaction, bool>)e.Argument;

            worker.ReportProgress(1);
            BillingDataDataContext db = new BillingDataDataContext();

            List <Transaction> transactions = db.Transactions.Where(whereQuery).ToList();
            double             transCount   = transactions.Count;

            double i = 0;

            foreach (Transaction trans in transactions)
            {
                if (trans.ConnsignmentNo == "X10477603")
                {
                    Debug.WriteLine("ABC");
                }
                trans.AmountCharged = (decimal)UtilityClass.getCost(trans.CustCode, trans.BilledWeight ?? 0, trans.Destination, trans.Type.Trim(), trans.DOX);
                if (trans.Insurance != null)
                {
                    trans.AmountCharged = trans.AmountCharged + (decimal)trans.Insurance;
                }

                worker.ReportProgress((int)((i / transCount) * 94 + 1));
                i++;
            }
            ChangeSet changeSet = db.GetChangeSet();

            db.SubmitChanges();
            worker.ReportProgress(100);
            e.Result = "Completed for " + ((int)transCount).ToString() + " transactions";
        }
Пример #13
0
        private void AddClient_close(object sender, EventArgs e)
        {
            BillingDataDataContext db = new BillingDataDataContext();
            var clients = DataSources.ClientCopy;

            viewsource        = (CollectionViewSource)FindResource("ClienTable");
            viewsource.Source = clients;
        }
        public ZoneAssignment()
        {
            this.InitializeComponent();
            ZoneTableSource = (CollectionViewSource)FindResource("zoneTable");
            BillingDataDataContext db = new BillingDataDataContext();

            ZoneTableSource.Source = db.ZONEs;
        }
Пример #15
0
        public AccountStatementFullWindow()
        {
            InitializeComponent();
            BillingDataDataContext db = new BillingDataDataContext();

            rs      = new Microsoft.Reporting.WinForms.ReportDataSource();
            rs.Name = "AccountStatementDatasetFull";
            AccountStatementViewer.LocalReport.ReportPath = "AccountStatementFullReport.rdlc";
        }
        private void CreateObj()
        {
            if (FromDate.SelectedDate == null || ToDate.SelectedDate == null)
            {
                MessageBox.Show("Please select from date and to date correctly..");
                return;
            }
            BillingDataDataContext db = new BillingDataDataContext();
            var c = (Client)this.ClientListCombo.SelectedItem;

            invoice = db.AccountStatements.Where(x => x.ClientCode == c.CLCODE && x.TransactionDate <= ToDate.SelectedDate && x.TransactionDate >= FromDate.SelectedDate).OrderBy(y => y.TransactionDate).ToList();
            AccountStatement carryOverDueRecord = new AccountStatement();

            carryOverDueRecord.Id                  = "";
            carryOverDueRecord.TypeOfRecord        = "Carry";
            carryOverDueRecord.Remark              = "PreviousDue/CarryOverDue";
            carryOverDueRecord.TransactionDate     = FromDate.SelectedDate ?? DateTime.Today;
            carryOverDueRecord.PayAmount           = db.CarryOverDue(FromDate.SelectedDate, c.CLCODE);
            carryOverDueRecord.TotalRecievedAmount = 0;
            invoice.Add(carryOverDueRecord);
            rs.Value = invoice;
            AccountStatementViewer.LocalReport.DataSources.Clear();
            AccountStatementViewer.LocalReport.DataSources.Add(rs);
            List <ReportParameter> repParams = new List <ReportParameter>();

            repParams.Add(new ReportParameter("CompanyName", Configs.Default.CompanyName));
            repParams.Add(new ReportParameter("ComapnyPhoneNo", Configs.Default.CompanyPhone));
            repParams.Add(new ReportParameter("CompanyAddress", Configs.Default.CompanyAddress));
            repParams.Add(new ReportParameter("CompanyEmail", Configs.Default.CompanyEmail));
            repParams.Add(new ReportParameter("CompanyFax", Configs.Default.CompanyFax));
            repParams.Add(new ReportParameter("ToDate", ((DateTime)ToDate.SelectedDate).ToString("dd-MMM-yyyy")));
            repParams.Add(new ReportParameter("FromDate", ((DateTime)FromDate.SelectedDate).ToString("dd-MMM-yyyy")));
            double?billedamountsum      = this.invoice.Select(y => y.PayAmount).Sum();
            double?amountRecivedsum     = this.invoice.Select(y => y.TotalRecievedAmount).Sum();
            double?TotalSum             = billedamountsum - amountRecivedsum;
            List <PaymentEntry> entries = db.PaymentEntries.Where(x => x.ClientCode == c.CLCODE && x.Date <= (ToDate.SelectedDate ?? DateTime.Today) && x.Date >= (FromDate.SelectedDate ?? DateTime.Today)).ToList();
            // List<PaymentEntry> entries = db.PaymentEntries.Where(x => x.ClientCode == c.CLCODE && x.DebitNote != null && x.Date <= (ToDate.SelectedDate ?? DateTime.Today) && x.Date >= (FromDate.SelectedDate ?? DateTime.Today)).ToList();
            double totalTDS   = 0;
            double totalDNote = 0;

            if (entries.Count > 0)
            {
                totalTDS   = entries.Select(x => x.TDS).Sum();
                totalDNote = entries.Select(x => x.DebitNote).Sum();
            }
            repParams.Add(new ReportParameter("TotalTDS", String.Format("{0:F2}", totalTDS)));
            repParams.Add(new ReportParameter("TotalDiscount", String.Format("{0:F2}", totalDNote)));
            string sumS = String.Format("{0:F2}", TotalSum ?? 0);

            repParams.Add(new ReportParameter("TotalSum", sumS));
            repParams.Add(new ReportParameter("ClientName", c.CLNAME));
            repParams.Add(new ReportParameter("ClientAddress", c.ADDRESS));
            repParams.Add(new ReportParameter("ClientPhoneNo", c.CONTACTNO));
            AccountStatementViewer.LocalReport.SetParameters(repParams);
            AccountStatementViewer.ShowExportButton = true;
            AccountStatementViewer.RefreshReport();
        }
Пример #17
0
 private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.EditAction == DataGridEditAction.Commit)
     {
         RuntimeData rData = ((RuntimeData)e.Row.Item);
         double      weight;
         if (double.TryParse((e.EditingElement as TextBox).Text, out weight))
         {
             if (e.Column.Header.ToString() == "Billed Weight")
             {
                 rData.BilledWeight = weight;
             }
             else if (e.Column.Header.ToString() == "Billed Amount")
             {
                 rData.FrAmount = (decimal)weight;
             }
         }
         else
         {
             MessageBox.Show("Unable to edit record!! Please check if input does not contain any invalid characters.", "Error");
             return;
         }
         if (rData == null)
         {
             MessageBox.Show("Unable to edit record....");
             return;
         }
         RuntimeData sData = dataGridHelper.getCurrentDataStack.SingleOrDefault(x => x.ConsignmentNo == rData.ConsignmentNo);
         if (sData == null)
         {
             MessageBox.Show("Unable to edit transaction. Please reload the data and try again..", "Error");
             return;
         }
         BillingDataDataContext db    = new BillingDataDataContext();
         RuntimeData            dData = db.RuntimeDatas.SingleOrDefault(x => x.ConsignmentNo == rData.ConsignmentNo && x.UserId == SecurityModule.currentUserName && dataGridHelper.currentSheetNumber == x.SheetNo);
         if (dData == null)
         {
             MessageBox.Show("Unable to edit transaction. Please check if data exists and try again..", "Error");
             return;
         }
         if (e.Column.Header.ToString() == "Billed Weight")
         {
             dData.BilledWeight = rData.BilledWeight;
             dData.FrAmount     = (decimal)UtilityClass.getCost(rData.CustCode, weight, rData.Destination, rData.Type.Trim(), rData.DOX ?? 'N');
             db.SubmitChanges();
             rData.FrAmount     = dData.FrAmount;
             sData.BilledWeight = dData.BilledWeight;
             sData.FrAmount     = dData.FrAmount;
         }
         if (e.Column.Header.ToString() == "Billed Amount")
         {
             dData.FrAmount = rData.FrAmount;
             db.SubmitChanges();
             sData.FrAmount = rData.FrAmount;
         }
     }
 }
Пример #18
0
 public ManageClient()
 {
     InitializeComponent();
     db                = new BillingDataDataContext();
     clientToEdit      = new List <Client>();
     clients           = DataSources.ClientCopy;
     viewsource        = (CollectionViewSource)FindResource("ClienTable");
     viewsource.Source = clients;
 }
Пример #19
0
        private void AddstockLabel_Click(object sender, RoutedEventArgs e)
        {
            bool flag = false;

            if (getdetails())
            {
                BillingDataDataContext db = new BillingDataDataContext();
                if (!isUpdate)
                {
                    db.Stocks.InsertOnSubmit(this.s);
                    try
                    {
                        try
                        {
                            db.SubmitChanges();
                            flag = true;
                        }
                        catch (Exception ex) { MessageBox.Show(ex.Message); flag = false; return; }
                    }
                    catch (Exception d) { flag = false; MessageBox.Show(d.Message); return; }
                    if (flag)
                    {
                        MessageBox.Show("Stock added", "Info");
                        this.Close();
                    }
                }
                else
                {
                    Stock stockEntry = db.Stocks.SingleOrDefault(x => x.ID == s.ID);
                    if (stockEntry == null)
                    {
                        MessageBox.Show("This stock entry doesn't exists", "Error");
                        return;
                    }
                    else
                    {
                        stockEntry.BookNo     = s.BookNo;
                        stockEntry.cost       = s.cost;
                        stockEntry.Date       = s.Date;
                        stockEntry.desc       = s.desc;
                        stockEntry.StockEnd   = s.StockEnd;
                        stockEntry.StockStart = s.StockStart;
                        stockEntry.UserId     = s.UserId;
                        try
                        {
                            db.SubmitChanges();
                            MessageBox.Show("Stock successfully updated");
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Cannot update stock entry. Error: " + ex.Message);
                        }
                    }
                }
            }
        }
Пример #20
0
        void fillAllElements(string connsignmentNo)
        {
            try
            {
                RuntimeData data;
                data = dataContext.SingleOrDefault(x => x.ConsignmentNo == connsignmentNo);
                if (data != null)
                {
                    if (backDataGrid != null)
                    {
                        if (backDataGrid.Items.Contains(data))
                        {
                            backDataGrid.SelectedItem = data;
                            DataGridRow row;
                            try
                            {
                                row = (DataGridRow)backDataGrid.ItemContainerGenerator.ContainerFromItem(data);
                                row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Error....");
                            }
                        }
                        else
                        {
                            backDataGrid.SelectedItems.Clear();
                        }
                    }
                    this.Focus();
                    fillDetails(data);
                }
                else
                {
                    if (backDataGrid != null)
                    {
                        backDataGrid.SelectedItems.Clear();
                    }

                    BillingDataDataContext db = new BillingDataDataContext();
                    var TData = db.Transactions.SingleOrDefault(x => x.ConnsignmentNo == connsignmentNo);
                    if (TData != null)
                    {
                        fillDetails(UtilityClass.convertTransObjToRunObj(TData));
                    }
                    else
                    {
                        clearDetails();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to load connsignment:" + ex.Message);
                this.Close();
            }
        }
Пример #21
0
        public ExpenseReportWindow()
        {
            InitializeComponent();
            BillingDataDataContext db = new BillingDataDataContext();

            rs      = new Microsoft.Reporting.WinForms.ReportDataSource();
            rs.Name = "ExpenseDataSet";
            AccountStatementViewer.LocalReport.ReportPath = "ExpenseAnalysisReport.rdlc";
        }
        public ServiceFinder()
        {
            InitializeComponent();
            BillingDataDataContext db = new BillingDataDataContext();

            cityView        = (CollectionViewSource)FindResource("CityList");
            cities          = null;
            cityView.Source = cities;
        }
Пример #23
0
        private void initializeRules()
        {
            BillingDataDataContext db = new BillingDataDataContext();

            rulesList    = db.Rules.Where(x => x.QID == this.Id).ToList();
            costingRules = rulesList.Where(x => x.Type == 1).Select(y => ((new JavaScriptSerializer()).Deserialize <CostingRule>(y.Properties))).ToList();
            serviceRules = rulesList.Where(x => x.Type == 2).Select(y => ((new JavaScriptSerializer()).Deserialize <ServiceRule>(y.Properties))).ToList();
            //invoiceRule = rulesList.Where(x => x.Type == 3).Select(y => ((new JavaScriptSerializer()).Deserialize<InvoiceRule>(y.Properties))).ToList();
        }
Пример #24
0
        private void SaveInvoiceButton_Click(object sender, RoutedEventArgs e)
        {
            if (source == null)
            {
                MessageBox.Show("Please print the invoice first...", "Error");
                return;
            }
            MessageBoxResult result = MessageBox.Show("Do you want to save this invoice? ", "Confirm", MessageBoxButton.YesNo);
            int count = source.Where(x => x.TransactionId == null || x.TransactionId == Guid.Empty).Count();

            if (count > 0)
            {
                MessageBox.Show("Selected transactions set contains records that are not yet saved in the database. This bill cannot be saved.");
                return;
            }
            if (result == MessageBoxResult.Yes)
            {
                BillingDataDataContext db = new BillingDataDataContext();
                if (db.Invoices.Where(x => x.BillId == invoice.BillId).Count() > 0)
                {
                    MessageBox.Show("This invoice is already saved", "Error..");
                    return;
                }
                try
                {
                    db.Invoices.InsertOnSubmit(invoice);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                    return;
                }
                foreach (var item in source)
                {
                    InvoiceAssignment assign = new InvoiceAssignment();
                    assign.BillId          = invoice.BillId;
                    assign.Id              = Guid.NewGuid();
                    assign.TransactionId   = (Guid)item.TransactionId;
                    assign.BilledAmount    = (double)(item.FrAmount ?? 0);
                    assign.BilledWeight    = (double)(item.BilledWeight ?? item.Weight);
                    assign.Destination     = item.Destination;
                    assign.DestinationDesc = item.CITY_DESC;
                    db.InvoiceAssignments.InsertOnSubmit(assign);
                }
                try
                {
                    db.SubmitChanges();
                    MessageBox.Show("Invoice Saved... ", "Information");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public ManageEmployee()
        {
            InitializeComponent();
            employeeToEdit = new List <Employee>();
            BillingDataDataContext db = new BillingDataDataContext();

            employees           = DataSources.EmployeeCopy.ToList();
            employeeview        = (CollectionViewSource)FindResource("EmployeeTable");
            employeeview.Source = employees;
        }
        public AddServiceRule(int ruleId)
            : this()
        {
            this.isUpdate = true;
            BillingDataDataContext db = new BillingDataDataContext();

            db   = new BillingDataDataContext();
            rule = db.Rules.SingleOrDefault(x => x.ID == ruleId);
            if (rule == null)
            {
                MessageBox.Show("Invalid Rule.");
                return;
            }
            isInitialized           = true;
            SRule                   = RuleSR = (new JavaScriptSerializer()).Deserialize <ServiceRule>(rule.Properties);
            this.FromWeightBox.Text = SRule.startW.ToString();
            this.ToWeightBox.Text   = SRule.endW.ToString();
            if (SRule.type == 'W')
            {
                this.WholeRadio.IsChecked = true;
                this.StepRadio.IsChecked  = false;
            }
            else
            {
                this.WholeRadio.IsChecked = false;
                this.StepRadio.IsChecked  = true;
                this.StepBox.Text         = SRule.stepweight.ToString();
            }
            if (SRule.change == 'I')
            {
                this.IncRadio.IsChecked = true;
            }
            else
            {
                this.DecRadio.IsChecked = true;
            }
            if (SRule.mode == 'P')
            {
                this.PerRadio.IsChecked = true;
                this.ValueBox.Text      = SRule.per.ToString();
            }
            else
            {
                this.AmountRadio.IsChecked = true;
                this.AmountBox.Text        = SRule.per.ToString();
            }
            AddRule.setFormList(SRule, this.ServiceTwinBox, this.ZoneTwinBox, this.StateTwinBox, this.CitiesTwinBox, ServiceGroupTwinBox);
            this.RemarkBox.Text        = rule.Remark;
            this.AddFilter.Data        = Geometry.Parse(@"F1M2,12.942C2,12.942 10.226,15.241 10.226,15.241 10.226,15.241 8.275,17.071 8.275,17.071 9.288,17.922 10.917,18.786 12.32,18.786 15.074,18.786 17.386,16.824 18.039,14.171 18.039,14.171 21.987,15.222 21.987,15.222 20.891,19.693 16.996,23 12.357,23 9.771,23 7.076,21.618 5.308,19.934 5.308,19.934 3.454,21.671 3.454,21.671 3.454,21.671 2,12.942 2,12.942z M11.643,2C14.229,2 16.924,3.382 18.692,5.066 18.692,5.066 20.546,3.329 20.546,3.329 20.546,3.329 22,12.058 22,12.058 22,12.058 13.774,9.759 13.774,9.759 13.774,9.759 15.725,7.929 15.725,7.929 14.712,7.078 13.083,6.214 11.68,6.214 8.926,6.214 6.614,8.176 5.961,10.829 5.961,10.829 2.013,9.778 2.013,9.778 3.109,5.307 7.004,2 11.643,2z");
            this.AddFilter.Height      = 18;
            this.AddFilter.Width       = 18;
            this.Title                 = "Update Rule " + ruleId.ToString();
            this.AddRuleButtonBox.Text = " Update Rule";
        }
Пример #27
0
        private void removeduplicatePermission()
        {
            var db = new BillingDataDataContext();
            List <User_permission> temp = (from a in db.User_permissions select a).Where(x => x.emp_id == emp.Id).ToList();

            db.User_permissions.DeleteAllOnSubmit(temp);
            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); return; }
        }
Пример #28
0
 public void deleteRuntimeData(int sheetNo)
 {
     try
     {
         BillingDataDataContext db = new BillingDataDataContext();
         db.sp_deleteSheetFromRuntime(SecurityModule.currentUserName, sheetNo);
     }
     catch (ChangeConflictException e)
     {
         Debug.WriteLine(e.Message);
     }
 }
Пример #29
0
        public bool SaveData()
        {
            BillingDataDataContext db   = new BillingDataDataContext();
            RuntimeData            data = null;

            data = fillData(data);
            if (data == null)
            {
                return(false);
            }
            data.SheetNo = sheetNo;
            data.UserId  = SecurityModule.currentUserName;
            if (!SubClientList.ContainsKey(data.CustCode))
            {
                SubClientList.Add(data.CustCode, new List <string>()
                {
                    data.SubClient
                });
            }
            else
            {
                if (!SubClientList[data.CustCode].Contains(data.SubClient))
                {
                    SubClientList[data.CustCode].Add(data.SubClient);
                }
            }
            if (!ConsignerList.Contains(data.ConsignerName))
            {
                ConsignerList.Add(data.ConsignerName);
            }
            if (!ConsigneeList.Contains(data.ConsigneeName))
            {
                ConsigneeList.Add(data.ConsigneeName);
            }
            if (dataContext.Where(x => x.ConsignmentNo == data.ConsignmentNo).Count() > 0)
            {
                RuntimeData origData = db.RuntimeDatas.SingleOrDefault(x => x.Id == data.Id);
                dupliData(data, origData);
            }
            else
            {
                db.RuntimeDatas.InsertOnSubmit(data);
                dataContext.Add(data);
                helper.addRecordToCurrentSheet(data);
                dataListContext.AddNewItem(data);
            }
            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); return(false); }
            return(true);
        }
Пример #30
0
 public static void Reload()
 {
     if (employee != null)
     {
         isSuper = false;
         BillingDataDataContext db = new BillingDataDataContext();
         employee           = db.Employees.Where(x => x.Id == employee.Id).FirstOrDefault();
         _currentUser       = employee.UserName;
         userpermissionList = employee.User_permissions.Select(x => x.Permission).ToList();
         DataSources.UnloadAllData();
     }
 }