示例#1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrWhiteSpace(URNNo))
            {
                yield return(new ValidationResult("Nomor Bon tidak boleh kosong", new List <string> {
                    "URNNo"
                }));
            }
            if (Items == null || Items.Count(i => i.IsSave) <= 0)
            {
                yield return(new ValidationResult("Items tidak boleh kosong", new List <string> {
                    "ItemsCount"
                }));
            }
            else
            {
                string itemError      = "[";
                int    itemErrorCount = 0;

                foreach (var item in Items)
                {
                    itemError += "{";

                    if (CorrectionType.ToUpper() == "JUMLAH")
                    {
                        if (item.CorrectionQuantity == 0)
                        {
                            itemErrorCount++;
                            itemError += "CorrectionQuantity: 'Jumlah Koreksi tidak boleh sama dengan 0', ";
                        }
                        else if (item.CorrectionQuantity + item.QuantityCheck < 0)
                        {
                            itemErrorCount++;
                            itemError += $"CorrectionQuantity: 'Jumlah Koreksi tidak boleh < -{item.QuantityCheck}', ";
                        }
                    }
                    else if (CorrectionType.ToUpper() == "KONVERSI")
                    {
                        if (item.CorrectionConversion <= 0)
                        {
                            itemErrorCount++;
                            itemError += "CorrectionConversion: 'Konversi tidak boleh kurang dari 0', ";
                        }
                    }

                    itemError += "}, ";
                }

                itemError += "]";

                if (itemErrorCount > 0)
                {
                    yield return(new ValidationResult(itemError, new List <string> {
                        "Items"
                    }));
                }
            }
        }
        public static bool AcceptCorrection(CorrectionType correctionType, JToken newToken, Node selectedParentNode)
        {
            bool result = false;

            try
            {
                if (correctionType == CorrectionType.Replace)
                {
                    if (newToken != null)
                    {
                        if (newToken is JProperty)
                        {
                            var prop   = newToken as JProperty;
                            var parent = selectedParentNode.Parent;
                            var tag    = parent.Tag as JProperty;
                            if (tag != null)
                            {
                                var properties = tag.Value as JObject;

                                if (properties.ContainsKey(prop.Name))
                                {
                                    properties[prop.Name] = prop.Value;

                                    result = true;
                                }
                            }
                            else
                            {
                                var properties = parent.Tag as JObject;
                                if (properties.ContainsKey(prop.Name))
                                {
                                    properties[prop.Name] = prop.Value;

                                    result = true;
                                }
                            }
                        }
                        else if (newToken is JObject)
                        {
                            var tag = selectedParentNode.Tag as JObject;
                            tag.RemoveAll();

                            tag.Merge(newToken);

                            result = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Level.Error, ex.Message, ex);
                result = false;
                throw;
            }

            return(result);
        }
 public TimeSystemCorrection(CorrectionType correctionType, double a0, double a1, int referenceTime,
                             int referenceWeek, string sbasType, int?utcId)
 {
     _correctionType = correctionType;
     _a0             = a0;
     _a1             = a1;
     _referenceTime  = referenceTime;
     _referenceWeek  = referenceWeek;
     _sbasType       = sbasType;
     _utcId          = utcId;
 }
示例#4
0
        public void ResetCorrectionsDataGrid(CorrectionType typeOfCorrection)
        {
            dgvCorrections.DataSource = Correction.GetCorrections(typeOfCorrection);

            dgvCorrections.Columns["ServiceTicketID"].Visible = false;
            dgvCorrections.Columns["Cost"].DisplayIndex       = 7;
            dgvCorrections.Columns["ID"].Width          = 30;
            dgvCorrections.Columns["ID"].DisplayIndex   = 0;
            dgvCorrections.Columns["OrderID"].Width     = 50;
            dgvCorrections.Columns["ProductCode"].Width = 80;
            dgvCorrections.Columns["Cost"].Width        = 70;
            dgvCorrections.Columns["Duration"].Width    = 70;
            dgvCorrections.Columns["StartDateTimeOfOperation"].HeaderText = "StartDate";
        }
示例#5
0
        public static List <Correction> GetCorrections(CorrectionType typeOfCorrection)
        {
            List <Correction> corrections = new List <Correction>();

            string tableName = "Correction";

            DataHandler.ResetDataSet();
            DataSet ds = new DataSet();

            switch (typeOfCorrection)
            {
            case CorrectionType.COMPLETED:
                ds = DataHandler.GetDataSet(tableName, "SELECT * FROM Correction WHERE Duration IS NOT NULL");
                break;

            case CorrectionType.SCHEDULED:
                ds = DataHandler.GetDataSet(tableName, "SELECT * FROM Correction WHERE Duration IS NULL");
                break;

            default:
                ds = DataHandler.GetDataSet(tableName);
                break;
            }

            foreach (DataRow row in ds.Tables[tableName].Rows)
            {
                string duration = row["Duration"].ToString();
                string cost     = row["Cost"].ToString();

                if ((duration == null || duration == "") && (cost == null || cost == ""))
                {
                    corrections.Add(new Correction(int.Parse(row["CorrectionID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfCorrection"].ToString()), null, null, int.Parse(row["ServiceTicketID"].ToString())));
                }
                else if (duration == null || duration == "")
                {
                    corrections.Add(new Correction(int.Parse(row["CorrectionID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfCorrection"].ToString()), null, decimal.Parse(cost), int.Parse(row["ServiceTicketID"].ToString())));
                }
                else if (cost == null || cost == "")
                {
                    corrections.Add(new Correction(int.Parse(row["CorrectionID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfCorrection"].ToString()), int.Parse(duration), null, int.Parse(row["ServiceTicketID"].ToString())));
                }
                else
                {
                    corrections.Add(new Correction(int.Parse(row["CorrectionID"].ToString()), int.Parse(row["OrderID"].ToString()), row["ProductCode"].ToString(), row["TechnicianID"].ToString(), DateTime.Parse(row["DateOfCorrection"].ToString()), int.Parse(duration), decimal.Parse(cost), int.Parse(row["ServiceTicketID"].ToString())));
                }
            }

            return(corrections);
        }
示例#6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = 17;
         hash = hash * 29 + Symbol.GetHashCode();
         hash = hash * 29 + CorrectionType.GetHashCode();
         hash = hash * 29 + TradeDate.GetHashCode();
         hash = hash * 29 + TradeTime.GetHashCode();
         hash = hash * 29 + TradePrice.GetHashCode();
         hash = hash * 29 + TradeSize.GetHashCode();
         hash = hash * 29 + TickId.GetHashCode();
         hash = hash * 29 + TradeConditions.GetHashCode();
         hash = hash * 29 + TradeMarketCentre.GetHashCode();
         return(hash);
     }
 }
        public SuggestedCorrectionForm(Node selectedNode, Profile profile) : this()
        {
            _selectedNode = selectedNode;

            _selectedParentNode = selectedNode.Parent;

            _profile = profile;

            leftText.Text = TokenToYaml(_selectedParentNode.Tag as JToken);

            try
            {
                _newToken = MigrationManager.AddMissingProperties(selectedNode);
                if (_newToken == null)
                {
                    _newToken = MigrationManager.AddMissingOneOf(selectedNode);
                }
                if (_newToken == null)
                {
                    _newToken = MigrationManager.SuggestCorrection(selectedNode);
                }

                if (_newToken != null)
                {
                    _correctionType = CorrectionType.Replace;

                    acceptButton.Visible = true;
                    rightText.Text       = TokenToYaml(_newToken);
                    _correctionType      = CorrectionType.Replace;

                    DoDiff();
                }
                else
                {
                    rightText.Text = "No suggestion";
                }
            }
            catch (Exception ex)
            {
                rightText.Text = "No schema found";

                _correctionType = CorrectionType.Unknown;
            }
        }
示例#8
0
 public Correction(CorrectionType type, string sentence, string word)
 {
     Type     = type;
     Sentence = sentence;
     Word     = word;
 }
示例#9
0
 private Correction CreateCorrection(IDefinitionState definitionState, CorrectionType correctionType) =>
 new Correction(correctionType, definitionState.SourceString, definitionState.CurrentWord);
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrWhiteSpace(CorrectionType) || (CorrectionType.ToUpper() != "HARGA SATUAN" && CorrectionType.ToUpper() != "HARGA TOTAL" && CorrectionType.ToUpper() != "JUMLAH"))
            {
                yield return(new ValidationResult("Jenis Koreksi harus berupa 'Harga Satuan' atau 'Harga Total'", new List <string> {
                    "CorrectionType"
                }));
            }

            if (string.IsNullOrWhiteSpace(DONo))
            {
                yield return(new ValidationResult("Nomor Surat Jalan tidak boleh kosong", new List <string> {
                    "DONo"
                }));
            }
            else if ((CorrectionType ?? "").ToUpper() == "HARGA SATUAN" || (CorrectionType ?? "").ToUpper() == "HARGA TOTAL" || (CorrectionType ?? "").ToUpper() == "JUMLAH")
            {
                if (Items == null || Items.Count < 1)
                {
                    yield return(new ValidationResult("Items tidak boleh kosong", new List <string> {
                        "ItemsCount"
                    }));
                }
                else
                {
                    string itemError      = "[";
                    int    itemErrorCount = 0;

                    foreach (var item in Items)
                    {
                        itemError += "{";

                        if (CorrectionType.ToUpper() == "HARGA SATUAN")
                        {
                            if (item.PricePerDealUnitAfter < 0)
                            {
                                itemErrorCount++;
                                itemError += "PricePerDealUnit: 'Harga Satuan tidak boleh kurang dari 0', ";
                            }
                            else if (item.PricePerDealUnitAfter == item.PricePerDealUnitBefore)
                            {
                                itemErrorCount++;
                                itemError += "PricePerDealUnit: 'Harga Satuan tidak berubah', ";
                            }
                        }
                        else if (CorrectionType.ToUpper() == "HARGA TOTAL")
                        {
                            if (item.PriceTotalAfter < 0)
                            {
                                itemErrorCount++;
                                itemError += "PriceTotal: 'Harga Total tidak boleh kurang dari 0', ";
                            }
                            else if (item.PriceTotalAfter == item.PriceTotalBefore)
                            {
                                itemErrorCount++;
                                itemError += "PriceTotal: 'Harga Total tidak berubah', ";
                            }
                        }
                        else if (CorrectionType.ToUpper() == "JUMLAH")
                        {
                            if (item.Quantity == 0)
                            {
                                itemErrorCount++;
                                itemError += "Quantity: 'Jumlah Tidak Boleh 0', ";
                            }
                        }

                        itemError += "}, ";
                    }

                    itemError += "]";

                    if (itemErrorCount > 0)
                    {
                        yield return(new ValidationResult(itemError, new List <string> {
                            "Items"
                        }));
                    }
                }
            }
        }