private void SaveAction()
 {
     var newVariable = new GlobalVariable {Name = UserVariableName};
     CurrentProgram.GlobalVariables.Add(newVariable);
     CurrentProgram.Save();
     base.GoBackAction();
 }
Esempio n. 2
0
		public static GlobalVariable LoadDefaultConfiguration(string configFile)
		{
			if (string.IsNullOrEmpty(configFile))
				configFile = DefaultConfigFile;

			var fileFullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFile);
			if (File.Exists(fileFullPath) == false)
			{
				throw new InvalidOperationException(string.Format("File not found. : {0}", fileFullPath));
				//SaveDefaultConfiguration();
			}

			using (var stream = new FileStream(fileFullPath, FileMode.Open, FileAccess.Read))
			{
				var reader = new StreamReader(stream, Encoding.UTF8);
				var xmlString = reader.ReadToEnd();

				reader.Close();
				stream.Close();

				var serializer = new XmlSerializer(typeof(GlobalVariable));
				_instance = (GlobalVariable)serializer.Deserialize(new StringReader(xmlString));
			}

			return _instance;
		}
Esempio n. 3
0
        internal void GetGlobalVariableCompleted(GlobalVariable itemsSource)
        {
            if (itemsSource == null)
            {
                DataServiceHelper.SelectSessionId();
            }
            else
            {
                Globals.UserLogin = itemsSource.UserLogin;
                Globals.AppSettings = itemsSource.AppSettings;

                //Security section
                Globals.UserLogin.IsUserOrganisationAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.OrganisationAdministratorRoleId);
                Globals.UserLogin.IsUserSiteAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SiteAdministratorRoleId);
                Globals.UserLogin.IsUserPortalAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.PortalAdministratorRoleId);
                Globals.UserLogin.IsUserSecurityAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SecurityAdminRoleId);

                CultureInfo customCultureInfo = new CultureInfo(Globals.AppSettings.GloblaCulture);
                customCultureInfo.NumberFormat = (new CultureInfo(Globals.AppSettings.NumberFormatCulture)).NumberFormat;
                customCultureInfo.DateTimeFormat = (new CultureInfo(Globals.AppSettings.DateTimeFormatCulture)).DateTimeFormat;

                Thread.CurrentThread.CurrentCulture = customCultureInfo;
                

                // Until their page has been converted to SL, redirect Portal admin to their aspx page (unless just loading the header).
                string typeName = this.startupEventArgs.InitParams["TypeName"];
                if (typeName == "MainPage")
                {
                    Type t = Type.GetType(this.GetType().Namespace + "." + typeName);
                    UIElement elem = Activator.CreateInstance(t) as UIElement;
                    if (elem != null)
                    {
                        if (elem is MainPage)
                        {
                            MainPage mainPage = (MainPage)elem;
                            mainPage.ContentTypeName = this.startupEventArgs.InitParams["ContentTypeName"];
                        }

                        StyleManager.ApplicationTheme = new Office_BlackTheme();
                        FontHelper.SetFontType(elem, new FontFamily("Corbel"), 12);

                        this.RootVisual = elem;

                        // Set keepalive timer to call every 10 minutes to renew asp.net authentication.
                        DispatcherTimer keepAliveTimer = new DispatcherTimer();
                        keepAliveTimer.Interval = new TimeSpan(0, 0, 10, 0, 0);
                        keepAliveTimer.Tick += new EventHandler(keepAliveTimer_Tick);
                        keepAliveTimer.Start();
                    }

                }
            }
        }
Esempio n. 4
0
		public static void Initialize(string configFile)
		{
			_instance = LoadDefaultConfiguration(configFile);

			if (_instance.RegisterTourney == RegisterTourney.CashGame)
			{
				_instance.TableBlindIndexInfo.SetTableBlind(_instance.TableBlindList);
			}
			else
			{
				_instance.TableBlindIndexInfo.SetTableBlind(-1);
				_instance.CanTableReEnter = false;
			}

			_instance.ConfigFilePath = configFile;
		}
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportLedgerAccounting"/> class.
 /// </summary>
 public ReportLedgerAccounting()
 {
     Model           = new TSD.AccountingSoft.Model.Model();
     _globalVariable = new GlobalVariable();
 }
Esempio n. 6
0
        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            isContainerApplicable = MTransaction.ProductContainerApplicable(GetCtx());

            log.Info("M_Inventory_ID=" + _m_Inventory_ID);
            inventory = new MInventory(GetCtx(), _m_Inventory_ID, Get_TrxName());
            if (inventory.Get_ID() == 0)
            {
                throw new SystemException("Not found: M_Inventory_ID=" + _m_Inventory_ID);
            }

            //	Multiple Lines for one item
            //jz simple the SQL so that Derby also like it. To avoid testing Oracle by now, leave no change for Oracle
            String sql = null;

            if (DataBase.DB.IsOracle())
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND (M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID) IN "
                      + "(SELECT M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + (isContainerApplicable ? " , M_ProductContainer_ID" : "")
                      + "HAVING COUNT(*) > 1)";
            }
            else
            {
                sql = "UPDATE M_InventoryLine SET IsActive='N' "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " AND EXISTS "
                      + "(SELECT COUNT(*) "
                      + "FROM M_InventoryLine "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID
                      + " GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID "
                      + (isContainerApplicable ? " , M_ProductContainer_ID" : "")
                      + "HAVING COUNT(*) > 1)";
            }
            int multiple = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Multiple=" + multiple);

            int delMA = MInventoryLineMA.DeleteInventoryMA(_m_Inventory_ID, Get_TrxName());

            log.Info("DeletedMA=" + delMA);

            //	ASI
            sql = "UPDATE M_InventoryLine l "
                  + "SET (QtyBook,QtyCount) = "
                  + "(SELECT QtyOnHand,QtyOnHand FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID),"
                  + " Updated=SysDate,"
                  + " UpdatedBy=" + GetAD_User_ID()
                  //
                  + " WHERE M_Inventory_ID=" + _m_Inventory_ID
                  + " AND EXISTS (SELECT * FROM M_Storage s "
                  + "WHERE s.M_Product_ID=l.M_Product_ID AND s.M_Locator_ID=l.M_Locator_ID"
                  + " AND s.M_AttributeSetInstance_ID=l.M_AttributeSetInstance_ID)";
            int no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());

            log.Info("Update with ASI =" + no);

            //	No ASI
            //int noMA = UpdateWithMA();

            //	Set Count to Zero
            if (_inventoryCountSetZero)
            {
                sql = "UPDATE M_InventoryLine l "
                      + "SET QtyCount=0 "
                      + "WHERE M_Inventory_ID=" + _m_Inventory_ID;
                no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName());
                log.Info("Set Count to Zero =" + no);
            }
            if (_AdjustinventoryCount)
            {
                //                MInventoryLine[] lines = inventory.GetLines(true);
                //                for (int i = 0; i < lines.Length; i++)
                //                {
                //                    decimal currentQty = 0;
                //                    string query = "", qry = "";
                //                    int result = 0;
                //                    MInventoryLine iLine = lines[i];
                //                    int M_Product_ID = Utility.Util.GetValueOfInt(iLine.GetM_Product_ID());
                //                    int M_Locator_ID = Utility.Util.GetValueOfInt(iLine.GetM_Locator_ID());
                //                    int M_AttributeSetInstance_ID = Util.GetValueOfInt(iLine.GetM_AttributeSetInstance_ID());

                //                    query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate = " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                           AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                    result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                //                    if (result > 0)
                //                    {
                //                        qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                        currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                //                    }
                //                    else
                //                    {
                //                        query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                        result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                //                        if (result > 0)
                //                        {
                //                            qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) + @"
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
                //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
                //                            currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
                //                        }
                //                    }
                //                    iLine.SetQtyBook(currentQty);
                //                    iLine.SetOpeningStock(currentQty);
                //                    if (iLine.GetAdjustmentType() == "A")
                //                    {
                //                        iLine.SetDifferenceQty(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetAsOnDateCount()));
                //                    }
                //                    else if (iLine.GetAdjustmentType() == "D")
                //                    {
                //                        iLine.SetAsOnDateCount(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                //                    }
                //                    iLine.SetQtyCount(Util.GetValueOfDecimal(iLine.GetQtyBook()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                //                    if (!iLine.Save())
                //                    {

                //                    }
                //                }

                // Work done by Bharat on 26/12/2016 for optimization
                if (isContainerApplicable)
                {
                    sql = @"SELECT m.M_InventoryLine_ID, m.M_Locator_ID, m.M_Product_ID, m.M_AttributeSetInstance_ID, m.AdjustmentType, m.AsOnDateCount, m.DifferenceQty,
                nvl(mt.CurrentQty, 0) as CurrentQty FROM M_InventoryLine m LEFT JOIN (SELECT DISTINCT t.M_Locator_ID, t.M_Product_ID, t.M_AttributeSetInstance_ID, t.M_ProductContainer_ID,
                FIRST_VALUE(t.ContainerCurrentQty) OVER (PARTITION BY t.M_Product_ID, t.M_AttributeSetInstance_ID ORDER BY t.MovementDate DESC, t.M_Transaction_ID DESC) AS CurrentQty FROM M_Transaction t
                INNER JOIN M_Locator l ON t.M_Locator_ID = l.M_Locator_ID WHERE t.MovementDate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) +
                          " AND t.AD_Client_ID = " + inventory.GetAD_Client_ID() + @") mt ON m.M_Product_ID = mt.M_Product_ID AND nvl(m.M_AttributeSetInstance_ID, 0) = nvl(mt.M_AttributeSetInstance_ID, 0) 
                AND m.M_Locator_ID = mt.M_Locator_ID AND nvl(m.M_ProductContainer_ID, 0) = nvl(mt.M_ProductContainer_ID, 0) 
                WHERE m.M_Inventory_ID = " + _m_Inventory_ID + " ORDER BY m.Line";
                }
                else
                {
                    sql = @"SELECT m.M_InventoryLine_ID, m.M_Locator_ID, m.M_Product_ID, m.M_AttributeSetInstance_ID, m.AdjustmentType, m.AsOnDateCount, m.DifferenceQty,
                nvl(mt.CurrentQty, 0) as CurrentQty FROM M_InventoryLine m LEFT JOIN (SELECT DISTINCT t.M_Locator_ID, t.M_Product_ID, t.M_AttributeSetInstance_ID, 
                FIRST_VALUE(t.CurrentQty) OVER (PARTITION BY t.M_Product_ID, t.M_AttributeSetInstance_ID ORDER BY t.MovementDate DESC, t.M_Transaction_ID DESC) AS CurrentQty FROM M_Transaction t
                INNER JOIN M_Locator l ON t.M_Locator_ID = l.M_Locator_ID WHERE t.MovementDate <= " + GlobalVariable.TO_DATE(inventory.GetMovementDate(), true) +
                          " AND t.AD_Client_ID = " + inventory.GetAD_Client_ID() + @") mt ON m.M_Product_ID = mt.M_Product_ID AND nvl(m.M_AttributeSetInstance_ID, 0) = nvl(mt.M_AttributeSetInstance_ID, 0) 
                AND m.M_Locator_ID = mt.M_Locator_ID WHERE m.M_Inventory_ID = " + _m_Inventory_ID + " ORDER BY m.Line";
                }

                int           totalRec  = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(M_InventoryLine_ID) FROM ( " + sql + " ) t", null, null));
                int           pageSize  = 500;
                int           TotalPage = (totalRec % pageSize) == 0 ? (totalRec / pageSize) : ((totalRec / pageSize) + 1);
                int           count     = 0;
                DataSet       ds        = null;
                StringBuilder updateSql = new StringBuilder();
                try
                {
                    if (totalRec > 0)
                    {
                        log.Info(" =====> Physical Inventory update process Started at " + DateTime.Now.ToString());
                        if (!_SkipBL)
                        {
                            for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                            {
                                ds = DB.GetDatabase().ExecuteDatasetPaging(sql, pageNo, pageSize, 0);
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                    {
                                        decimal currentQty = 0;
                                        int     line_ID    = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                        currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][7]);
                                        MInventoryLine iLine = new MInventoryLine(GetCtx(), line_ID, Get_TrxName());
                                        iLine.SetQtyBook(currentQty);
                                        iLine.SetOpeningStock(currentQty);
                                        if (iLine.GetAdjustmentType() == "A")
                                        {
                                            iLine.SetDifferenceQty(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetAsOnDateCount()));
                                        }
                                        else if (iLine.GetAdjustmentType() == "D")
                                        {
                                            iLine.SetAsOnDateCount(Util.GetValueOfDecimal(iLine.GetOpeningStock()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                                        }
                                        iLine.SetQtyCount(Util.GetValueOfDecimal(iLine.GetQtyBook()) - Util.GetValueOfDecimal(iLine.GetDifferenceQty()));
                                        if (!iLine.Save())
                                        {
                                        }
                                        else
                                        {
                                            count++;
                                        }
                                    }
                                    ds.Dispose();
                                    log.Info(" =====>  records updated at " + DateTime.Now.ToString() + " are = " + count + " <===== ");
                                }
                            }
                        }
                        else
                        {
                            for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                            {
                                //updateSql.Clear();
                                ds = DB.GetDatabase().ExecuteDatasetPaging(sql, pageNo, pageSize, 0);
                                if (ds != null && ds.Tables[0].Rows.Count > 0)
                                {
                                    //updateSql.Append("BEGIN ");
                                    //for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                    //{
                                    //    int line_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                    //    int locator_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][1]);
                                    //    int product_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][2]);
                                    //    string AdjustType = Util.GetValueOfString(ds.Tables[0].Rows[j][4]);
                                    //    decimal AsonDateCount = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][5]);
                                    //    decimal DiffQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][6]);
                                    //    decimal currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][7]);
                                    //    string updateQry = UpdateInventoryLine(line_ID, product_ID, locator_ID, currentQty, AdjustType, AsonDateCount, DiffQty);
                                    //    if (updateQry != "")
                                    //    {
                                    //        updateSql.Append(updateQry);
                                    //    }
                                    //}
                                    //ds.Dispose();
                                    //updateSql.Append(" END;");
                                    //int cnt = DB.ExecuteQuery(updateSql.ToString(), null, Get_Trx());
                                    //log.Info(" =====>  records updated at " + DateTime.Now.ToString() + " are = " + count + " <===== ");

                                    string updateQry = DBFunctionCollection.UpdateInventoryLine(GetCtx(), ds, Get_Trx());
                                    ds.Dispose();
                                    int cnt = DB.ExecuteQuery(updateQry, null, Get_Trx());
                                }
                            }
                        }
                        log.Info(" =====>  Physical Inventory update process end at " + DateTime.Now.ToString());
                    }
                }
                catch (Exception e)
                {
                    if (ds != null)
                    {
                        ds.Dispose();
                    }
                    log.Log(Level.SEVERE, sql.ToString(), e);
                }
            }
            inventory.SetIsAdjusted(true);
            if (!inventory.Save())
            {
            }
            if (multiple > 0)
            {
                return("@M_InventoryLine_ID@ - #" + no + " --> @InventoryProductMultiple@");
            }

            //return "@M_InventoryLine_ID@ - #" + (no + noMA);
            return("Physical Inventory Updated");
        }
Esempio n. 7
0
        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            log.Info("M_Inventory_ID=" + _m_Inventory_ID
                     + ", M_Locator_ID=" + _m_Locator_ID + ", LocatorValue=" + _locatorValue
                     + ", ProductValue=" + _productValue
                     + ", M_Product_Category_ID=" + _m_Product_Category_ID
                     + ", QtyRange=" + _qtyRange + ", DeleteOld=" + _deleteOld);
            _inventory = new MInventory(GetCtx(), _m_Inventory_ID, Get_TrxName());
            if (_inventory.Get_ID() == 0)
            {
                throw new SystemException("Not found: M_Inventory_ID=" + _m_Inventory_ID);
            }
            if (_inventory.IsProcessed())
            {
                throw new SystemException("@M_Inventory_ID@ @Processed@");
            }
            //
            String        sqlQry = "";
            StringBuilder sql    = null;
            int           count  = 0;

            if (_deleteOld)
            {
                sqlQry = "DELETE FROM M_InventoryLine WHERE Processed='N' "
                         + "AND M_Inventory_ID=" + _m_Inventory_ID;
                int no = DataBase.DB.ExecuteQuery(sqlQry, null, Get_TrxName());
                log.Fine("doIt - Deleted #" + no);
            }

            //	Create Null Storage records
            //if (_qtyRange != null && _qtyRange.Equals("="))
            //{
            //    sqlQry = "INSERT INTO M_Storage "
            //        + "(AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,"
            //        + " M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,"
            //        + " qtyOnHand, QtyReserved, QtyOrdered, DateLastInventory) "
            //        + "SELECT l.AD_CLIENT_ID, l.AD_ORG_ID, 'Y', SysDate, 0,SysDate, 0,"
            //        + " l.M_Locator_ID, p.M_Product_ID, 0,"
            //        + " 0,0,0,null "
            //        + "FROM M_Locator l"
            //        + " INNER JOIN M_Product p ON (l.AD_Client_ID=p.AD_Client_ID) "
            //        + "WHERE l.M_Warehouse_ID=" + _inventory.GetM_Warehouse_ID();
            //    if (_m_Locator_ID != 0)
            //        sqlQry += " AND l.M_Locator_ID=" + _m_Locator_ID;
            //    sqlQry += " AND l.IsDefault='Y'"
            //        + " AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'"
            //        + " AND NOT EXISTS (SELECT * FROM M_Storage s"
            //            + " INNER JOIN M_Locator sl ON (s.M_Locator_ID=sl.M_Locator_ID) "
            //            + "WHERE sl.M_Warehouse_ID=l.M_Warehouse_ID"
            //            + " AND s.M_Product_ID=p.M_Product_ID)";
            //    int no = DataBase.DB.ExecuteQuery(sqlQry, null, Get_TrxName());
            //    log.Fine("'0' Inserted #" + no);
            //}

            //string sqlstock = "SELECT Count(*) FROM user_procedures WHERE object_type='FUNCTION' AND OBJECT_NAME='GETSTOCKOFWAREHOUSE'";
            //int countStock = Util.GetValueOfInt(DB.ExecuteScalar(sqlstock, null, null));
            //if (countStock > 0)
            //{
            sql = new StringBuilder(
                @"WITH mt AS (SELECT m_product_id, M_Locator_ID, M_AttributeSetInstance_ID, SUM(CurrentQty) AS CurrentQty FROM
                (SELECT t.M_Product_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID, SUM(t.CurrentQty) keep (dense_rank last
                ORDER BY t.MovementDate, t.M_Transaction_ID) AS CurrentQty FROM m_transaction t INNER JOIN M_Locator l ON t.M_Locator_ID = l.M_Locator_ID
                WHERE t.MovementDate <= " + GlobalVariable.TO_DATE(_inventory.GetMovementDate(), true) +
                @" AND t.AD_Client_ID = " + _inventory.GetAD_Client_ID() + " AND l.AD_Org_ID = " + _inventory.GetAD_Org_ID() +
                @" AND l.M_Warehouse_ID = " + _inventory.GetM_Warehouse_ID() + @" GROUP BY t.M_Product_ID,l.M_Warehouse_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID) 
                GROUP BY m_product_id, M_Locator_ID, M_AttributeSetInstance_ID )
                SELECT s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID, mt.currentqty AS Qty, s.QtyOnHand, p.M_AttributeSet_ID FROM M_Product p 
                INNER JOIN M_Storage s ON (s.M_Product_ID=p.M_Product_ID) INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) 
                JOIN mt ON (mt.M_Product_ID = s.M_Product_ID AND mt.M_Locator_ID = s.M_Locator_ID AND mt.M_AttriButeSetInstance_ID = NVL(s.M_AttriButeSetInstance_ID,0))
                WHERE l.M_Warehouse_ID = " + _inventory.GetM_Warehouse_ID() + " AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'");
            //
            if (_m_Locator_ID != 0)
            {
                sql.Append(" AND s.M_Locator_ID=" + _m_Locator_ID);
            }
            //else
            //    sql.Append(" AND  s.m_Locator_Id IN (SELECT M_Locator_ID FROM M_Locator WHERE M_Warehouse_ID=" + _inventory.GetM_Warehouse_ID() + ")");
            //
            if (_locatorValue != null &&
                (_locatorValue.Trim().Length == 0 || _locatorValue.Equals("%")))
            {
                _locatorValue = null;
            }
            if (_locatorValue != null)
            {
                sql.Append(" AND UPPER(l.Value) LIKE '" + _locatorValue.ToUpper() + "'");
            }
            //
            if (_productValue != null &&
                (_productValue.Trim().Length == 0 || _productValue.Equals("%")))
            {
                _productValue = null;
            }
            if (_productValue != null)
            {
                sql.Append(" AND UPPER(p.Value) LIKE '" + _productValue.ToUpper() + "'");
            }

            if (_m_Product_Category_ID != 0)
            {
                sql.Append(" AND p.M_Product_Category_ID=" + _m_Product_Category_ID);
            }
            //	Do not overwrite existing records
            if (!_deleteOld)
            {
                sql.Append(" AND NOT EXISTS (SELECT * FROM M_InventoryLine il "
                           + "WHERE il.M_Inventory_ID=" + _m_Inventory_ID
                           + " AND il.M_Product_ID=s.M_Product_ID"
                           + " AND il.M_Locator_ID=s.M_Locator_ID"
                           + " AND COALESCE(il.M_AttributeSetInstance_ID,0)=COALESCE(s.M_AttributeSetInstance_ID,0))");
            }
            //	+ " AND il.M_AttributeSetInstance_ID=s.M_AttributeSetInstance_ID)");
            //
            //sql.Append(" ORDER BY l.Value, p.Value, s.qtyOnHand DESC");	//	Locator/Product
            if (_qtyRange == "N")
            {
                sql.Append(" AND mt.currentqty != 0");
            }

            /*SI_0631 : System is giving error ORA-00920: invalid relational operator if User does not select any value from Inventory Quantity list.
             *          Physical Inventory Window -- button -- Create inventory count list*/
            else if (!String.IsNullOrEmpty(_qtyRange))
            {
                sql.Append(" AND mt.currentqty " + _qtyRange + " 0");
            }

            int           totalRec  = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(M_Product_ID) FROM ( " + sql.ToString() + " )", null, null));
            int           pageSize  = 500;
            int           TotalPage = (totalRec % pageSize) == 0 ? (totalRec / pageSize) : ((totalRec / pageSize) + 1);
            StringBuilder insertSql = new StringBuilder();
            DataSet       ds        = null;

            try
            {
                if (totalRec > 0)
                {
                    log.Info(" =====> Physical Inventory process Started at " + DateTime.Now.ToString());
                    if (!_SkipBL)
                    {
                        for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                        {
                            ds = DB.GetDatabase().ExecuteDatasetPaging(sql.ToString(), pageNo, pageSize, 0);
                            if (ds != null && ds.Tables[0].Rows.Count > 0)
                            {
                                for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                {
                                    decimal currentQty   = 0;
                                    int     M_Product_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                    int     M_Locator_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][1]);
                                    int     M_AttributeSetInstance_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][2]);
                                    //Decimal qtyOnHand = Util.GetValueOfDecimal(idr[3]);
                                    int M_AttributeSet_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][5]);
                                    currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][3]);

                                    count += CreateInventoryLine(M_Locator_ID, M_Product_ID,
                                                                 M_AttributeSetInstance_ID, currentQty, currentQty, M_AttributeSet_ID);
                                }
                                ds.Dispose();
                                log.Info(" =====>  records inserted at " + DateTime.Now.ToString() + " are = " + count + " <===== ");
                            }
                        }
                    }
                    else
                    {
                        for (int pageNo = 1; pageNo <= TotalPage; pageNo++)
                        {
                            insertSql.Clear();
                            ds = DB.GetDatabase().ExecuteDatasetPaging(sql.ToString(), pageNo, pageSize, 0);
                            if (ds != null && ds.Tables[0].Rows.Count > 0)
                            {
                                sqlQry = "SELECT COALESCE(MAX(Line),0) AS DefaultValue FROM M_InventoryLine WHERE M_Inventory_ID=" + _m_Inventory_ID;
                                int lineNo = DB.GetSQLValue(Get_Trx(), sqlQry);
                                insertSql.Append("BEGIN ");
                                for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                                {
                                    decimal currentQty   = 0;
                                    int     M_Product_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][0]);
                                    int     M_Locator_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][1]);
                                    int     M_AttributeSetInstance_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][2]);
                                    //Decimal qtyOnHand = Util.GetValueOfDecimal(idr[3]);
                                    int M_AttributeSet_ID = Util.GetValueOfInt(ds.Tables[0].Rows[j][5]);
                                    currentQty = Util.GetValueOfDecimal(ds.Tables[0].Rows[j][3]);
                                    lineNo     = lineNo + 10;
                                    string insertQry = InsertInventoryLine(M_Locator_ID, M_Product_ID, lineNo, M_AttributeSetInstance_ID, currentQty, M_AttributeSet_ID);
                                    if (insertQry != "")
                                    {
                                        insertSql.Append(insertQry);
                                    }
                                }
                                ds.Dispose();
                                insertSql.Append(" END;");
                                int no = DB.ExecuteQuery(insertSql.ToString(), null, Get_Trx());
                            }
                        }
                    }

                    log.Info(" =====>  Physical Inventory process end at " + DateTime.Now.ToString());
                }
            }
            catch (Exception e)
            {
                if (ds != null)
                {
                    ds.Dispose();
                }
                log.Log(Level.SEVERE, sql.ToString(), e);
            }
            //            }
            //            else
            //            {
            //                sql = new StringBuilder(
            //                    "SELECT s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID,"
            //                    + " s.qtyOnHand, p.M_AttributeSet_ID "
            //                    + "FROM M_Product p"
            //                    + " INNER JOIN M_Storage s ON (s.M_Product_ID=p.M_Product_ID)"
            //                    + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) "
            //                    + "WHERE l.M_Warehouse_ID=" + _inventory.GetM_Warehouse_ID()
            //                    + " AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'");
            //                //
            //                if (_m_Locator_ID != 0)
            //                    sql.Append(" AND s.M_Locator_ID=" + _m_Locator_ID);
            //                //
            //                if (_locatorValue != null &&
            //                    (_locatorValue.Trim().Length == 0 || _locatorValue.Equals("%")))
            //                    _locatorValue = null;
            //                if (_locatorValue != null)
            //                    sql.Append(" AND UPPER(l.Value) LIKE '" + _locatorValue.ToUpper() + "'");
            //                //
            //                if (_productValue != null &&
            //                    (_productValue.Trim().Length == 0 || _productValue.Equals("%")))
            //                    _productValue = null;
            //                if (_productValue != null)
            //                    sql.Append(" AND UPPER(p.Value) LIKE '" + _productValue.ToUpper() + "'");
            //                //
            //                if (_m_Product_Category_ID != 0)
            //                    sql.Append(" AND p.M_Product_Category_ID=" + _m_Product_Category_ID);

            //                //	Do not overwrite existing records
            //                if (!_deleteOld)
            //                    sql.Append(" AND NOT EXISTS (SELECT * FROM M_InventoryLine il "
            //                    + "WHERE il.M_Inventory_ID=" + _m_Inventory_ID
            //                    + " AND il.M_Product_ID=s.M_Product_ID"
            //                    + " AND il.M_Locator_ID=s.M_Locator_ID"
            //                    + " AND COALESCE(il.M_AttributeSetInstance_ID,0)=COALESCE(s.M_AttributeSetInstance_ID,0))");

            //                sql.Append(" ORDER BY l.Value, p.Value, s.qtyOnHand DESC");	//	Locator/Product
            //                //

            //                IDataReader idr = null;
            //                try
            //                {
            //                    idr = DataBase.DB.ExecuteReader(sql.ToString(), null, Get_TrxName());
            //                    while (idr.Read())
            //                    {
            //                        decimal currentQty = 0;
            //                        string query = "", qry = "";
            //                        int result = 0;
            //                        int M_Product_ID = Utility.Util.GetValueOfInt(idr[0]);
            //                        int M_Locator_ID = Utility.Util.GetValueOfInt(idr[1]);
            //                        int M_AttributeSetInstance_ID = Utility.Util.GetValueOfInt(idr[2]);
            //                        Decimal qtyOnHand = Utility.Util.GetValueOfDecimal(idr[3]);
            //                        int M_AttributeSet_ID = Utility.Util.GetValueOfInt(idr[4]);

            //                        query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate = " + GlobalVariable.TO_DATE(_inventory.GetMovementDate(), true) + @"
            //                           AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
            //                        result = Util.GetValueOfInt(DB.ExecuteScalar(query));
            //                        if (result > 0)
            //                        {
            //                            qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
            //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
            //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate <= " + GlobalVariable.TO_DATE(_inventory.GetMovementDate(), true) + @"
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
            //                            currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
            //                        }
            //                        else
            //                        {
            //                            query = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(_inventory.GetMovementDate(), true) + @"
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
            //                            result = Util.GetValueOfInt(DB.ExecuteScalar(query));
            //                            if (result > 0)
            //                            {
            //                                qry = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
            //                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
            //                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(_inventory.GetMovementDate(), true) + @"
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID + @")
            //                            AND  M_Product_ID = " + M_Product_ID + " AND M_Locator_ID = " + M_Locator_ID + " AND M_AttributeSetInstance_ID = " + M_AttributeSetInstance_ID;
            //                                currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(qry));
            //                            }

            //                        }
            //                        int compare = currentQty.CompareTo(Env.ZERO);
            //                        if (_qtyRange == null
            //                            || (_qtyRange.Equals(">") && compare > 0)
            //                            || (_qtyRange.Equals("<") && compare < 0)
            //                            || (_qtyRange.Equals("=") && compare == 0)
            //                            || (_qtyRange.Equals("N") && compare != 0))
            //                        {
            //                            count += CreateInventoryLine(M_Locator_ID, M_Product_ID,
            //                                M_AttributeSetInstance_ID, currentQty, currentQty, M_AttributeSet_ID);
            //                        }
            //                    }
            //                    idr.Close();
            //                }
            //                catch (Exception e)
            //                {
            //                    if (idr != null)
            //                    {
            //                        idr.Close();
            //                    }
            //                    log.Log(Level.SEVERE, sql.ToString(), e);
            //                }
            //            }
            //	Set Count to Zero
            if (_inventoryCountSetZero)
            {
                String         sql1 = "";
                MInventoryLine inv  = new MInventoryLine(GetCtx(), 0, null);
                if (inv.Get_ColumnIndex("IsFromProcess") >= 0)
                {
                    sql1 = "UPDATE M_InventoryLine l "
                           + "SET QtyCount=0,AsOnDateCount=0 "
                           + "WHERE M_Inventory_ID=" + _m_Inventory_ID + " AND IsFromProcess = 'Y'";
                }
                else
                {
                    sql1 = "UPDATE M_InventoryLine l "
                           + "SET QtyCount=0,AsOnDateCount=0 "
                           + "WHERE M_Inventory_ID=" + _m_Inventory_ID;
                }
                int no = DataBase.DB.ExecuteQuery(sql1, null, Get_TrxName());
                log.Info("Set Cont to Zero=" + no);
            }

            //
            //return "@M_InventoryLine_ID@ - #" + count;
            return("Physical Inventory Created");
        }
Esempio n. 8
0
 public override GlobalVariable VisitGlobalVariable(GlobalVariable node)
 {
     add(node);
     return(base.VisitGlobalVariable(node));
 }
Esempio n. 9
0
        internal static void GetGlobalVariableCompleted(GlobalVariable itemsSource)
        {
            if (itemsSource == null)
            {
                DataServiceHelper.SelectSessionId();
            }
            else
            {
                Globals.UserLogin = itemsSource.UserLogin;
                Globals.AppSettings = itemsSource.AppSettings;

                //Security section
                Globals.UserLogin.IsUserOrganisationAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.OrganisationAdministratorRoleId);
                Globals.UserLogin.IsUserSiteAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SiteAdministratorRoleId);
                Globals.UserLogin.IsUserPortalAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.PortalAdministratorRoleId);
                Globals.UserLogin.IsUserSecurityAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SecurityAdminRoleId);

            }
        }
 public static FormulaNodeGlobalVariable CreateGlobalVariableNode(GlobalVariable variable)
 {
     return new FormulaNodeGlobalVariable
     {
         Variable = variable
     };
 }
Esempio n. 11
0
 public virtual void DeclareGlobalVariable(GlobalVariable v, string attributes)
 {
     Contract.Requires(v != null); ProcessDeclaration(v);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FrmXtraGeneralReceiptEstimate"/> class.
 /// </summary>
 public FrmXtraGeneralReceiptEstimate()
 {
     InitializeComponent();
     _dbOptionHelper = new GlobalVariable();
 }
        /// <summary>
        /// Gets the cash report S12 ah.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="commonVariable">The common variable.</param>
        /// <param name="oRsTool">The o rs tool.</param>
        /// <returns></returns>
        public IList <CashReportModel> GetCashReportS12AH(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            IList <CashReportModel> list = null;
            var amountType           = GlobalVariable.AmountTypeViewReport;
            var currencyCode         = GlobalVariable.CurrencyViewReport;
            var isTotalBandInNewPage = false;
            var isBank = false;
            int?bankId = null;

            if (!oRsTool.IsRefresh)
            {
                using (var frmParam = new FrmS12AH())
                {
                    frmParam.Text = @"Sổ chi tiết tiền gửi ngân hàng";
                    if (frmParam.ShowDialog() == DialogResult.OK)
                    {
                        GlobalVariable.FromDate = DateTime.Parse(frmParam.FromDate);
                        GlobalVariable.ToDate   = DateTime.Parse(frmParam.ToDate);
                        isTotalBandInNewPage    = frmParam.IsTotalBandInNewPage;
                        var accountNumber = frmParam.AccountCode;
                        isBank = frmParam.IsBank;
                        bankId = frmParam.BankId;

                        if (!oRsTool.Parameters.ContainsKey("Account"))
                        {
                            oRsTool.Parameters.Add("Account", "Tài khoản: " + accountNumber + " - " + frmParam.AccountName);
                        }

                        if (!oRsTool.Parameters.ContainsKey("AccountNumber"))
                        {
                            oRsTool.Parameters.Add("AccountNumber", accountNumber);
                        }

                        var correspondingAccountNumber = frmParam.CorrespondingAccountNumber;
                        if (!oRsTool.Parameters.ContainsKey("CorrespondingAccountNumber"))
                        {
                            oRsTool.Parameters.Add("CorrespondingAccountNumber", correspondingAccountNumber);
                        }

                        if (!oRsTool.Parameters.ContainsKey("BankName"))
                        {
                            oRsTool.Parameters.Add("BankName", frmParam.BankName);
                        }

                        list = Model.GetCashS12AHWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(),
                                                                  GlobalVariable.ToDate.ToShortDateString(), amountType, accountNumber, correspondingAccountNumber, currencyCode, isBank, bankId);
                    }
                }
            }
            else
            {
                var accountNumber = oRsTool.Parameters["AccountNumber"].ToString();
                var correspondingAccountNumber = oRsTool.Parameters["CorrespondingAccountNumber"].ToString();
                list = Model.GetCashS12AHWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(),
                                                          GlobalVariable.ToDate.ToShortDateString(), amountType, accountNumber, correspondingAccountNumber, currencyCode, isBank, bankId);
            }
            if (list != null && list.Count > 0)
            {
                if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                {
                    oRsTool.Parameters.Add("CurrencyCodeUnit",
                                           "Đơn vị tính " + (amountType == 2 ? "(nguyên tệ): " : "(quy đổi): ") + currencyCode);
                }

                if (!oRsTool.Parameters.ContainsKey("FromDate"))
                {
                    oRsTool.Parameters.Add("FromDate", GlobalVariable.FromDate.ToShortDateString());
                }

                if (!oRsTool.Parameters.ContainsKey("ToDate"))
                {
                    oRsTool.Parameters.Add("ToDate", GlobalVariable.ToDate.ToShortDateString());
                }

                if (!oRsTool.Parameters.ContainsKey("Year"))
                {
                    oRsTool.Parameters.Add("Year", "Năm:" + GlobalVariable.ToDate.Year);
                }

                if (!oRsTool.Parameters.ContainsKey("Province"))
                {
                    oRsTool.Parameters.Add("Province", _globalVariable.CompanyProvince);
                }

                if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                {
                    oRsTool.Parameters.Add("ReportDate", _globalVariable.PostedDate);
                }



                if (!oRsTool.Parameters.ContainsKey("ckClosing"))
                {
                    oRsTool.Parameters.Add("ckClosing", list[list.Count - 1].RestAmount);
                }
                list.RemoveAt(list.Count - 1);
                if (!oRsTool.Parameters.ContainsKey("lkReceipt"))
                {
                    oRsTool.Parameters.Add("lkReceipt", list[list.Count - 1].ReceiptAmount);
                }
                if (!oRsTool.Parameters.ContainsKey("lkPayment"))
                {
                    oRsTool.Parameters.Add("lkPayment", list[list.Count - 1].PayAmount);
                }
                list.RemoveAt(list.Count - 1);
                if (!oRsTool.Parameters.ContainsKey("psReceipt"))
                {
                    oRsTool.Parameters.Add("psReceipt", list[list.Count - 1].ReceiptAmount);
                }
                if (!oRsTool.Parameters.ContainsKey("psPayment"))
                {
                    oRsTool.Parameters.Add("psPayment", list[list.Count - 1].PayAmount);
                }
                list.RemoveAt(list.Count - 1);

                // ThoDD add trạng thái chuyển sang trang sau
                if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                {
                    oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                }
            }
            return(list);
        }
Esempio n. 14
0
        private static IFormulaToken CreateToken(FormulaEditorKey key, LocalVariable localVariable, GlobalVariable globalVariable)
        {
            switch (key)
            {
                // Constants
                case FormulaEditorKey.D0: return FormulaTokenFactory.CreateDigitToken(0);
                case FormulaEditorKey.D1: return FormulaTokenFactory.CreateDigitToken(1);
                case FormulaEditorKey.D2: return FormulaTokenFactory.CreateDigitToken(2);
                case FormulaEditorKey.D3: return FormulaTokenFactory.CreateDigitToken(3);
                case FormulaEditorKey.D4: return FormulaTokenFactory.CreateDigitToken(4);
                case FormulaEditorKey.D5: return FormulaTokenFactory.CreateDigitToken(5);
                case FormulaEditorKey.D6: return FormulaTokenFactory.CreateDigitToken(6);
                case FormulaEditorKey.D7: return FormulaTokenFactory.CreateDigitToken(7);
                case FormulaEditorKey.D8: return FormulaTokenFactory.CreateDigitToken(8);
                case FormulaEditorKey.D9: return FormulaTokenFactory.CreateDigitToken(9);
                case FormulaEditorKey.DecimalSeparator: return FormulaTokenFactory.CreateDecimalSeparatorToken();
                case FormulaEditorKey.ParameterSeparator: return FormulaTokenFactory.CreateParameterSeparatorToken();
                case FormulaEditorKey.Pi: return FormulaTokenFactory.CreatePiToken();
                case FormulaEditorKey.True: return FormulaTokenFactory.CreateTrueToken();
                case FormulaEditorKey.False: return FormulaTokenFactory.CreateFalseToken();

                // Operators
                case FormulaEditorKey.Plus: return FormulaTokenFactory.CreatePlusToken();
                case FormulaEditorKey.Minus: return FormulaTokenFactory.CreateMinusToken();
                case FormulaEditorKey.Multiply: return FormulaTokenFactory.CreateMultiplyToken();
                case FormulaEditorKey.Divide: return FormulaTokenFactory.CreateDivideToken();
                case FormulaEditorKey.Caret: return FormulaTokenFactory.CreateCaretToken();
                case FormulaEditorKey.Equals: return FormulaTokenFactory.CreateEqualsToken();
                case FormulaEditorKey.NotEquals: return FormulaTokenFactory.CreateNotEqualsToken();
                case FormulaEditorKey.Greater: return FormulaTokenFactory.CreateGreaterToken();
                case FormulaEditorKey.GreaterEqual: return FormulaTokenFactory.CreateGreaterEqualToken();
                case FormulaEditorKey.Less: return FormulaTokenFactory.CreateLessToken();
                case FormulaEditorKey.LessEqual: return FormulaTokenFactory.CreateLessEqualToken();
                case FormulaEditorKey.And: return FormulaTokenFactory.CreateAndToken();
                case FormulaEditorKey.Or: return FormulaTokenFactory.CreateOrToken();
                case FormulaEditorKey.Not: return FormulaTokenFactory.CreateNotToken();
                case FormulaEditorKey.Mod: return FormulaTokenFactory.CreateModToken();

                // Functions
                case FormulaEditorKey.Exp: return FormulaTokenFactory.CreateExpToken();
                case FormulaEditorKey.Log: return FormulaTokenFactory.CreateLogToken();
                case FormulaEditorKey.Ln: return FormulaTokenFactory.CreateLnToken();
                case FormulaEditorKey.Min: return FormulaTokenFactory.CreateMinToken();
                case FormulaEditorKey.Max: return FormulaTokenFactory.CreateMaxToken();
                case FormulaEditorKey.Sin: return FormulaTokenFactory.CreateSinToken();
                case FormulaEditorKey.Cos: return FormulaTokenFactory.CreateCosToken();
                case FormulaEditorKey.Tan: return FormulaTokenFactory.CreateTanToken();
                case FormulaEditorKey.Arcsin: return FormulaTokenFactory.CreateArcsinToken();
                case FormulaEditorKey.Arccos: return FormulaTokenFactory.CreateArccosToken();
                case FormulaEditorKey.Arctan: return FormulaTokenFactory.CreateArctanToken();
                case FormulaEditorKey.Sqrt: return FormulaTokenFactory.CreateSqrtToken();
                case FormulaEditorKey.Abs: return FormulaTokenFactory.CreateAbsToken();
                case FormulaEditorKey.Round: return FormulaTokenFactory.CreateRoundToken();
                case FormulaEditorKey.Random: return FormulaTokenFactory.CreateRandomToken();

                // Sensors
                case FormulaEditorKey.AccelerationX: return FormulaTokenFactory.CreateAccelerationXToken();
                case FormulaEditorKey.AccelerationY: return FormulaTokenFactory.CreateAccelerationYToken();
                case FormulaEditorKey.AccelerationZ: return FormulaTokenFactory.CreateAccelerationZToken();
                case FormulaEditorKey.Compass: return FormulaTokenFactory.CreateCompassToken();
                case FormulaEditorKey.InclinationX: return FormulaTokenFactory.CreateInclinationXToken();
                case FormulaEditorKey.InclinationY: return FormulaTokenFactory.CreateInclinationYToken();
                case FormulaEditorKey.Loudness: return FormulaTokenFactory.CreateLoudnessToken();

                // Properties
                case FormulaEditorKey.Brightness: return FormulaTokenFactory.CreateBrightnessToken();
                case FormulaEditorKey.Layer: return FormulaTokenFactory.CreateLayerToken();
                case FormulaEditorKey.Transparency: return FormulaTokenFactory.CreateTransparencyToken();
                case FormulaEditorKey.PositionX: return FormulaTokenFactory.CreatePositionXToken();
                case FormulaEditorKey.PositionY: return FormulaTokenFactory.CreatePositionYToken();
                case FormulaEditorKey.Rotation: return FormulaTokenFactory.CreateRotationToken();
                case FormulaEditorKey.Size: return FormulaTokenFactory.CreateSizeToken();

                // Variables
                case FormulaEditorKey.LocalVariable: return FormulaTokenFactory.CreateLocalVariableToken(localVariable);
                case FormulaEditorKey.GlobalVariable: return FormulaTokenFactory.CreateGlobalVariableToken(globalVariable);

                // brackets
                case FormulaEditorKey.OpeningParenthesis: return FormulaTokenFactory.CreateParenthesisToken(true);
                case FormulaEditorKey.ClosingParenthesis: return FormulaTokenFactory.CreateParenthesisToken(false);

                default: throw new ArgumentOutOfRangeException("key");
            }
        }
Esempio n. 15
0
        public bool HandleKey(FormulaEditorKey key, LocalVariable localVariable = null, GlobalVariable globalVariable = null)
        {
            if (key == FormulaEditorKey.Delete)
            {
                PushUndo();
                return Delete();
            }

            PushUndo();
            var token = CreateToken(key, localVariable, globalVariable);
            return Insert((token is IFormulaFunction)
                ? new[] { token, FormulaTokenFactory.CreateParenthesisToken(true) }
                : new[] { token });
        }
Esempio n. 16
0
        /// <summary>
        /// Sổ nhật ký chung
        /// Gets the report S03 ah.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="commonVariable">The common variable.</param>
        /// <param name="oRsTool">The o rs tool.</param>
        /// <returns></returns>
        public IList <S03AHModel> GetReportS03AH(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            IList <S03AHModel> list;
            var amountType           = GlobalVariable.AmountTypeViewReport;
            var currencyCode         = GlobalVariable.CurrencyViewReport;
            var reportDate           = _globalVariable.PostedDate;
            var isTotalBandInNewPage = false;

            if (!oRsTool.IsRefresh)
            {
                using (var frmParam = new FrmS03a_H())
                {
                    frmParam.ReporDate = _globalVariable.PostedDate;
                    if (frmParam.ShowDialog() == DialogResult.OK)
                    {
                        GlobalVariable.FromDate = DateTime.Parse(frmParam.FromDate);
                        GlobalVariable.ToDate   = DateTime.Parse(frmParam.ToDate);
                        isTotalBandInNewPage    = frmParam.IsTotalBandInNewPage;
                        list = Model.GetS03AHWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), currencyCode, amountType);
                    }
                    else
                    {
                        list = null;
                    }
                }
            }
            else
            {
                list = Model.GetS03AHWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), currencyCode, amountType);
            }
            if (list != null)
            {
                list = list.Where(w => !string.IsNullOrEmpty(w.RefNo)).Select(s =>
                {
                    if (s.AccountNumber.StartsWith("0"))
                    {
                        s.AccountGroupCode = "B";
                    }
                    else
                    {
                        s.AccountGroupCode = "A";
                    }
                    return(s);
                }).ToList();


                if (!oRsTool.Parameters.ContainsKey("CompanyProvince"))
                {
                    oRsTool.Parameters.Add("CompanyProvince", _globalVariable.CompanyProvince);
                }
                if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                {
                    oRsTool.Parameters.Add("ReportDate", reportDate);
                }
                if (amountType == 1)
                {
                    if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                    {
                        oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (qui đổi): " + currencyCode);
                    }
                }
                else
                {
                    if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                    {
                        oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (nguyên tệ): " + currencyCode);
                    }
                }
                if (!oRsTool.Parameters.ContainsKey("FromDate"))
                {
                    oRsTool.Parameters.Add("FromDate", GlobalVariable.FromDate.ToShortDateString());
                }
                if (!oRsTool.Parameters.ContainsKey("ToDate"))
                {
                    oRsTool.Parameters.Add("ToDate", GlobalVariable.ToDate.ToShortDateString());
                }
                if (!oRsTool.Parameters.ContainsKey("Province"))
                {
                    oRsTool.Parameters.Add("Province", _globalVariable.CompanyProvince);
                }
                if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                {
                    oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                }
                if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                {
                    oRsTool.Parameters.Add("ReportDate", _globalVariable.PostedDate);
                }
            }

            return(list);
        }
Esempio n. 17
0
        public IList <AdvancePaymentModel> GetReportAdvancePayment(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            try
            {
                IList <AdvancePaymentModel> list = null;
                var amountType           = GlobalVariable.AmountTypeViewReport;
                var currencyCode         = GlobalVariable.CurrencyViewReport;
                var reportDate           = _globalVariable.PostedDate;
                var isTotalBandInNewPage = false;
                var accountType          = 0;
                if (!oRsTool.IsRefresh)
                {
                    using (var frmParam = new FrmB01H())
                    {
                        if (frmParam.ShowDialog() == DialogResult.OK)
                        {
                            GlobalVariable.FromDate = DateTime.Parse(frmParam.FromDate);
                            GlobalVariable.ToDate   = DateTime.Parse(frmParam.ToDate);
                            isTotalBandInNewPage    = frmParam.IsTotalBandInNewPage;
                            accountType             = frmParam.AccountType;
                            list = Model.GetAdvancePaymentWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), GlobalVariable.CurrencyViewReport, GlobalVariable.AmountTypeViewReport, accountType);
                        }
                    }
                }
                else
                {
                    list = Model.GetAdvancePaymentWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), GlobalVariable.CurrencyViewReport, GlobalVariable.AmountTypeViewReport, accountType);
                }
                if (list != null && list.Count > 0)
                {
                    if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                    {
                        oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                    }
                    //if (!oRsTool.Parameters.ContainsKey("AmountType"))
                    //    oRsTool.Parameters.Add("AmountType", amountType);

                    if (!oRsTool.Parameters.ContainsKey("CompanyProvince"))
                    {
                        oRsTool.Parameters.Add("CompanyProvince", _globalVariable.CompanyProvince);
                    }
                    if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                    {
                        oRsTool.Parameters.Add("ReportDate", reportDate);
                    }
                    if (amountType == 1)
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (qui đổi): " + currencyCode);
                        }
                    }
                    else
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (nguyên tệ): " + currencyCode);
                        }
                    }
                    if (!oRsTool.Parameters.ContainsKey("FromDate"))
                    {
                        oRsTool.Parameters.Add("FromDate", GlobalVariable.FromDate.ToShortDateString());
                    }
                    if (!oRsTool.Parameters.ContainsKey("ToDate"))
                    {
                        oRsTool.Parameters.Add("ToDate", GlobalVariable.ToDate.ToShortDateString());
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Lỗi ở chỗ này " + ex.InnerException + ex.Message + ex.StackTrace);
                return(null);
            }
        }
        private string SendEmailWithAttachment(string Subject, string Message, DataSet ds1, int AD_Org_ID, int Ad_Client_ID)
        {
            string Check = "";
            int    count = 0;
            string res   = "";

            List <string> EmailLst = new List <string>(); //!string.IsNullOrEmpty(EmailIDs) ? EmailIDs.Split(',').ToList() : null;

            int UpdatedBy = GetCtx().GetAD_User_ID();

            sendmail = new VAdvantage.Utility.EMail(GetCtx(), "", "", "", "", "", "", true, false);
            string isConfigExist = sendmail.IsConfigurationExist(GetCtx());

            if (isConfigExist != "OK")
            {
                log.SaveError("Check email configuration", "");
                return(Msg.GetMsg(GetCtx(), "VIS_CheckMailConfig"));
            }

            if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    if (Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "A" ||
                        Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "B" ||
                        Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "E" ||
                        Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "L")
                    {
                        sendmail.AddBcc(Util.GetValueOfString(ds1.Tables[0].Rows[i]["EMAIL"]));
                    }
                }

                sendmail.SetSubject(Subject);
                sendmail.SetMessageText(Message);

                MAttachment mAttach  = GetFileAttachment(GetTable_ID(), GetRecord_ID(), GetCtx());
                string      filePath = "";

                if (mAttach != null && mAttach.AD_Attachment_ID > 0)
                {
                    if (mAttach == null)
                    {
                        return("");
                    }
                    if (mAttach.IsFromHTML())
                    {
                        for (int i = 0; i < mAttach._lines.Count; i++)
                        {
                            filePath = System.IO.Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "TempDownload");
                            filePath = System.IO.Path.Combine(filePath, mAttach.GetFile(mAttach._lines[i].Line_ID));
                            if (filePath.IndexOf("ERROR") > -1)
                            {
                                continue;
                            }
                            filePath = System.IO.Path.Combine(filePath, mAttach._lines[i].FileName);
                            sendmail.AddAttachment(new FileInfo(filePath));
                        }
                    }
                    else
                    {
                        foreach (MAttachmentEntry entry in mAttach.GetEntries())
                        {
                            sendmail.AddAttachment(entry.GetData(), entry.GetName());
                        }
                    }
                }

                Check = sendmail.Send();
                if (Check == "OK")
                {
                    count++;
                }
            }

            if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    if (Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "B" ||
                        Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "C" ||
                        Util.GetValueOfString(ds1.Tables[0].Rows[i]["NOTIFICATIONTYPE"]) == "N")
                    {
                        SendNotice(Message, Util.GetValueOfInt(ds1.Tables[0].Rows[i]["AD_USER_ID"]), AD_Org_ID, Ad_Client_ID);
                    }
                }
            }

            if (count > 0)
            {
                log.Fine("Email Sent Successfully");
                res = Msg.GetMsg(GetCtx(), "VIS_EmailSent");

                string sql = "UPDATE OFFICEMEMO SET PUBLISHDATE = " + GlobalVariable.TO_DATE(System.DateTime.Now, false) + ", PUBLISHTIME = " + GlobalVariable.TO_DATE(System.DateTime.Now, false) + ", PROCESSED = 'Y' WHERE OFFICEMEMO_ID = " + _OfficeMemoID;
                DB.ExecuteQuery(sql, null, null);
            }
            else
            {
                log.SaveError("Email Not Sent", "");
                res = Msg.GetMsg(GetCtx(), "VIS_EmailNotSent");
            }

            return(res);
        }
Esempio n. 19
0
		public void Update(GlobalVariable globalVariable)
		{
			GlobalVariable = globalVariable;
			OnPropertyChanged(() => Name);
			OnPropertyChanged(() => Value);
		}
Esempio n. 20
0
        public VariableManager(ProgramInfo pinfo)
        {
            varkName           = "k";
            csProcName         = "contextSwitch";
            raiseExceptionName = "raiseException";
            errorVarName       = "assertsPassed";
            inAtomicBlockName  = "inAtomicBlock";
            tidVarName         = LanguageSemantics.tidName;
            tidCountVarName    = "tidCount";
            oldkVarName        = "old_k";
            oldtidVarName      = "old_tid";

            cbaMainName = pinfo.mainProcName;
            csProcBound = -1;

            vark = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, varkName, Microsoft.Boogie.Type.Int));

            raiseException = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, raiseExceptionName,
                                                                              Microsoft.Boogie.Type.Bool));

            errorVar = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, errorVarName,
                                                                        Microsoft.Boogie.Type.Bool));

            inAtomicBlock = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, inAtomicBlockName,
                                                                             Microsoft.Boogie.Type.Bool));

            tidVar = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, tidVarName,
                                                                      pinfo.threadIdType));

            tidCountVar = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken, tidCountVarName,
                                                                           pinfo.threadIdType));

            // Construct type int -> bool
            var ts = new List <Microsoft.Boogie.Type>();

            ts.Add(pinfo.threadIdType);
            MapType mt = new MapType(Token.NoToken, new List <TypeVariable>(), ts, Microsoft.Boogie.Type.Bool);

            // Construct type int -> int
            mt = new MapType(Token.NoToken, new List <TypeVariable>(), ts, Microsoft.Boogie.Type.Int);

            oldkLocalVars   = new Dictionary <string, LocalVariable>();
            oldtidLocalVars = new Dictionary <string, LocalVariable>();

            declaredGlobals = pinfo.declaredGlobals;

            numCopiesCreated = 0;
            gblVarCopies     = new Dictionary <string, List <GlobalVariable> >();
            gblVarInitCopies = new Dictionary <string, List <GlobalVariable> >();

            // Make some copies for now
            makeCopies(1);

            // Check if any of variables we're going to insert
            // have any clashes with what is existing
            if (declaredGlobals.ContainsKey(varkName) ||
                declaredGlobals.ContainsKey(raiseExceptionName) ||
                declaredGlobals.ContainsKey(errorVarName) ||
                declaredGlobals.ContainsKey(inAtomicBlockName) ||
                pinfo.allProcs.Contains(csProcName))
            {
                throw new InvalidProg("Possible name clashes!");
            }
        }
 public static void DeleteGlobalVariable(Program project, GlobalVariable variable)
 {
     project.GlobalVariables.Remove(variable);
 }
 private void Start()
 {
     GlobalVariable.Add(new Variable("AxisX", VariableType.v_float, 0f, new VariableParameters(true, VariableAccessType.v_readonly)));
     GlobalVariable.Add(new Variable("AxisY", VariableType.v_float, 0f, new VariableParameters(true, VariableAccessType.v_readonly)));
 }
 public static FormulaNodeGlobalVariable CreateGlobalVariableToken(GlobalVariable variable)
 {
     return FormulaTreeFactory.CreateGlobalVariableNode(variable);
 }
Esempio n. 24
0
        /// <summary>
        /// Create Difference Document.
        ///	Creates one or two inventory lines
        /// </summary>
        /// <param name="move">movement</param>
        /// <param name="confirm">confirm line</param>
        /// <returns>true if created</returns>
        private Boolean CreateDifferenceDoc(MMovement move, MMovementLineConfirm confirm)
        {
            string        query      = "";
            int           result     = 0;
            decimal       currentQty = 0;
            MMovementLine mLine      = confirm.GetLine();

            //Added By amit 11-jun-2015
            //Opening Stock , Qunatity Book => CurrentQty From Transaction of MovementDate
            //As On Date Count = Opening Stock - Diff Qty
            //Qty Count = Qty Book - Diff Qty
            query  = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate = " + GlobalVariable.TO_DATE(move.GetMovementDate(), true) + @" 
                           AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID();
            result = Util.GetValueOfInt(DB.ExecuteScalar(query));
            if (result > 0)
            {
                query      = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate <= " + GlobalVariable.TO_DATE(move.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID() + @")
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID() + @")
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID();
                currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(query));
            }
            else
            {
                query  = "SELECT COUNT(*) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(move.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID();
                result = Util.GetValueOfInt(DB.ExecuteScalar(query));
                if (result > 0)
                {
                    query      = @"SELECT currentqty FROM M_Transaction WHERE M_Transaction_ID =
                            (SELECT MAX(M_Transaction_ID)   FROM M_Transaction
                            WHERE movementdate =     (SELECT MAX(movementdate) FROM M_Transaction WHERE movementdate < " + GlobalVariable.TO_DATE(move.GetMovementDate(), true) + @" 
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID() + @")
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID() + @")
                            AND  M_Product_ID = " + mLine.GetM_Product_ID() + " AND M_Locator_ID = " + mLine.GetM_Locator_ID() + " AND M_AttributeSetInstance_ID = " + mLine.GetM_AttributeSetInstance_ID();
                    currentQty = Util.GetValueOfDecimal(DB.ExecuteScalar(query));
                }
            }
            //End

            //	Difference - Create Inventory Difference for Source Location
            if (Env.ZERO.CompareTo(confirm.GetDifferenceQty()) != 0)
            {
                //	Get Warehouse for Source
                MLocator loc = MLocator.Get(GetCtx(), mLine.GetM_Locator_ID());
                if (_inventoryFrom != null &&
                    _inventoryFrom.GetM_Warehouse_ID() != loc.GetM_Warehouse_ID())
                {
                    _inventoryFrom = null;
                }

                if (_inventoryFrom == null)
                {
                    MWarehouse wh = MWarehouse.Get(GetCtx(), loc.GetM_Warehouse_ID());
                    _inventoryFrom = new MInventory(wh);
                    _inventoryFrom.SetDescription(Msg.Translate(GetCtx(), "M_MovementConfirm_ID") + " " + GetDocumentNo());
                    if (!_inventoryFrom.Save(Get_TrxName()))
                    {
                        _processMsg += "Inventory not created";
                        return(false);
                    }
                    //	First Inventory
                    if (GetM_Inventory_ID() == 0)
                    {
                        SetM_Inventory_ID(_inventoryFrom.GetM_Inventory_ID());
                        _inventoryInfo = _inventoryFrom.GetDocumentNo();
                    }
                    else
                    {
                        _inventoryInfo += "," + _inventoryFrom.GetDocumentNo();
                    }
                }

                log.Info("createDifferenceDoc - Difference=" + confirm.GetDifferenceQty());

                MInventoryLine line = new MInventoryLine(_inventoryFrom, mLine.GetM_Locator_ID(), mLine.GetM_Product_ID(),
                                                         mLine.GetM_AttributeSetInstance_ID(), confirm.GetDifferenceQty(), Env.ZERO);

                line.SetAdjustmentType("D");
                line.SetDifferenceQty(Util.GetValueOfDecimal(confirm.GetDifferenceQty()));
                line.SetQtyBook(currentQty);
                line.SetOpeningStock(currentQty);
                line.SetAsOnDateCount(Decimal.Subtract(Util.GetValueOfDecimal(line.GetOpeningStock()), Util.GetValueOfDecimal(confirm.GetDifferenceQty())));
                line.SetQtyCount(Decimal.Subtract(Util.GetValueOfDecimal(line.GetQtyBook()), Util.GetValueOfDecimal(confirm.GetDifferenceQty())));

                //JID_1185: System does not update the Qunatity and UoM on Physical Inventory Document.
                line.Set_Value("C_UOM_ID", mLine.GetC_UOM_ID());
                line.Set_Value("QtyEntered", confirm.GetDifferenceQty());

                line.SetDescription(Msg.Translate(GetCtx(), "DifferenceQty"));
                if (!line.Save(Get_TrxName()))
                {
                    _processMsg += "Inventory Line not created";
                    return(false);
                }
                confirm.SetM_InventoryLine_ID(line.GetM_InventoryLine_ID());
            }   //	Difference

            //	Scrapped - Create Inventory Difference for TarGet Location
            if (Env.ZERO.CompareTo(confirm.GetScrappedQty()) != 0)
            {
                //	Get Warehouse for TarGet
                MLocator loc = MLocator.Get(GetCtx(), mLine.GetM_LocatorTo_ID());
                if (_inventoryTo != null &&
                    _inventoryTo.GetM_Warehouse_ID() != loc.GetM_Warehouse_ID())
                {
                    _inventoryTo = null;
                }

                if (_inventoryTo == null)
                {
                    MWarehouse wh = MWarehouse.Get(GetCtx(), loc.GetM_Warehouse_ID());
                    _inventoryTo = new MInventory(wh);
                    _inventoryTo.SetDescription(Msg.Translate(GetCtx(), "M_MovementConfirm_ID") + " " + GetDocumentNo());
                    if (!_inventoryTo.Save(Get_TrxName()))
                    {
                        _processMsg += "Inventory not created";
                        return(false);
                    }
                    //	First Inventory
                    if (GetM_Inventory_ID() == 0)
                    {
                        SetM_Inventory_ID(_inventoryTo.GetM_Inventory_ID());
                        _inventoryInfo = _inventoryTo.GetDocumentNo();
                    }
                    else
                    {
                        _inventoryInfo += "," + _inventoryTo.GetDocumentNo();
                    }
                }

                log.Info("CreateDifferenceDoc - Scrapped=" + confirm.GetScrappedQty());
                MInventoryLine line = new MInventoryLine(_inventoryTo,
                                                         mLine.GetM_LocatorTo_ID(), mLine.GetM_Product_ID(), mLine.GetM_AttributeSetInstance_ID(),
                                                         confirm.GetScrappedQty(), Env.ZERO);
                line.SetDescription(Msg.Translate(GetCtx(), "ScrappedQty"));

                //JID_1185: System does not update the Qunatity and UoM on Physical Inventory Document.
                line.Set_Value("C_UOM_ID", mLine.GetC_UOM_ID());
                line.Set_Value("QtyEntered", confirm.GetDifferenceQty());

                // JID_0804 Ship receipt confirm with scrap Qty
                line.SetAdjustmentType("D");
                line.SetDifferenceQty(Util.GetValueOfDecimal(confirm.GetScrappedQty()));
                line.SetQtyBook(currentQty);
                line.SetOpeningStock(currentQty);
                line.SetAsOnDateCount(Decimal.Subtract(Util.GetValueOfDecimal(line.GetOpeningStock()), Util.GetValueOfDecimal(confirm.GetScrappedQty())));
                line.SetQtyCount(Decimal.Subtract(Util.GetValueOfDecimal(line.GetQtyBook()), Util.GetValueOfDecimal(confirm.GetScrappedQty())));

                if (!line.Save(Get_TrxName()))
                {
                    _processMsg += "Inventory Line not created";
                    return(false);
                }
                confirm.SetM_InventoryLine_ID(line.GetM_InventoryLine_ID());
            }   //	Scrapped

            return(true);
        }
Esempio n. 25
0
 public override GlobalVariable VisitGlobalVariable(GlobalVariable node)
 {
     return(node);
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes the variables.
 /// </summary>
 private void InitVariables()
 {
     ActionMode      = ActionModeVoucherEnum.None;
     _globalVariable = new GlobalVariable();
     PostedDate      = _globalVariable.PostedDate;
 }
Esempio n. 27
0
        /// <summary>
        /// Create/Add to Inventory Line Query
        /// </summary>
        /// <param name="M_Locator_ID">locator</param>
        /// <param name="M_Product_ID">product</param>
        /// <param name="M_AttributeSetInstance_ID">asi</param>
        /// <param name="qtyOnHand">quantity</param>
        /// <param name="M_AttributeSet_ID">attribute set</param>
        /// <returns>lines added</returns>
        private string InsertInventoryLine(int M_Locator_ID, int M_Product_ID, int lineNo,
                                           int M_AttributeSetInstance_ID, Decimal qtyOnHand, int M_AttributeSet_ID)
        {
            MInventoryLine line           = new MInventoryLine(GetCtx(), 0, Get_Trx());
            int            line_ID        = DB.GetNextID(GetCtx(), "M_InventoryLine", Get_Trx());
            string         qry            = "select m_warehouse_id from m_locator where m_locator_id=" + M_Locator_ID;
            int            M_Warehouse_ID = Util.GetValueOfInt(DB.ExecuteScalar(qry, null, Get_Trx()));
            MWarehouse     wh             = MWarehouse.Get(GetCtx(), M_Warehouse_ID);

            if (wh.IsDisallowNegativeInv() == true)
            {
                if (qtyOnHand < 0)
                {
                    return("");
                }
            }
            MProduct product = MProduct.Get(GetCtx(), M_Product_ID);

            if (product != null)
            {
                int precision = product.GetUOMPrecision();
                if (Env.Signum(qtyOnHand) != 0)
                {
                    qtyOnHand = Decimal.Round(qtyOnHand, precision, MidpointRounding.AwayFromZero);
                }
            }
            string sql = @"INSERT INTO M_InventoryLine (AD_Client_ID, AD_Org_ID,IsActive, Created, CreatedBy, Updated, UpdatedBy, Line, M_Inventory_ID, M_InventoryLine_ID,  
                M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, QtyBook, QtyCount, OpeningStock, AsOnDateCount, DifferenceQty, AdjustmentType";

            if (line.Get_ColumnIndex("C_UOM_ID") > 0)
            {
                sql += ", QtyEntered, C_UOM_ID";
            }

            if (line.Get_ColumnIndex("IsFromProcess") > 0)
            {
                sql += ",IsFromProcess";
            }
            sql += " ) VALUES ( " + _inventory.GetAD_Client_ID() + "," + _inventory.GetAD_Org_ID() + ",'Y'," + GlobalVariable.TO_DATE(DateTime.Now, true) + "," + 0 + "," +
                   GlobalVariable.TO_DATE(DateTime.Now, true) + "," + 0 + "," + lineNo + "," + _m_Inventory_ID + "," + line_ID + "," + M_Locator_ID + "," + M_Product_ID + "," +
                   M_AttributeSetInstance_ID + "," + qtyOnHand + "," + qtyOnHand + "," + qtyOnHand + "," + qtyOnHand + "," + 0 + ",'A'";

            if (line.Get_ColumnIndex("C_UOM_ID") > 0)
            {
                sql += "," + qtyOnHand + "," + product.GetC_UOM_ID();
            }

            if (line.Get_ColumnIndex("IsFromProcess") > 0)
            {
                sql += ",'Y'";
            }
            string insertQry = " BEGIN execute immediate('" + sql.Replace("'", "''") + ")'); exception when others then null; END;";

            return(insertQry);
        }
Esempio n. 28
0
 public static bool IsPermitted(ObjectNames objectName, int permissionToCheck)
 {
     return(IsPermitted(GlobalVariable.GetPermission((int)objectName), permissionToCheck));
 }
Esempio n. 29
0
        /// <summary>
        /// Sổ chi Cái tài khoản
        /// Gets the report S03 bh.
        /// LinhMC thêm code kiểm tra nếu là xem báo cáo bằng cách truy xuất từ báo cáo khác thì không cần mở form lấy tham số báo cáo
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="commonVariable">The common variable.</param>
        /// <param name="oRsTool">The o rs tool.</param>
        /// <returns></returns>
        public IList <S03BHModel> GetReportS03BH(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            IList <S03BHModel> list  = null;
            var amountType           = GlobalVariable.AmountTypeViewReport;
            var currencyCode         = GlobalVariable.CurrencyViewReport;
            var isTotalBandInNewPage = false;

            if (commonVariable.IsDrillDownReport)
            {
                GlobalVariable.FromDate = DateTime.Parse(commonVariable.DrillDownParram[9].ToString());
                GlobalVariable.ToDate   = DateTime.Parse(commonVariable.DrillDownParram[10].ToString());
                var          accountNumber = commonVariable.DrillDownParram[4].ToString();
                const string correspondingAccountNumber = "";
                amountType   = int.Parse(commonVariable.DrillDownParram[2].ToString());
                currencyCode = commonVariable.DrillDownParram[3].ToString();

                list = Model.GetS03BHWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), amountType, accountNumber, correspondingAccountNumber, currencyCode);

                var accountName = Model.GetAccountByCode(accountNumber).AccountName;

                if (!oRsTool.Parameters.ContainsKey("Account"))
                {
                    oRsTool.Parameters.Add("Account", "Tài khoản: " + accountNumber + " - " + accountName);
                }

                if (!oRsTool.Parameters.ContainsKey("AccountNumber"))
                {
                    oRsTool.Parameters.Add("AccountNumber", accountNumber);
                }

                if (!oRsTool.Parameters.ContainsKey("CorrespondingAccountNumber"))
                {
                    oRsTool.Parameters.Add("CorrespondingAccountNumber", correspondingAccountNumber);
                }
            }
            else
            {
                if (!oRsTool.IsRefresh)
                {
                    using (var frmParam = new FrmS03BH())
                    {
                        frmParam.Text = @"Sổ cái";
                        if (frmParam.ShowDialog() == DialogResult.OK)
                        {
                            GlobalVariable.FromDate = DateTime.Parse(frmParam.FromDate);
                            GlobalVariable.ToDate   = DateTime.Parse(frmParam.ToDate);
                            isTotalBandInNewPage    = frmParam.IsTotalBandInNewPage;
                            var accountNumber = frmParam.AccountCode;
                            if (!oRsTool.Parameters.ContainsKey("Account"))
                            {
                                oRsTool.Parameters.Add("Account", "Tài khoản: " + accountNumber + " - " + frmParam.AccountName);
                            }

                            if (!oRsTool.Parameters.ContainsKey("AccountNumber"))
                            {
                                oRsTool.Parameters.Add("AccountNumber", accountNumber);
                            }

                            var correspondingAccountNumber = frmParam.CorrespondingAccountNumber;
                            if (!oRsTool.Parameters.ContainsKey("CorrespondingAccountNumber"))
                            {
                                oRsTool.Parameters.Add("CorrespondingAccountNumber", correspondingAccountNumber);
                            }

                            if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                            {
                                oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                            }

                            list = Model.GetS03BHWithStoreProdure(commonVariable.ReportList.ProcedureName,
                                                                  GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(),
                                                                  amountType, accountNumber, correspondingAccountNumber, currencyCode);
                        }
                    }
                }
                else
                {
                    var accountNumber = oRsTool.Parameters["AccountNumber"].ToString();
                    var correspondingAccountNumber = oRsTool.Parameters["CorrespondingAccountNumber"].ToString();
                    list = Model.GetS03BHWithStoreProdure(commonVariable.ReportList.ProcedureName,
                                                          GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(),
                                                          amountType, accountNumber, correspondingAccountNumber, currencyCode);
                }
            }
            if (list != null && list.Count > 0)
            {
                if (!oRsTool.Parameters.ContainsKey("Year"))
                {
                    oRsTool.Parameters.Add("Year", "Năm:" + GlobalVariable.ToDate.Year);
                }
                if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                {
                    oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính " + (amountType == 2 ? "(nguyên tệ): " : "(tính quy đổi): ") + currencyCode);
                }
                if (!oRsTool.Parameters.ContainsKey("FromDate"))
                {
                    oRsTool.Parameters.Add("FromDate", GlobalVariable.FromDate.ToShortDateString());
                }
                if (!oRsTool.Parameters.ContainsKey("ToDate"))
                {
                    oRsTool.Parameters.Add("ToDate", GlobalVariable.ToDate.ToShortDateString());
                }
                if (!oRsTool.Parameters.ContainsKey("Province"))
                {
                    oRsTool.Parameters.Add("Province", _globalVariable.CompanyProvince);
                }

                if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                {
                    oRsTool.Parameters.Add("ReportDate", _globalVariable.PostedDate);
                }
            }

            return(list);
        }
Esempio n. 30
0
 public TypeUnify(Program program)
 {
     U = new GlobalVariable(Token.NoToken, new TypedIdent(Token.NoToken,
                                                          "Mem_T.All", BoogieAstFactory.MkMapType(Microsoft.Boogie.Type.Int, Microsoft.Boogie.Type.Int)));
     this.program = program;
 }
Esempio n. 31
0
        /// <summary>
        /// Sổ chi tiết tài khoản
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="commonVariable">The common variable.</param>
        /// <param name="oRsTool">The o rs tool.</param>
        /// <returns></returns>
        public IList <S33HModel> GetReportS33H(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            IList <S33HModel> list;
            var amountType           = GlobalVariable.AmountTypeViewReport;
            var isTotalBandInNewPage = false;

            if (!oRsTool.IsRefresh)
            {
                using (var frmParam = new FrmS33H())
                {
                    if (frmParam.ShowDialog() == DialogResult.OK)
                    {
                        string FromDate     = DateTime.Parse(frmParam.FromDate).ToShortDateString();
                        string ToDate       = DateTime.Parse(frmParam.ToDate).ToShortDateString();
                        string whereClause  = frmParam.WhereClause;
                        string accountCode  = frmParam.AccountCode;
                        string accountName  = frmParam.AccountName;
                        string currencyCode = GlobalVariable.CurrencyViewReport;
                        //string currencyCode = frmParam.CurrencyCode;
                        string fixedAssetCode  = frmParam.FixedAssetCode;
                        string budgetGroupCode = frmParam.BudgetGroupCode;
                        string departmentCode  = frmParam.DepartmentCode;
                        isTotalBandInNewPage = frmParam.IsTotalBandInNewPage;
                        string selectedField         = frmParam.SelectedField;
                        string selectedAllValueField = frmParam.SelectedAllValueField;

                        if (amountType == 1)
                        {
                            if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                            {
                                oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (qui đổi): " + currencyCode);
                            }
                        }
                        else
                        {
                            if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                            {
                                oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (nguyên tệ): " + currencyCode);
                            }
                        }

                        if (!oRsTool.Parameters.ContainsKey("EmployeeName"))
                        {
                            oRsTool.Parameters.Add("EmployeeName", frmParam.EmployeeName);
                        }
                        if (!oRsTool.Parameters.ContainsKey("VendorId"))
                        {
                            oRsTool.Parameters.Add("VendorId", frmParam.VendorId);
                        }
                        if (!oRsTool.Parameters.ContainsKey("VendorName"))
                        {
                            oRsTool.Parameters.Add("VendorName", frmParam.VendorName);
                        }
                        if (!oRsTool.Parameters.ContainsKey("AccountingObjectId"))
                        {
                            oRsTool.Parameters.Add("AccountingObjectId", frmParam.AccountingObjectId);
                        }
                        if (!oRsTool.Parameters.ContainsKey("FullName"))
                        {
                            oRsTool.Parameters.Add("FullName", frmParam.FullName);
                        }
                        if (!oRsTool.Parameters.ContainsKey("AccountCode"))
                        {
                            oRsTool.Parameters.Add("AccountCode",
                                                   "Tên tài khoản: " + accountName + " Số hiệu: " + accountCode);
                        }
                        if (!oRsTool.Parameters.ContainsKey("FromDate"))
                        {
                            oRsTool.Parameters.Add("FromDate", FromDate);
                        }
                        if (!oRsTool.Parameters.ContainsKey("ToDate"))
                        {
                            oRsTool.Parameters.Add("ToDate", ToDate);
                        }
                        // ThoDD add chuyển dòng sang trang sau
                        if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                        {
                            oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                        }

                        /*=== LinhMC add thêm 1 số biến lưu giữ giá trị, để Refresh dữ liệu ===*/
                        if (!oRsTool.Parameters.ContainsKey("WhereClause"))
                        {
                            oRsTool.Parameters.Add("WhereClause", frmParam.WhereClause);
                        }
                        if (!oRsTool.Parameters.ContainsKey("AccountNumber"))
                        {
                            oRsTool.Parameters.Add("AccountNumber", accountCode);
                        }


                        if (!oRsTool.Parameters.ContainsKey("BudgetGroupCode"))
                        {
                            oRsTool.Parameters.Add("BudgetGroupCode", budgetGroupCode);
                        }
                        if (!oRsTool.Parameters.ContainsKey("FixedAssetCode"))
                        {
                            oRsTool.Parameters.Add("FixedAssetCode", fixedAssetCode);
                        }

                        if (!oRsTool.Parameters.ContainsKey("DepartmentCode"))
                        {
                            oRsTool.Parameters.Add("DepartmentCode", departmentCode);
                        }

                        if (!oRsTool.Parameters.ContainsKey("SelectedField"))
                        {
                            oRsTool.Parameters.Add("SelectedField", frmParam.SelectedField);
                        }

                        if (!oRsTool.Parameters.ContainsKey("SelectedAllValueField"))
                        {
                            oRsTool.Parameters.Add("SelectedAllValueField", frmParam.SelectedAllValueField);
                        }

                        if (!oRsTool.Parameters.ContainsKey("ObjectName"))
                        {
                            oRsTool.Parameters.Add("ObjectName", frmParam.ObjectName);
                        }

                        if (!oRsTool.Parameters.ContainsKey("Province"))
                        {
                            oRsTool.Parameters.Add("Province", _globalVariable.CompanyProvince);
                        }

                        if (!oRsTool.Parameters.ContainsKey("ObjectName"))
                        {
                            oRsTool.Parameters.Add("ObjectName", frmParam.ObjectName);
                        }

                        if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                        {
                            oRsTool.Parameters.Add("ReportDate", _globalVariable.PostedDate);
                        }

                        list = Model.GetS33HWithStoreProdure(commonVariable.ReportList.ProcedureName, accountCode, FromDate, ToDate, currencyCode, budgetGroupCode, fixedAssetCode, departmentCode, amountType, whereClause);

                        if (!oRsTool.Parameters.ContainsKey("ckAccountNumber"))
                        {
                            oRsTool.Parameters.Add("ckAccountNumber", list[list.Count - 1].DebitAmountBalance);
                        }

                        if (!oRsTool.Parameters.ContainsKey("ckCorrAccountNumber"))
                        {
                            oRsTool.Parameters.Add("ckCorrAccountNumber", list[list.Count - 1].CreditAmountBalance);
                        }
                        list.RemoveAt(list.Count - 1);
                    }

                    else
                    {
                        list = null;
                    }
                }
            }
            else
            {
                var    accountCode           = oRsTool.Parameters["AccountNumber"].ToString();
                var    currencyCode          = oRsTool.Parameters["CurrencyCode"].ToString();
                var    whereClause           = oRsTool.Parameters["WhereClause"].ToString();
                var    budgetGroupCode       = oRsTool.Parameters["BudgetGroupCode"].ToString();
                var    fixedAssetCode        = oRsTool.Parameters["FixedAssetCode"].ToString();
                var    selectedField         = oRsTool.Parameters["SelectedField"].ToString();
                var    selectedAllValueField = oRsTool.Parameters["SelectedAllValueField"].ToString();
                string departmentCode        = oRsTool.Parameters["DepartmentCode"].ToString();
                string fromDate = oRsTool.Parameters["FromDate"].ToString();
                string toDate   = oRsTool.Parameters["ToDate"].ToString();

                list = Model.GetS33HWithStoreProdure(commonVariable.ReportList.ProcedureName, accountCode, fromDate, toDate, currencyCode, budgetGroupCode, fixedAssetCode, departmentCode, amountType, whereClause, selectedField, selectedAllValueField);
            }
            return(list);
        }
Esempio n. 32
0
 // Update is called once per frame
 void Update()
 {
     playerGold    = GlobalVariable.GetPlayerGold();
     GoldText.text = "$" + playerGold;
 }
Esempio n. 33
0
        public IList <S05HGroupModel> GetReportS05H(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            try
            {
                IList <S05HModel> list      = null;
                S05HGroupModel    s05HGroup = new S05HGroupModel();
                var amountType           = GlobalVariable.AmountTypeViewReport;
                var currencyCode         = GlobalVariable.CurrencyViewReport;
                var reportDate           = _globalVariable.PostedDate;
                var isTotalBandInNewPage = false;

                if (!oRsTool.IsRefresh)
                {
                    using (var frmParam = new FrmB01H())
                    {
                        if (frmParam.ShowDialog() == DialogResult.OK)
                        {
                            GlobalVariable.FromDate = DateTime.Parse(frmParam.FromDate);
                            GlobalVariable.ToDate   = DateTime.Parse(frmParam.ToDate);
                            isTotalBandInNewPage    = frmParam.IsTotalBandInNewPage;

                            list = Model.GetS05HWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), currencyCode, amountType);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    list = Model.GetS05HWithStoreProdure(commonVariable.ReportList.ProcedureName, GlobalVariable.FromDate.ToShortDateString(), GlobalVariable.ToDate.ToShortDateString(), currencyCode, amountType);
                }
                if (list != null && list.Count > 0)
                {
                    foreach (var obj in list.ToList())
                    {
                        if (obj.ClosingCredit == 0 && obj.ClosingDebit == 0 && obj.MovementAccumCredit == 0 && obj.MovementAccumDebit == 0 && obj.MovementCredit == 0 && obj.MovementDebit == 0 && obj.OpeningCredit == 0 && obj.OpeningDebit == 0)
                        {
                            list.Remove(obj);
                        }
                    }

                    s05HGroup.GroupA = list.Where(w => !w.AccountCode.StartsWith("0")).ToList() ?? new List <S05HModel>();
                    s05HGroup.GroupB = list.Where(w => w.AccountCode.StartsWith("0")).ToList() ?? new List <S05HModel>();

                    if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                    {
                        oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                    }

                    if (!oRsTool.Parameters.ContainsKey("CompanyProvince"))
                    {
                        oRsTool.Parameters.Add("CompanyProvince", _globalVariable.CompanyProvince);
                    }
                    if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                    {
                        oRsTool.Parameters.Add("ReportDate", reportDate);
                    }
                    if (amountType == 1)
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (qui đổi): " + currencyCode);
                        }
                    }
                    else
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (nguyên tệ): " + currencyCode);
                        }
                    }
                    if (!oRsTool.Parameters.ContainsKey("FromDate"))
                    {
                        oRsTool.Parameters.Add("FromDate", GlobalVariable.FromDate.ToShortDateString());
                    }
                    if (!oRsTool.Parameters.ContainsKey("ToDate"))
                    {
                        oRsTool.Parameters.Add("ToDate", GlobalVariable.ToDate.ToShortDateString());
                    }

                    //decimal TotalOpeningCredit = list.Where(x => x.Grade == 1).Sum(x => x.OpeningCredit);
                    //decimal TotalOpeningDebit = list.Where(x => x.Grade == 1).Sum(x => x.OpeningDebit);
                    //decimal TotalMovementAccumCredit = list.Where(x => x.Grade == 1).Sum(x => x.MovementAccumCredit);
                    //decimal TotalMovementAccumDebit = list.Where(x => x.Grade == 1).Sum(x => x.MovementAccumDebit);
                    //decimal TotalMovementCredit = list.Where(x => x.Grade == 1).Sum(x => x.MovementCredit);
                    //decimal TotalMovementDebit = list.Where(x => x.Grade == 1).Sum(x => x.MovementDebit);
                    //decimal TotalClosingCredit = list.Where(x => x.Grade == 1).Sum(x => x.ClosingCredit);
                    //decimal TotalClosingDebit = list.Where(x => x.Grade == 1).Sum(x => x.ClosingDebit);
                    decimal TotalOpeningCredit       = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.OpeningCredit);
                    decimal TotalOpeningDebit        = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.OpeningDebit);
                    decimal TotalMovementAccumCredit = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.MovementAccumCredit);
                    decimal TotalMovementAccumDebit  = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.MovementAccumDebit);
                    decimal TotalMovementCredit      = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.MovementCredit);
                    decimal TotalMovementDebit       = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.MovementDebit);
                    decimal TotalClosingCredit       = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.ClosingCredit);
                    decimal TotalClosingDebit        = s05HGroup.GroupA.Where(x => x.Grade == 1).Sum(x => x.ClosingDebit);

                    if (!oRsTool.Parameters.ContainsKey("TotalMovementCredit"))
                    {
                        oRsTool.Parameters.Add("TotalMovementCredit", TotalMovementCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementDebit"))
                    {
                        oRsTool.Parameters.Add("TotalMovementDebit", TotalMovementDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalClosingCredit"))
                    {
                        oRsTool.Parameters.Add("TotalClosingCredit", TotalClosingCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalClosingDebit"))
                    {
                        oRsTool.Parameters.Add("TotalClosingDebit", TotalClosingDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalOpeningCredit"))
                    {
                        oRsTool.Parameters.Add("TotalOpeningCredit", TotalOpeningCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalOpeningDebit"))
                    {
                        oRsTool.Parameters.Add("TotalOpeningDebit", TotalOpeningDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementAccumCredit"))
                    {
                        oRsTool.Parameters.Add("TotalMovementAccumCredit", TotalMovementAccumCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementAccumDebit"))
                    {
                        oRsTool.Parameters.Add("TotalMovementAccumDebit", TotalMovementAccumDebit);
                    }

                    TotalOpeningCredit       = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.OpeningCredit);
                    TotalOpeningDebit        = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.OpeningDebit);
                    TotalMovementAccumCredit = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.MovementAccumCredit);
                    TotalMovementAccumDebit  = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.MovementAccumDebit);
                    TotalMovementCredit      = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.MovementCredit);
                    TotalMovementDebit       = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.MovementDebit);
                    TotalClosingCredit       = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.ClosingCredit);
                    TotalClosingDebit        = s05HGroup.GroupB.Where(x => x.Grade == 1).Sum(x => x.ClosingDebit);
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementCreditGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalMovementCreditGroupB", TotalMovementCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementDebitGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalMovementDebitGroupB", TotalMovementDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalClosingCreditGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalClosingCreditGroupB", TotalClosingCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalClosingDebitGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalClosingDebitGroupB", TotalClosingDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalOpeningCreditGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalOpeningCreditGroupB", TotalOpeningCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalOpeningDebitGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalOpeningDebitGroupB", TotalOpeningDebit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementAccumCreditGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalMovementAccumCreditGroupB", TotalMovementAccumCredit);
                    }
                    if (!oRsTool.Parameters.ContainsKey("TotalMovementAccumDebitGroupB"))
                    {
                        oRsTool.Parameters.Add("TotalMovementAccumDebitGroupB", TotalMovementAccumDebit);
                    }
                }
                else
                {
                    return(new List <S05HGroupModel>());
                }

                return(new List <S05HGroupModel> {
                    s05HGroup
                });
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Lỗi ở chỗ này " + ex.InnerException + ex.Message + ex.StackTrace);
                return(null);
            }
        }
Esempio n. 34
0
        public static ProverInterface CreateProver(Program prog, string /*?*/ logFilePath, bool appendLogFile, int timeout, int taskID = -1)
        {
            Contract.Requires(prog != null);

            ProverOptions options = cce.NonNull(CommandLineOptions.Clo.TheProverFactory).BlankProverOptions();

            if (logFilePath != null)
            {
                options.LogFilename = logFilePath;
                if (appendLogFile)
                {
                    options.AppendLogFile = appendLogFile;
                }
            }

            if (timeout > 0)
            {
                options.TimeLimit = timeout * 1000;
            }

            if (taskID >= 0)
            {
                options.Parse(CommandLineOptions.Clo.Cho[taskID].ProverOptions);
            }
            else
            {
                options.Parse(CommandLineOptions.Clo.ProverOptions);
            }

            ProverContext ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);

            // set up the context
            foreach (Declaration decl in prog.TopLevelDeclarations)
            {
                Contract.Assert(decl != null);
                TypeCtorDecl t = decl as TypeCtorDecl;
                if (t != null)
                {
                    ctx.DeclareType(t, null);
                }
            }
            foreach (Declaration decl in prog.TopLevelDeclarations)
            {
                Contract.Assert(decl != null);
                Constant c = decl as Constant;
                if (c != null)
                {
                    ctx.DeclareConstant(c, c.Unique, null);
                }
                else
                {
                    Function f = decl as Function;
                    if (f != null)
                    {
                        ctx.DeclareFunction(f, null);
                    }
                }
            }
            foreach (var ax in prog.Axioms)
            {
                ctx.AddAxiom(ax, null);
            }
            foreach (Declaration decl in prog.TopLevelDeclarations)
            {
                Contract.Assert(decl != null);
                GlobalVariable v = decl as GlobalVariable;
                if (v != null)
                {
                    ctx.DeclareGlobalVariable(v, null);
                }
            }

            return((ProverInterface)CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx));
        }
Esempio n. 35
0
        public IList <TSD.AccountingSoft.Model.BusinessObjects.Report.LedgerAccounting.ReportS104HModel> GetReportS104H(XtraForm frmParent, GlobalVariable commonVariable, ReportSharpHelper oRsTool)
        {
            try
            {
                IList <TSD.AccountingSoft.Model.BusinessObjects.Report.LedgerAccounting.ReportS104HModel> lstResults = null;
                var amountType           = GlobalVariable.AmountTypeViewReport;
                var currencyCode         = GlobalVariable.CurrencyViewReport;
                var reportDate           = _globalVariable.PostedDate;
                var isTotalBandInNewPage = false;

                DateTime fromDate = GlobalVariable.FromDate;
                DateTime toDate   = GlobalVariable.ToDate;
                DateTime?openDate = null;
                string   selectedBudgetSourceCodes = "";
                string   expenseName = "NSNN";

                if (!oRsTool.IsRefresh)
                {
                    using (var frmParam = new FrmLedgerAccountingS104H())
                    {
                        frmParam.Text = "Sổ theo dõi kinh phí NSNN cấp bằng lệnh chi tiền";
                        if (frmParam.ShowDialog() == DialogResult.OK)
                        {
                            fromDate = frmParam.FromDate;
                            toDate   = frmParam.ToDate;
                            openDate = frmParam.OpenDate;
                            selectedBudgetSourceCodes = frmParam.SelectedBudgetSourceCodes;
                            expenseName = frmParam.ExpenseName;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }

                lstResults = Model.LedgerAccountingS104H(commonVariable.ReportList.ProcedureName, fromDate.ToShortDateString(), toDate.ToShortDateString(), selectedBudgetSourceCodes, currencyCode, amountType);
                if (lstResults != null && lstResults.Count > 0)
                {
                    if (!oRsTool.Parameters.ContainsKey("IsTotalBandInNewPage"))
                    {
                        oRsTool.Parameters.Add("IsTotalBandInNewPage", isTotalBandInNewPage);
                    }

                    if (!oRsTool.Parameters.ContainsKey("CompanyProvince"))
                    {
                        oRsTool.Parameters.Add("CompanyProvince", _globalVariable.CompanyProvince);
                    }
                    if (!oRsTool.Parameters.ContainsKey("ReportDate"))
                    {
                        oRsTool.Parameters.Add("ReportDate", reportDate);
                    }
                    if (amountType == 1)
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (qui đổi): " + currencyCode);
                        }
                    }
                    else
                    {
                        if (!oRsTool.Parameters.ContainsKey("CurrencyCodeUnit"))
                        {
                            oRsTool.Parameters.Add("CurrencyCodeUnit", "Đơn vị tính (nguyên tệ): " + currencyCode);
                        }
                    }
                    if (!oRsTool.Parameters.ContainsKey("FromDate"))
                    {
                        oRsTool.Parameters.Add("FromDate", fromDate.ToShortDateString());
                    }
                    if (!oRsTool.Parameters.ContainsKey("ToDate"))
                    {
                        oRsTool.Parameters.Add("ToDate", toDate.ToShortDateString());
                    }
                    if (!oRsTool.Parameters.ContainsKey("ExpenseName"))
                    {
                        oRsTool.Parameters.Add("ExpenseName", expenseName);
                    }
                    if (!oRsTool.Parameters.ContainsKey("OpenDate"))
                    {
                        oRsTool.Parameters.Add("OpenDate", openDate);
                    }
                }

                return(lstResults);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Lỗi ở chỗ này " + ex.InnerException + ex.Message + ex.StackTrace);
                return(null);
            }
        }
Esempio n. 36
0
        public void WholeProgram()
        {
            var p  = new Program();
            var t  = new TypedIdent(Token.NoToken, "foo", Microsoft.Boogie.Type.Bool);
            var gv = new GlobalVariable(Token.NoToken, t);

            p.AddTopLevelDeclaration(gv);
            string metaDataString = "This is a test";

            p.SetMetadata(0, metaDataString);

            // Now try to clone
            var p2 = (Program)d.Visit(p);

            // Check global is a copy
            int            counter = 0;
            GlobalVariable gv2     = null;

            foreach (var g in p2.TopLevelDeclarations)
            {
                ++counter;
                Assert.IsInstanceOf <GlobalVariable>(g);
                gv2 = g as GlobalVariable;
            }

            Assert.AreEqual(1, counter);
            Assert.AreNotSame(gv, gv2);
            Assert.AreEqual(metaDataString, p2.GetMetadata <string>(0));


            // Check Top level declarations list is duplicated properly
            var t2  = new TypedIdent(Token.NoToken, "bar", Microsoft.Boogie.Type.Bool);
            var gv3 = new GlobalVariable(Token.NoToken, t2);

            p2.AddTopLevelDeclaration(gv3);

            counter = 0;
            foreach (var g in p2.TopLevelDeclarations)
            {
                ++counter;
                Assert.IsInstanceOf <GlobalVariable>(g);
            }

            Assert.AreEqual(2, counter);

            // The original program should still only have one global variable
            counter = 0;
            foreach (var g in p.TopLevelDeclarations)
            {
                ++counter;
                Assert.IsInstanceOf <GlobalVariable>(g);
                Assert.AreSame(g, gv);
            }

            Assert.AreEqual(1, counter);

            // Change Metadata in p2, this shouldn't affect p
            string newMetaDataString = "Another test";

            p2.SetMetadata(0, newMetaDataString);

            Assert.AreNotEqual(p2.GetMetadata <string>(0), p.GetMetadata <string>(0));
        }
Esempio n. 37
0
		public GlobalVariableViewModel(GlobalVariable globalVariable)
		{
			GlobalVariable = globalVariable;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="UserControlTransferVoucherList"/> class.
 /// </summary>
 public UserControlTransferVoucherList()
 {
     InitializeComponent();
     DBOptionHelper             = new GlobalVariable();
     _genveralVouchersPresenter = new GenveralVouchersPresenter(this);
 }
Esempio n. 39
0
 public FormulaKey(FormulaEditorKey key, LocalVariable localVariable = null, GlobalVariable globalVariable = null)
 {
     Key = key;
     LocalVariable = localVariable;
     GlobalVariable = globalVariable;
 }
Esempio n. 40
0
        public VAdvantage.Model.MJournal CreateJournalHDR(MRevenueRecognitionPlan revenueRecognitionPlan, MRevenueRecognitionRun revenurecognitionRun)
        {
            journal.SetClientOrg(revenueRecognitionPlan.GetAD_Client_ID(), revenueRecognitionPlan.GetAD_Org_ID());
            journal.SetC_AcctSchema_ID(revenueRecognitionPlan.GetC_AcctSchema_ID());
            journal.SetDescription("Revenue Recognition Run");
            journal.SetPostingType("A");
            int C_Doctype_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_Doctype_ID From C_Doctype Where DocBaseType='GLJ'"));

            journal.SetC_DocType_ID(C_Doctype_ID);
            int GL_Category_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select GL_Category_ID From GL_Category Where CategoryType='M' Order by GL_Category_ID desc"));

            journal.SetGL_Category_ID(GL_Category_ID);
            journal.SetDateDoc(DateTime.Now);
            journal.SetDateAcct(revenurecognitionRun.GetINT15_RecognitionDate());


            C_Period_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_Period_ID From C_Period pr INNER JOIN ad_clientinfo cl ON cl.ad_client_id = " + GetAD_Client_ID() + " INNER JOIN c_year yr ON (yr.c_year_id = pr.c_year_id" +
                                                              " AND cl.c_calendar_id=yr.c_calendar_id) Where " + GlobalVariable.TO_DATE(revenurecognitionRun.GetINT15_RecognitionDate(), true) + " between StartDate and EndDate"));

            journal.SetC_Period_ID(C_Period_ID);
            journal.SetC_Currency_ID(revenueRecognitionPlan.GetC_Currency_ID());
            int C_ConversionType_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_ConversionType_ID From C_ConversionType where IsDefault='Y'"));

            journal.SetC_ConversionType_ID(C_ConversionType_ID);
            journal.SetTotalCr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetTotalDr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetDocStatus("DR");
            journal.SetDocAction("CO");

            return(journal);
        }
Esempio n. 41
0
        internal static void InitGlobalsValues(GlobalVariable itemsSource)
        {
            Globals.UserLogin = itemsSource.UserLogin;
            Globals.AppSettings = itemsSource.AppSettings;

            //Security section
            Globals.UserLogin.IsUserOrganisationAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.OrganisationAdministratorRoleId);
            Globals.UserLogin.IsUserSiteAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SiteAdministratorRoleId);
            Globals.UserLogin.IsUserPortalAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.PortalAdministratorRoleId);
            Globals.UserLogin.IsUserSecurityAdministrator = SecurityHelper.HasRole(Globals.UserLogin.UserRoleAuths, SecurityHelper.SecurityAdminRoleId);
        }
 private void Start()
 {
     GlobalVariable.Add(new Variable("IsOn", VariableType.v_bool, false, new VariableParameters(true, VariableAccessType.v_readonly)));
 }
 public static void AddGlobalVariable(Program project, GlobalVariable variable)
 {
     project.GlobalVariables.Add(variable);
 }
Esempio n. 44
0
            /// <summary>
            /// Performs lambda lifting (see <see cref="LambdaHelper.ExpandLambdas"/>) by replacing the lambda's
            /// free variables with bound ones.
            /// </summary>
            /// <param name="lambda">A lambda expression
            ///   <code>(lambda x1: T1 ... x_n: T_n :: t)</code>
            /// where <c>t</c> contains the free variables <c>y1</c>, ..., <c>y_m</c>.
            /// </param>
            /// <returns>
            /// <list type="bullet">
            ///   <item>
            ///     A function application <c>f(y1, ..., y_m)</c> where <c>f</c>'s body is defined to be the result of
            ///     replacing the free variables <c>y1</c>, ..., <c>y_m</c> in <c>t</c> with bound variables
            ///     <c>b1</c>, ..., <c>b_m</c>.
            ///   </item>
            ///   <item>
            ///     Adds a definition and axiom for <c>f</c> to <see cref="lambdaFunctions"/> and <see cref="lambdaAxioms"/>.
            ///     Memoizes <c>f</c> as the lifted lambda for <para>lambda</para>.
            ///   </item>
            /// </list>
            /// </returns>
            private Expr LiftLambdaFreeVars(LambdaExpr lambda)
            {
                // We start by getting rid of any use of "old" inside the lambda.  This is done as follows.
                // For each variable "g" occurring inside lambda as "old(... g ...)", create a new name "og".
                // Replace each old occurrence of "g" with "og", removing the enclosing "old" wrappers.
                var oldFinder = new OldFinder();

                oldFinder.Visit(lambda);
                var oldSubst       = new Dictionary <Variable, Expr>(); // g -> g0
                var callOldMapping = new Dictionary <Variable, Expr>(); // g0 -> old(g)

                foreach (var v in oldFinder.FreeOldVars)
                {
                    var g = v as GlobalVariable;
                    if (g != null)
                    {
                        var g0 = new GlobalVariable(g.tok, new TypedIdent(g.tok, g.TypedIdent.Name + "@old", g.TypedIdent.Type));
                        oldSubst.Add(g, new IdentifierExpr(g0.tok, g0));
                        callOldMapping.Add(g0, new OldExpr(g0.tok, new IdentifierExpr(g.tok, g)));
                    }
                }
                var lambdaBody = Substituter.ApplyReplacingOldExprs(
                    Substituter.SubstitutionFromHashtable(new Dictionary <Variable, Expr>()),
                    Substituter.SubstitutionFromHashtable(oldSubst),
                    lambda.Body);
                var lambdaAttrs = Substituter.ApplyReplacingOldExprs(
                    Substituter.SubstitutionFromHashtable(new Dictionary <Variable, Expr>()),
                    Substituter.SubstitutionFromHashtable(oldSubst),
                    lambda.Attributes);

                if (0 < CommandLineOptions.Clo.VerifySnapshots && QKeyValue.FindStringAttribute(lambdaAttrs, "checksum") == null)
                {
                    // Attach a dummy checksum to avoid issues in the dependency analysis.
                    var checksumAttr = new QKeyValue(lambda.tok, "checksum", new List <object> {
                        "lambda expression"
                    }, null);
                    if (lambdaAttrs == null)
                    {
                        lambdaAttrs = checksumAttr;
                    }
                    else
                    {
                        lambdaAttrs.AddLast(checksumAttr);
                    }
                }

                // this is ugly, the output will depend on hashing order
                var subst            = new Dictionary <Variable, Expr>();
                var substFnAttrs     = new Dictionary <Variable, Expr>();
                var formals          = new List <Variable>();
                var callArgs         = new List <Expr>();
                var axCallArgs       = new List <Expr>();
                var dummies          = new List <Variable>(lambda.Dummies);
                var freeTypeVars     = new List <TypeVariable>();
                var fnTypeVarActuals = new List <Type /*!*/>();
                var freshTypeVars    = new List <TypeVariable>(); // these are only used in the lambda@n function's definition

                // compute the free variables of the lambda expression, but with lambdaBody instead of lambda.Body
                Set freeVars = new Set();

                BinderExpr.ComputeBinderFreeVariables(lambda.TypeParameters, lambda.Dummies, lambdaBody, null, lambdaAttrs, freeVars);

                foreach (object o in freeVars)
                {
                    // 'o' is either a Variable or a TypeVariable.
                    if (o is Variable)
                    {
                        var v  = o as Variable;
                        var ti = new TypedIdent(v.TypedIdent.tok, v.TypedIdent.Name, v.TypedIdent.Type);
                        var f  = new Formal(v.tok, ti, true);
                        formals.Add(f);
                        substFnAttrs.Add(v, new IdentifierExpr(f.tok, f));
                        var b = new BoundVariable(v.tok, ti);
                        dummies.Add(b);
                        if (callOldMapping.ContainsKey(v))
                        {
                            callArgs.Add(callOldMapping[v]);
                        }
                        else
                        {
                            callArgs.Add(new IdentifierExpr(v.tok, v));
                        }
                        Expr id = new IdentifierExpr(b.tok, b);
                        subst.Add(v, id);
                        axCallArgs.Add(id);
                    }
                    else
                    {
                        var tv = (TypeVariable)o;
                        freeTypeVars.Add(tv);
                        fnTypeVarActuals.Add(tv);
                        freshTypeVars.Add(new TypeVariable(tv.tok, tv.Name));
                    }
                }

                var sw = new System.IO.StringWriter();
                var wr = new TokenTextWriter(sw, true);

                lambda.Emit(wr);
                string lam_str = sw.ToString();

                FunctionCall fcall;
                IToken       tok = lambda.tok;
                Formal       res = new Formal(tok, new TypedIdent(tok, TypedIdent.NoName, cce.NonNull(lambda.Type)), false);

                if (liftedLambdas.TryGetValue(lambda, out fcall))
                {
                    if (CommandLineOptions.Clo.TraceVerify)
                    {
                        Console.WriteLine("Old lambda: {0}", lam_str);
                    }
                }
                else
                {
                    if (CommandLineOptions.Clo.TraceVerify)
                    {
                        Console.WriteLine("New lambda: {0}", lam_str);
                    }
                    Function fn = new Function(tok, FreshLambdaFunctionName(), freshTypeVars, formals, res, "auto-generated lambda function",
                                               Substituter.Apply(Substituter.SubstitutionFromHashtable(substFnAttrs), lambdaAttrs));
                    fn.OriginalLambdaExprAsString = lam_str;

                    fcall                 = new FunctionCall(new IdentifierExpr(tok, fn.Name));
                    fcall.Func            = fn; // resolve here
                    liftedLambdas[lambda] = fcall;

                    List <Expr /*!*/> selectArgs = new List <Expr /*!*/>();
                    foreach (Variable /*!*/ v in lambda.Dummies)
                    {
                        Contract.Assert(v != null);
                        selectArgs.Add(new IdentifierExpr(v.tok, v));
                    }
                    NAryExpr axcall = new NAryExpr(tok, fcall, axCallArgs);
                    axcall.Type           = res.TypedIdent.Type;
                    axcall.TypeParameters = SimpleTypeParamInstantiation.From(freeTypeVars, fnTypeVarActuals);
                    NAryExpr select = Expr.Select(axcall, selectArgs);
                    select.Type = lambdaBody.Type;
                    List <Type /*!*/>   selectTypeParamActuals = new List <Type /*!*/>();
                    List <TypeVariable> forallTypeVariables    = new List <TypeVariable>();
                    foreach (TypeVariable /*!*/ tp in lambda.TypeParameters)
                    {
                        Contract.Assert(tp != null);
                        selectTypeParamActuals.Add(tp);
                        forallTypeVariables.Add(tp);
                    }
                    forallTypeVariables.AddRange(freeTypeVars);
                    select.TypeParameters = SimpleTypeParamInstantiation.From(lambda.TypeParameters, selectTypeParamActuals);

                    Expr     bb   = Substituter.Apply(Substituter.SubstitutionFromHashtable(subst), lambdaBody);
                    NAryExpr body = Expr.Eq(select, bb);
                    body.Type           = Type.Bool;
                    body.TypeParameters = SimpleTypeParamInstantiation.EMPTY;
                    Trigger trig = new Trigger(select.tok, true, new List <Expr> {
                        select
                    });

                    lambdaFunctions.Add(fn);
                    lambdaAxioms.Add(new ForallExpr(tok, forallTypeVariables, dummies,
                                                    Substituter.Apply(Substituter.SubstitutionFromHashtable(subst), lambdaAttrs),
                                                    trig, body));
                }

                NAryExpr call = new NAryExpr(tok, fcall, callArgs);

                call.Type           = res.TypedIdent.Type;
                call.TypeParameters = SimpleTypeParamInstantiation.From(freeTypeVars, fnTypeVarActuals);

                return(call);
            }
Esempio n. 45
0
        /// <summary>
        /// Close the periods for all dcocument type except Gl Journal of previous month
        /// </summary>
        /// <returns>info</returns>
        protected override string DoIt()
        {
            int      currentDay = date.Day;
            DateTime month      = new DateTime(date.Year, date.Month, 1);
            DateTime lastMonth  = month.AddMonths(-1);

            //close period if scheduler date is a current date.here day is scheduled day
            if (currentDay == day)
            {
                string sql = "UPDATE C_PeriodControl SET PeriodStatus= '" + MPeriodControl.PERIODSTATUS_Closed + "'" +
                             " WHERE C_Period_ID= (SELECT C_Period_ID FROM C_Period p INNER JOIN C_Year y ON y.C_Year_ID = p.C_Year_ID  " +
                             "WHERE p.IsActive='Y' AND y.C_Calendar_ID=" + calendar_id + " AND Startdate=" + GlobalVariable.TO_DATE(lastMonth, true) + ") AND DocBaseType NOT IN ('" + MDocBaseType.DOCBASETYPE_GLJOURNAL + "')" +
                             " AND PeriodStatus<>'" + MPeriodControl.PERIODSTATUS_PermanentlyClosed + "' AND AD_Org_ID IN (" + OrgId + ")";

                //  sql = MRole.GetDefault(GetCtx()).AddAccessSQL(sql, "C_PeriodControl", true, true); // fully qualified - RO


                if (Util.GetValueOfInt(DB.ExecuteQuery(sql, null, null)) == 0)
                {
                    log.Log(Level.SEVERE, sql);
                    return(Msg.GetMsg(GetCtx(), "PeriodNotClosed"));
                }
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "NotScheduled"));
            }
            return(Msg.GetMsg(GetCtx(), "PeriodClosed"));
        }
        private void SendEvaluation(LocalVariable localVariable = null, GlobalVariable globalVariable = null)
        {
            FormulaEvaluationResult result;

            if (ParsingError != null)
            {
                // FormulaEditorKey key as parameter for this function
                //if (key != FormulaEditorKey.Delete)
                //{
                //    SelectionStart = ParsingError.Index;
                //    SelectionLength = ParsingError.Length;
                //}      
                result = new FormulaEvaluationResult
                {
                    Error = AppResourcesHelper.Get("FormulaInterpreter_Error")
                };
            }
            else
            {
                var value = FormulaEvaluator.Evaluate(Formula);
                var stringValue = value == null ? string.Empty : value.ToString();

                result = new FormulaEvaluationResult
                {
                    Value = stringValue,
                };
            }
            Messenger.Default.Send(result, ViewModelMessagingToken.FormulaEvaluated);
        }