コード例 #1
0
        public List <RuntimeData> getRuntimeDataFromPodCSV(string filePath, char seperator, char quotes)
        {
            List <RuntimeData> data = new List <RuntimeData>();

            string[] lines = File.ReadAllLines(filePath);
            foreach (string line in lines)
            {
                if (line.ElementAt(0) != '\'')
                {
                    continue;
                }

                string[] lineData = line.Split(seperator);

                RuntimeData rowData = new RuntimeData();
                rowData.ConsignmentNo = lineData[0].Trim('\'');
                rowData.DeliveryDate  = lineData[1].Trim('\'');
                string time;
                lineData[2] = lineData[2].Trim('\'').Trim(' ');
                try
                {
                    if (lineData[2] != null && lineData[2] != "" && lineData[2] != "NULL" && lineData[2].Length >= 4)
                    {
                        rowData.DeliveryTime = DateTime.ParseExact(lineData[2], "HHmm", null).ToString("HH:mm");
                    }
                    else
                    {
                        rowData.DeliveryTime = null;
                    }
                }
                catch (Exception ex)
                {
                    rowData.DeliveryTime = null;
                }
                rowData.DeliveryTime = lineData[2].Trim('\'');
                rowData.ReceivedBy   = lineData[3].Trim('\'');
                rowData.Remarks      = lineData[4].Trim('\'');
                data.Add(rowData);
            }
            return(data);
        }
コード例 #2
0
        static public RuntimeData convertTransObjToRunObj(Transaction trans)
        {
            RuntimeData runtimeDataObj = new RuntimeData();

            runtimeDataObj.Amount        = trans.AmountPayed;
            runtimeDataObj.BookingDate   = trans.BookingDate;
            runtimeDataObj.Weight        = trans.Weight;
            runtimeDataObj.ConsignmentNo = trans.ConnsignmentNo.Trim();
            runtimeDataObj.Destination   = trans.Destination.Trim();
            if (trans.DestinationPin != null)
            {
                runtimeDataObj.DestinationPin = (decimal)trans.DestinationPin;
            }
            runtimeDataObj.DOX      = trans.DOX;
            runtimeDataObj.FrAmount = trans.AmountCharged;
            runtimeDataObj.FrWeight = trans.WeightByFranchize;
            runtimeDataObj.Id       = Guid.NewGuid();
            if (trans.InvoiceDate != null)
            {
                runtimeDataObj.InvoiceDate = (DateTime)trans.InvoiceDate;
            }
            if (trans.InvoiceNo != null)
            {
                runtimeDataObj.InvoiceNo = trans.InvoiceNo.Trim();
            }
            runtimeDataObj.Mode          = trans.Mode.Trim();
            runtimeDataObj.ServiceTax    = trans.ServiceTax;
            runtimeDataObj.SplDisc       = trans.SplDisc;
            runtimeDataObj.CustCode      = trans.CustCode;
            runtimeDataObj.TransactionId = trans.ID;
            if (trans.Type != null)
            {
                runtimeDataObj.Type = trans.Type.Trim();
            }
            runtimeDataObj.BilledWeight  = trans.BilledWeight;
            runtimeDataObj.SubClient     = trans.SubClient;
            runtimeDataObj.ConsigneeName = trans.ConsigneeName;
            runtimeDataObj.ConsignerName = trans.ConsignerName;
            return(runtimeDataObj);
        }
コード例 #3
0
 public void dupliData(RuntimeData sData, RuntimeData dData)
 {
     dData.Amount             = sData.Amount;
     dData.BilledWeight       = sData.BilledWeight;
     dData.BookingDate        = sData.BookingDate;
     dData.City_Desc          = sData.City_Desc;
     dData.Client_Desc        = sData.Client_Desc;
     dData.ConsignmentNo      = sData.ConsignmentNo;
     dData.CustCode           = sData.CustCode;
     dData.Destination        = sData.Destination;
     dData.DestinationPin     = sData.DestinationPin;
     dData.DOX                = sData.DOX;
     dData.EmpId              = sData.EmpId;
     dData.FrAmount           = sData.FrAmount;
     dData.FrWeight           = sData.FrWeight;
     dData.InvoiceDate        = sData.InvoiceDate;
     dData.InvoiceNo          = sData.InvoiceNo;
     dData.Mode               = sData.Mode;
     dData.Service_Desc       = sData.Service_Desc;
     dData.ServiceTax         = sData.ServiceTax;
     dData.SheetNo            = sData.SheetNo;
     dData.SplDisc            = sData.SplDisc;
     dData.TransactionId      = sData.TransactionId;
     dData.TransMF_No         = sData.TransMF_No;
     dData.Type               = sData.Type;
     dData.UserId             = sData.UserId;
     dData.Weight             = sData.Weight;
     dData.Client_Desc        = sData.Client_Desc;
     dData.ConsigneeName      = sData.ConsigneeName;
     dData.ConsignerAddress   = sData.ConsignerAddress;
     dData.ConsignerName      = sData.ConsignerName;
     dData.ConsigneeAddress   = sData.ConsigneeAddress;
     dData.SubClient          = sData.SubClient;
     dData.RecalculateEnabled = sData.RecalculateEnabled;
     dData.Insurance          = sData.Insurance;
     dData.DeliveryStatus     = sData.DeliveryStatus;
 }
コード例 #4
0
        public SanitizingWindow(List <RuntimeData> dataContext, BillingDataDataContext db, int sheetNo, DataGrid dg, DataGridHelper helper, Dictionary <string, List <string> > SubClientList, List <string> ConsigneeList, List <string> ConsignerList, RuntimeData selectedRec = null)
            : this()
        {
            ConsigneeListSource        = (CollectionViewSource)FindResource("ConsigneeListSource");
            ConsignerListSource        = (CollectionViewSource)FindResource("ConsignerListSource");
            SubClientListSource        = (CollectionViewSource)FindResource("SubClientListSource");
            this.SubClientList         = SubClientList;
            this.ConsigneeList         = ConsigneeList;
            this.ConsignerList         = ConsignerList;
            ConsignerListSource.Source = this.ConsignerList;
            ConsigneeListSource.Source = this.ConsigneeList;
            string SelectedClientCode = ((Client)CustomerSelected.SelectedItem).CLCODE;

            SubClientListSource.Source = SubClientList.ContainsKey(SelectedClientCode) ? SubClientList[SelectedClientCode] : null;
            this.helper       = helper;
            this.backDataGrid = dg;
            this.sheetNo      = sheetNo;
            if (dataContext != null)
            {
                this.dataContext = dataContext;
            }
            if (dg.ItemsSource != null)
            {
                dataListContext = (ListCollectionView)dg.ItemsSource;
            }
            conssNumbers        = (CollectionViewSource)FindResource("ConsignmentNumbers");
            conssNumbers.Source = (from id in dataContext
                                   orderby id.ConsignmentNo
                                   select id.ConsignmentNo).ToList();
            InsertionDate.SelectedDate = DateTime.Today;
            if (selectedRec != null)
            {
                ConnsignmentNumber.Text = selectedRec.ConsignmentNo;
            }
            fillAllElements(ConnsignmentNumber.Text);
        }
コード例 #5
0
        public void fillDetails(RuntimeData data)
        {
            BillingDataDataContext db = new BillingDataDataContext();

            WeightAccToDTDC.Text = data.Weight.ToString();
            Cost.Text            = data.Amount.ToString();
            MODE.Text            = data.Mode;
            if (data.DOX == 'N')
            {
                DoxCombobox.Text = "Non Dox";
            }
            else
            {
                DoxCombobox.Text = "Dox";
            }
            if (data.BookingDate != null)
            {
                InsertionDate.SelectedDate = data.BookingDate;
            }
            Destination.Text = DataSources.CityCopy.Where(x => x.CITY_CODE == data.Destination).Select(y => y.NameAndCode).FirstOrDefault();
            if ((data.FrAmount != null))
            {
                CustomerSelected.Text = DataSources.ClientCopy.Where(x => x.CLCODE == data.CustCode).Select(y => y.NameAndCode).FirstOrDefault();
            }
            DestinationPin.Text = data.DestinationPin.ToString();
            if (data.FrWeight != null)
            {
                WeightAccToFranchize.Text = data.FrWeight.ToString();
            }
            else
            {
                WeightAccToFranchize.Text = data.Weight.ToString();
            }
            if (data.FrAmount != null)
            {
                BilledAmount.Text = data.FrAmount.ToString();
            }
            else
            {
                BilledAmount.Text = "";
            }
            if (data.BilledWeight != null)
            {
                this.BilledWeightTextBox.Text = data.BilledWeight.ToString();
            }
            else
            {
                this.BilledWeightTextBox.Text = data.Weight.ToString();
            }
            if (data.Type != "" && data.Type != null)
            {
                TypeComboBox.Text = DataSources.ServicesCopy.Where(x => x.SER_CODE == data.Type.Trim()).Select(y => y.NameAndCode).FirstOrDefault();
            }
            if (data.Mode != "" && data.Mode != null)
            {
                MODE.Text = data.Mode.Trim();
            }
            string SelectedClientCode = ((Client)CustomerSelected.SelectedItem).CLCODE;

            SubClientListSource.Source = SubClientList.ContainsKey(SelectedClientCode) ? SubClientList[SelectedClientCode] : new List <string>();
            ConsigneeListSource.Source = ConsigneeList;
            ConsignerListSource.Source = ConsignerList;
            ConsgineeName.Text         = data.ConsigneeName ?? "";
            ConsignerName.Text         = data.ConsignerName ?? "";
            if (data.RecalculateEnabled != 'F')
            {
                RecalculateCheckBox.IsChecked = true;
            }
            else
            {
                RecalculateCheckBox.IsChecked = false;
            }
            HeightPacketBox.Text = "0";
            WidthPacketBox.Text  = "0";
            LenghtPacketBox.Text = "0";
            NetWeightBlock.Text  = "0";

            if (data.SubClient != "" && data.SubClient != null)
            {
                SubClientComboBox.Text = data.SubClient;
            }
            if (data.ConsigneeName != "" && data.ConsigneeName != null)
            {
                this.ConsgineeName.Text = data.ConsigneeName;
            }
            SlipCost.Text = data.Stock;
            if (data.Stock == "N/A")
            {
                SlipCost.Text       = "  N/A  ";
                SlipCost.Background = new SolidColorBrush(Colors.Red);
            }
            else
            {
                SlipCost.Background = new SolidColorBrush(Colors.White);
            }
        }
コード例 #6
0
 public void setdata(RuntimeData dbdata, RuntimeData data)
 {
 }
コード例 #7
0
        public RuntimeData fillData(RuntimeData data)
        {
            List <Client>  clientList  = DataSources.ClientCopy;
            List <City>    cityList    = DataSources.CityCopy;
            List <Service> serviceList = DataSources.ServicesCopy;

            if (CustomerSelected.Text == "")
            {
                CustomerSelected.Text = "<NONE>";
            }
            if (WeightAccToDTDC.Text == "")
            {
                WeightAccToDTDC.Text = "0";
            }
            if (WeightAccToFranchize.Text == "")
            {
                WeightAccToFranchize.Text = WeightAccToDTDC.Text;
            }
            if (BilledWeightTextBox.Text == "")
            {
                BilledWeightTextBox.Text = WeightAccToFranchize.Text;
            }
            if (BilledAmount.Text == "")
            {
                BilledAmount.Text = "0";
            }
            if (Destination.Text == "" || Destination.Text == null)
            {
                MessageBox.Show("City cannot be empty");
                return(null);
            }
            data = dataContext.SingleOrDefault(x => x.ConsignmentNo == ConnsignmentNumber.Text);
            if (data == null)
            {
                BillingDataDataContext db = new BillingDataDataContext();
                var TData = db.Transactions.SingleOrDefault(x => x.ConnsignmentNo == ConnsignmentNumber.Text);
                if (TData == null)
                {
                    data               = new RuntimeData();
                    data.Id            = Guid.NewGuid();
                    data.ConsignmentNo = ConnsignmentNumber.Text;
                }
                else
                {
                    data = UtilityClass.convertTransObjToRunObj(TData);
                }
            }
            double weight;

            if (Double.TryParse(WeightAccToDTDC.Text, out weight))
            {
                data.Weight = weight;
            }
            else
            {
                MessageBox.Show("Weight is incorrect", "Error");
                return(null);
            }
            data.FrWeight = Double.Parse(WeightAccToFranchize.Text);
            double tmpD;

            if (Cost.Text == "" || !double.TryParse(Cost.Text, out tmpD))
            {
                Cost.Text = "0";
            }
            data.Amount = Decimal.Parse(Cost.Text);
            var c1 = cityList.Where(x => x.NameAndCode == Destination.Text).FirstOrDefault();

            if (c1 != null)
            {
                data.Destination = c1.CITY_CODE;
                data.City_Desc   = c1.CITY_DESC;
            }
            decimal tempDecimal;

            if (decimal.TryParse(DestinationPin.Text, out tempDecimal))
            {
                data.DestinationPin = tempDecimal;
            }
            data.CustCode = DataSources.ClientCopy.Where(x => x.NameAndCode == CustomerSelected.Text).Select(y => y.CLCODE).FirstOrDefault();
            if (data.CustCode == "" || data.CustCode == null || data.CustCode == "<NONE>")
            {
                MessageBox.Show("No customer selected...", "Error");
                return(null);
            }
            if (MODE.Text != "")
            {
                data.Mode = MODE.Text;
            }
            Service service = serviceList.Where(x => x.NameAndCode == TypeComboBox.Text.Trim()).FirstOrDefault();

            if (service == null)
            {
                MessageBox.Show("No service selected...", "Error");
                return(null);
            }
            data.Type         = service.SER_CODE;
            data.Service_Desc = service.SER_DESC;
            data.BookingDate  = InsertionDate.SelectedDate ?? DateTime.Today;
            if (decimal.TryParse(BilledAmount.Text, out tempDecimal))
            {
                data.FrAmount = tempDecimal;
            }
            else
            {
                MessageBox.Show("Invalid billed amount", "Error");
                return(null);
            }
            if (DoxCombobox.Text == "")
            {
                DoxCombobox.Text = "Dox";
            }
            data.DOX = DoxCombobox.Text.Length > 1 ? DoxCombobox.Text.ElementAt(0) : 'D';
            float tempValue;

            if (float.TryParse(BilledWeightTextBox.Text, out tempValue))
            {
                data.BilledWeight = double.Parse(BilledWeightTextBox.Text, CultureInfo.InvariantCulture);
            }
            else
            {
                BilledWeightTextBox.Text = "";
            }
            if (data.Destination == null)
            {
                MessageBoxResult rsltMessageBox = MessageBox.Show("City not found \n Would you like to enter city", "", MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
                if (MessageBoxResult.Yes == rsltMessageBox)
                {
                    return(null);
                }
                else
                {
                    this.Close();
                }
            }
            data.CustCode = clientList.Where(x => x.NameAndCode == CustomerSelected.Text).Select(y => y.CLCODE).FirstOrDefault();
            if (data.CustCode != null)
            {
                data.Client_Desc = clientList.Where(x => x.NameAndCode == CustomerSelected.Text).Select(y => y.CLNAME).FirstOrDefault();
            }
            if (this.BilledWeightTextBox.Text == "" || this.BilledWeightTextBox.Text == null)
            {
                if (this.WeightAccToFranchize.Text == "" || this.WeightAccToFranchize == null)
                {
                    data.BilledWeight = 0;
                }
                else
                {
                    data.BilledWeight = data.FrWeight;
                }
            }
            else
            {
                if (float.TryParse(BilledWeightTextBox.Text, out tempValue))
                {
                    data.BilledWeight = double.Parse(BilledWeightTextBox.Text, CultureInfo.InvariantCulture);
                }
            }
            data.ConsigneeName = ConsgineeName.Text;
            data.ConsignerName = ConsignerName.Text;
            data.SubClient     = SubClientComboBox.Text;
            if (RecalculateCheckBox.IsChecked == true)
            {
                data.RecalculateEnabled = 'T';
            }
            else
            {
                data.RecalculateEnabled = 'F';
            }
            if (decimal.TryParse(InsuranceBox.Text, out tempDecimal))
            {
                data.Insurance = tempDecimal;
            }
            else
            {
                data.Insurance    = 0;
                InsuranceBox.Text = "0";
            }
            return(data);
        }
コード例 #8
0
        public List <RuntimeData> getRuntimeDataFromCSV(string filePath, char seperator, char quotes)
        {
            List <City>        cityList    = DataSources.CityCopy;
            List <Service>     serviceList = DataSources.ServicesCopy;
            List <RuntimeData> data        = new List <RuntimeData>();

            string[] lines = File.ReadAllLines(filePath);
            foreach (string line in lines)
            {
                if (line.ElementAt(0) != '\'')
                {
                    continue;
                }

                string[] lineData = line.Split(seperator);

                RuntimeData rowData = new RuntimeData();
                rowData.Id             = Guid.NewGuid();
                rowData.ConsignmentNo  = lineData[1].Trim('\'');
                rowData.Weight         = Double.Parse(lineData[4]);
                rowData.FrWeight       = rowData.Weight;
                rowData.BilledWeight   = rowData.Weight;
                rowData.Type           = lineData[5].Trim('\'');
                rowData.Destination    = lineData[6].Trim('\'');
                rowData.Mode           = lineData[7].Trim('\'');
                rowData.DestinationPin = Decimal.Parse(lineData[9]);
                rowData.BookingDate    = DateTime.ParseExact(lineData[10].Replace("\'", ""), "dd-MM-yyyy", new CultureInfo("en-US")).Date;
                rowData.Amount         = Decimal.Parse(lineData[11]);
                rowData.TransMF_No     = lineData[14].Trim('\'');
                rowData.DOX            = lineData[16].Trim('\'').ToCharArray()[0];
                Double doubledata;
                if (Double.TryParse(lineData[17], out doubledata))
                {
                    rowData.ServiceTax = doubledata;
                }
                if (Double.TryParse(lineData[18], out doubledata))
                {
                    rowData.SplDisc = doubledata;
                }
                rowData.InvoiceNo = lineData[22].Trim('\'');
                DateTime dateTimeObj;
                if (DateTime.TryParse(lineData[23], out dateTimeObj))
                {
                    rowData.InvoiceDate = dateTimeObj;
                }
                rowData.CustCode = "<NONE>";
                Service service = serviceList.SingleOrDefault(x => x.SER_CODE == rowData.Type);
                if (service != null)
                {
                    rowData.Service_Desc = service.SER_DESC;
                }
                City city = cityList.SingleOrDefault(x => x.CITY_CODE == rowData.Destination);
                if (city != null)
                {
                    rowData.City_Desc = city.CITY_DESC;
                }
                rowData.Client_Desc = DataSources.ClientCopy.SingleOrDefault(x => x.CLCODE == "<NONE>").CLNAME;
                data.Add(rowData);
            }
            return(data);
        }
コード例 #9
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Client client = DataSources.ClientCopy.FirstOrDefault(x => x.CLCODE == clientCodeSelectedValue);

            errorNos = "";
            if (startCOnnNoIndex <= endConnNoIndex && startCOnnNoIndex != -1 && endConnNoIndex != -1)
            {
                int total = endConnNoIndex - startCOnnNoIndex;
                var cs    = (from m in db.Cities select m).ToList();
                for (int i = startCOnnNoIndex; i <= endConnNoIndex; i++)
                {
                    RuntimeData data = DataStack.ElementAt(i);

                    data = db.RuntimeDatas.Single(x => x.Id == data.Id);
                    var c = cs.Where(x => x.CITY_CODE == data.Destination).FirstOrDefault();
                    if (c == null)
                    {
                        c = db.Cities.SingleOrDefault(x => x.CITY_CODE == "DEL");
                    }
                    data.CustCode = clientCodeSelectedValue;
                    if (client != null)
                    {
                        data.Client_Desc = client.CLNAME;
                    }
                    if (data.FrWeight == null)
                    {
                        data.FrWeight = data.Weight;
                    }
                    if (data.BilledWeight == null)
                    {
                        data.BilledWeight = data.Weight;
                    }
                    if (setWeightCheck == true)
                    {
                        data.BilledWeight = weight;
                    }
                    if (subClientCheck == true)
                    {
                        data.SubClient = subClient;
                    }
                    if (consignerCheck == true)
                    {
                        data.ConsignerName = consigner;
                    }
                    if (consigneeCheck == true)
                    {
                        data.ConsigneeName = consignee;
                    }
                    if (calcRateCheck == true)
                    {
                        try
                        {
                            decimal costObt = (decimal)UtilityClass.getCost(data.CustCode.Trim(), (double)data.BilledWeight, data.Destination.Trim(), data.Type.Trim(), (char)data.DOX);
                            if (data.Insurance != null)
                            {
                                costObt = costObt + (decimal)data.Insurance;
                            }
                            data.FrAmount = costObt;
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message + ": Occured in " + data.ConsignmentNo);
                            data.FrAmount = -1;
                        }
                    }
                    try
                    {
                        RuntimeData ndata = DataStack.ElementAt(i);
                        dupliData(data, ndata);
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        errorNos = errorNos + "\n " + data.ConsignmentNo;
                    }
                    worker.ReportProgress((((i - startCOnnNoIndex + 1) * 100) / total));
                }
            }
        }