/// <summary> /// 将字符串金额格式化"9785.335"→"9,78.33" /// </summary> /// <param name="strPriceValue">需要转换的字符串</param> /// <param name="FractionalDigit">四舍五入的小数位数</param> /// <returns></returns> public string FormatCurrency(string strPriceValue, int fractionalDigit) { try { Decimal PriceValue; if (!Decimal.TryParse(strPriceValue, out PriceValue)) { return(strPriceValue); } strPriceValue = PriceValue.ToString("F" + fractionalDigit.ToString()); string retValue = "." + strPriceValue.Split('.')[1]; strPriceValue = strPriceValue.Split('.')[0]; while (strPriceValue.Length > 3) { retValue = "," + strPriceValue.Substring(strPriceValue.Length - 3, 3) + retValue; strPriceValue = strPriceValue.Substring(0, strPriceValue.Length - 3); } retValue = strPriceValue + retValue; return(retValue); } catch (Exception) { return(strPriceValue); } }
/// <summary> /// در صورتی که شناسه محصول صفر نباشد می توانید ازین تابع استفاده نمایید /// </summary> public Builder SetPrice(PriceValue price) { this.price = price.ToString(); return(this); }
private void OKButton_Click(object sender, EventArgs e) { try { Price = PriceValue; Count = Count - CountValue; Summ = Summ - SummValue; CratesCount = CratesCount - CratesCountBalue; Mass = Mass - MassValue; if (!File.Exists(Application.StartupPath + "//Raw.Residue.Data.xml")) { General.ShowErrorBox("Список продуктов сырья отсутствует!\nВозможно была потеря данных, обратитесь к администрации программы!"); } else { XmlDocument xDoc = new XmlDocument(); xDoc.Load(Application.StartupPath + "//Raw.Residue.Data.xml"); XmlElement xRoot = xDoc.DocumentElement; XmlNode childnode = xRoot.SelectSingleNode(String.Format("RawResidue[Имя='{0}']", titlebox.Text)); if (childnode != null) { XmlNode nameChildNode = childnode.SelectSingleNode("Имя"); string elemNameStr = "NONE"; if (nameChildNode != null) { elemNameStr = nameChildNode.InnerText; XmlNode massElem = childnode.SelectSingleNode("Масса"); XmlNode countElem = childnode.SelectSingleNode("Количество"); XmlNode cratesElem = childnode.SelectSingleNode("КоличествоКаробок"); XmlNode pricesElem = childnode.SelectSingleNode("Цена"); XmlNode summElem = childnode.SelectSingleNode("Сумма"); if (massElem != null && countElem != null && cratesElem != null && pricesElem != null && summElem != null) { massElem.InnerText = Mass.ToString(); countElem.InnerText = Count.ToString(); cratesElem.InnerText = CratesCount.ToString(); pricesElem.InnerText = Price.ToString(); summElem.InnerText = Summ.ToString(); } } } xDoc.Save(Application.StartupPath + "//Raw.Residue.Data.xml"); } /* * General.UpdateCellData("RawMaterialsResidue", "Цена", Price.ToString().Replace(",", "."), Convert.ToInt32(ID)); * General.UpdateCellData("RawMaterialsResidue", "Количество", Count.ToString().Replace(",", "."), Convert.ToInt32(ID)); * General.UpdateCellData("RawMaterialsResidue", "КоличествоКаробок", CratesCount.ToString().Replace(",", "."), Convert.ToInt32(ID)); * General.UpdateCellData("RawMaterialsResidue", "Масса", Mass.ToString().Replace(",", "."), Convert.ToInt32(ID)); * General.UpdateCellData("RawMaterialsResidue", "Сумма", Summ.ToString().Replace(",", "."), Convert.ToInt32(ID)); */ Date = DateControl.Value.ToString(); if (ProviderTextBox.Text != null) { Provider = ProviderTextBox.Text; } if (RecipientTextBox.Text != null) { Recipient = RecipientTextBox.Text; } RemovedRawMaterialsForm RRMF = new RemovedRawMaterialsForm(); RRMF.InsertRecords(titlebox.Text, MassValue.ToString().Replace(",", "."), PriceValue.ToString().Replace(",", "."), CountValue.ToString().Replace(",", "."), CratesCountBalue.ToString().Replace(",", "."), SummValue.ToString().Replace(",", "."), Date, Provider, Recipient); RRMF.ShowDialog(this); this.Close(); } catch (Exception) { } }
public override string ToString() { return(PriceValue.ToString()); }