Esempio n. 1
0
        public void ReadSettingsFromNode(XmlNode Node, ReportType Type)
        {
            try
            {
                SettingsNode = Node;
                this.Type    = Type;

                String Value;
                XMLFileUtils.GetChildNodeValue(SettingsNode, "HeaderTitle", out HeaderTitle);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "HeaderSubTitle", out HeaderSubTitle);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "FooterTitle", out FooterTitle);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "Address", out Address);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "PhoneNumber", out PhoneNumber);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "EMailID", out EMailID);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "VATPercent", out VATPercent);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "TINNumber", out TINNumber);
                XMLFileUtils.GetChildNodeValue(SettingsNode, "GSTINumber", out GSTINumber);

                if (XMLFileUtils.GetChildNodeValue(SettingsNode, "LastNumber", out Value))
                {
                    LastNumber = Int32.Parse(Value);
                }

                if (XMLFileUtils.GetChildNodeValue(SettingsNode, "HeaderTitleColor", out Value))
                {
                    HeaderTitleColor = CommonFunctions.GetColor(Value);
                }
                if (XMLFileUtils.GetChildNodeValue(SettingsNode, "HeaderSubTitleColor", out Value))
                {
                    HeaderSubTitleColor = CommonFunctions.GetColor(Value);
                }
                if (XMLFileUtils.GetChildNodeValue(SettingsNode, "FooterTitleColor", out Value))
                {
                    FooterTitleColor = CommonFunctions.GetColor(Value);
                }
                if (XMLFileUtils.GetChildNodeValue(SettingsNode, "FooterTextColor", out Value))
                {
                    FooterTextColor = CommonFunctions.GetColor(Value);
                }
                XmlNode PastSalesPeriodNode;
                if (XMLFileUtils.GetChildNode(SettingsNode, "PastSalesPeriod", out PastSalesPeriodNode))
                {
                    if (XMLFileUtils.GetChildNodeValue(PastSalesPeriodNode, "Value", out Value))
                    {
                        PastSalePeriodValue = Int32.Parse(Value);
                    }
                    if (XMLFileUtils.GetChildNodeValue(PastSalesPeriodNode, "Units", out Value))
                    {
                        PastSalePeriodUnits = GetTimePeriodUnits(Value);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonFunctions.ShowErrorDialog("ReportSettings.ReadSettingsFromNode()", ex);
            }
        }
Esempio n. 2
0
        public void LoadProductPastSalesFromStockHistoryFile(DataTable dtSalePurchaseHistory, DateTime AsOnDate, Int32 PeriodValue, TimePeriodUnits PeriodUnits)
        {
            try
            {
                #region Compute Date Range
                List <DateTime> ListPODates = dtSalePurchaseHistory.AsEnumerable().Select(s => s.Field <DateTime>("PO Date")).Distinct().ToList();
                ListPODates.Sort();

                DateTime FromDate = AsOnDate, ToDate = AsOnDate;
                switch (PeriodUnits)
                {
                case TimePeriodUnits.Days:
                    Int32 ToDateIndex = -1;
                    for (int i = ListPODates.Count - 1; i >= 0; i--)
                    {
                        if (ListPODates[i] <= AsOnDate)
                        {
                            ToDate      = ListPODates[i];
                            ToDateIndex = i;
                            break;
                        }
                    }

                    if (ToDateIndex < 0)
                    {
                        return;
                    }
                    FromDate = ListPODates[((ToDateIndex - PeriodValue + 1) >= 0) ? (ToDateIndex - PeriodValue + 1) : 0];
                    break;

                case TimePeriodUnits.Weeks:
                    ToDate   = AsOnDate;
                    FromDate = AsOnDate.AddDays(PeriodValue * -7);
                    break;

                case TimePeriodUnits.Months:
                    ToDate   = AsOnDate;
                    FromDate = AsOnDate.AddMonths(PeriodValue * -1);
                    break;

                case TimePeriodUnits.Years:
                    ToDate   = AsOnDate;
                    FromDate = AsOnDate.AddYears(PeriodValue * -1);
                    break;

                case TimePeriodUnits.None:
                default: break;
                }
                #endregion

                DataRow[] drSalesPurchaseHistory           = dtSalePurchaseHistory.Select("", "[Stock Name] asc");

                StockProductDetails ObjStockProductDetails = null;
                String PreviousStockName                   = "";
                for (int i = 0; i < drSalesPurchaseHistory.Length; i++)
                {
                    DataRow dr = drSalesPurchaseHistory[i];
                    if (DateTime.Parse(dr["PO Date"].ToString()) < FromDate || DateTime.Parse(dr["PO Date"].ToString()) > ToDate)
                    {
                        continue;
                    }

                    if (!PreviousStockName.Trim().Equals(dr["Stock Name"].ToString().Trim(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        ObjStockProductDetails = GetStockProductDetails(dr["Stock Name"].ToString().Trim());
                        PreviousStockName      = ObjStockProductDetails.StockName;
                        if (ObjStockProductDetails == null)
                        {
                            continue;
                        }
                    }

                    String TransactionType = dr["Type"].ToString().Trim().ToUpper();
                    if (TransactionType.Equals("SALE"))
                    {
                        ObjStockProductDetails.SaleQty += (-1 * Double.Parse(dr["Receive Qty"].ToString()));
                    }
                    else if (TransactionType.Equals("PURCHASE"))
                    {
                        ObjStockProductDetails.RecvdQty += Double.Parse(dr["Receive Qty"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                CommonFunctions.ShowErrorDialog("ProductMaster.LoadProductPastSalesFromStockHistoryFile()", ex);
                throw;
            }
        }