//Tharrani – End

        //Esther
        public string CreateAdjustment(String token, WCF_Adjustment adj)
        {
            if (AuthenticateToken(token))
            {
                String       now      = DateTime.Now.ToString("yyyy-MM-dd");
                WCF_Employee employee = GetEmployeeByToken(token);
                adjustment   a        = new adjustment()
                {
                    adjustment_date     = DateTime.ParseExact(now, "yyyy-MM-dd", null),
                    employee_id         = employee.EmployeeId,
                    item_number         = adj.ItemNumber.Trim(),
                    adjustment_quantity = Int32.Parse(adj.AdjustmentQty.Trim()),
                    adjustment_price    = BusinessLogic.Adjprice(adj.ItemNumber) * Int32.Parse(adj.AdjustmentQty.Trim()),
                    adjustment_status   = "Pending",
                    employee_remark     = adj.EmployeeRemark,
                    manager_remark      = null,
                };
                String result1 = BusinessLogic.CreateAdjustment(a);
                String email   = BusinessLogic.SendEmailAdjustmentApproval(a);
                try
                {
                    BusinessLogic.sendMail(email, "New Adjustment Request", employee.EmployeeName + " raised new adjustment request.");
                }
                catch (Exception ex)
                {
                    return("email exception " + ex.Message);
                }
                return(result1);
            }
            else
            {
                return("invalid token");
            }
        }
Esempio n. 2
0
    public adjustment GetChildObj(int x, int y)
    {
        int        index = ((GManager.MAX_CHUNK_SIZE * y) + x) + 1;
        adjustment tile  = transform.GetChild(index).GetComponent <adjustment>();

        return(tile);
    }
Esempio n. 3
0
    public ChunkInfo getChunkInfo()
    {
        Dictionary <int, TileInfo> tiles = new Dictionary <int, TileInfo>();

        for (int i = 0; i < transform.childCount - 1; i++)
        {
            adjustment tile = transform.GetChild(i + 1).GetComponent <adjustment>();
            tiles.Add(i, new TileInfo(tile.transform.position.y, tile.type, tile.placerName));
        }
        return(new ChunkInfo(tiles));
    }
Esempio n. 4
0
        // Convert From Auto Generated DB Model to APIModel
        private static AdjustmentModel ConvertDBtoAPIAdjust(adjustment adj)
        {
            List <AdjustmentDetailModel> adjdm = new List <AdjustmentDetailModel>();

            foreach (adjustmentdetail adjd in adj.adjustmentdetails)
            {
                adjdm.Add(new AdjustmentDetailModel(adjd.adjid, adjd.itemid, adjd.item.description, adjd.adjustedqty, adjd.reason, adjd.item.category.name, adjd.item.uom));
            }
            AdjustmentModel adjm = new AdjustmentModel(adj.adjid, adj.raisedby, adj.user.fullname, adj.raisedto, adj.user1.fullname, adj.issueddate, adj.status, adjdm);

            return(adjm);
        }
        protected void CreateAdjustment()
        {
            string email = RetrieveEmail(TotalPrice());
            String today = DateTime.Now.ToString("yyyy-MM-dd");

            try
            {
                adjustment a = new adjustment()
                {
                    adjustment_date     = DateTime.ParseExact(today, "yyyy-MM-dd", null),
                    employee_id         = user.employee_id,
                    item_number         = item.item_number,
                    adjustment_quantity = ReturnQuantity(),
                    adjustment_price    = TotalPrice(),
                    adjustment_status   = "Pending",
                    employee_remark     = TextBoxRemarks.Text,
                    manager_remark      = null,
                };

                try
                {
                    using (TransactionScope tx = new TransactionScope())
                    {
                        BusinessLogic.CreateAdjustment(a);
                        tx.Complete();
                        Response.Write(BusinessLogic.MsgBox("Success: The adjustment request has been sent for approval"));
                        BusinessLogic.sendMail(email, "New Adjustment Request awaiting for approval", user.employee_name + " has submitted a new Adjustment Request for approval.");
                    }
                    //Response.Redirect("ClerkInventory.aspx");
                    String url = "ClerkInventory.aspx";
                    Response.Write(BusinessLogic.MsgBox("Success: The adjustment request has been sent for approval"));
                    Response.Write("<script language=JavaScript>  opener.location.replace('" + url + "'); </script>");
                    Response.Write("<script language='javascript'> { window.close();}</script>");
                }
                catch (System.Transactions.TransactionException ex)
                {
                    Response.Write(BusinessLogic.MsgBox(ex.Message));
                }
                catch (Exception ex)
                {
                    Response.Write(BusinessLogic.MsgBox(ex.Message));
                }
            }

            catch (Exception ex)
            {
                Response.Write(BusinessLogic.MsgBox(ex.Message));
            }
        }
Esempio n. 6
0
    public IEnumerator LoadChunk(Vector3 posIn, ChunkInfo info)
    {
        Vector3Int chunkStart = new Vector3Int((int)posIn.x, 0, (int)posIn.z);
        GameObject newChunk   = Instantiate(GManager.self.empty, chunkStart, Quaternion.identity, transform);
        Chunk      ch         = newChunk.GetComponent <Chunk>();

        newChunk.name = "chunk" + posIn.x + " " + posIn.z + "";
        int selName = 0;

        Loader.loading   = true;
        float[,] heights = new float[GManager.MAX_CHUNK_SIZE, GManager.MAX_CHUNK_SIZE];
        for (int i = 0; i < info.tiles.Keys.Count; i++, selName++)
        {
            info.tiles.TryGetValue(i, out TileInfo tile);
            float      z       = (int)(i / 25f);
            float      x       = (int)(i % 25f);
            Vector3    pos     = new Vector3(x - 12f, tile.height, z - 12f);
            GameObject newTile = Instantiate(GManager.self.TilePrefab, pos, Quaternion.identity, newChunk.transform);
            adjustment adj     = newTile.GetComponent <adjustment>();
            GameObject arrSel  = newTile.transform.GetChild(3).gameObject;
            arrSel.name = posIn.x + "" + posIn.z + selName;
            adj.type    = tile.type;
            if (tile.placerName != string.Empty)
            {
                adj.SetPlacer(GManager.items[tile.placerName] as IPlaceable);
            }
            heights[(int)x, (int)z] = pos.y;
            if ((int)x == GManager.MAX_CHUNK_SIZE - 1)
            {
                yield return(null);
            }
        }
        ch.setAllHeights(heights);
        chunks.Add(new Vector2Int((int)posIn.x, (int)posIn.z), ch);
        Loader.loading = false;
        if (!doneFirstload)
        {
            doneFirstload = true;
            GManager.playerLocation.gameObject.GetComponent <Rigidbody>().isKinematic = false;
            GManager.GSState = GS.N;
        }
        yield return(null);
    }
Esempio n. 7
0
        //find Adjusment by id
        public static AdjustmentModel GetAdjustmentByID(int adjid, out string error)
        {
            LUSSISEntities entities = new LUSSISEntities();

            error = "";

            adjustment      adj  = new adjustment();
            AdjustmentModel adjm = new AdjustmentModel();

            try
            {
                adj  = entities.adjustments.Where(a => a.adjid == adjid).FirstOrDefault <adjustment>();
                adjm = ConvertDBtoAPIAdjust(adj);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(adjm);
        }
Esempio n. 8
0
        //Update Adjustment
        public static AdjustmentModel UpdateAdjustment(AdjustmentModel adjm, out string error)
        {
            error = "";
            LUSSISEntities entities = new LUSSISEntities();

            NotificationModel nom = new NotificationModel();

            adjustment adj = new adjustment();

            try
            {
                adj            = entities.adjustments.Where(a => a.adjid == adjm.Adjid).First <adjustment>();
                adj.raisedby   = adjm.Raisedby;
                adj.raisedto   = adjm.Raisedto;
                adj.issueddate = adjm.Issueddate;
                adj.status     = adjm.Status;
                nom.Remark     = "The Adjustment Voucher has been Rejected!";


                if (adj.status == ConAdjustment.Active.APPROVED)
                {
                    nom.Remark = "The Adjustment Voucher has been Approved!";
                }

                List <AdjustmentDetailModel> adjustds = AdjustmentDetailRepo.GetAdjustmentDetailByAdjID(adj.adjid, out error);
                foreach (AdjustmentDetailModel adjustd in adjustds)
                {
                    InventoryModel inventm = InventoryRepo.GetInventoryByItemid(adjustd.Itemid, out error);
                    inventory      invent  = entities.inventories.Where(i => i.invid == inventm.Invid).First <inventory>();
                    invent.stock += adjustd.Adjustedqty;

                    InventoryTransactionModel invtm = new InventoryTransactionModel();

                    invtm.InvID     = invent.invid;
                    invtm.ItemID    = invent.itemid;
                    invtm.Qty       = adjustd.Adjustedqty;
                    invtm.TransType = ConInventoryTransaction.TransType.ADJUSTMENT;
                    invtm.TransDate = DateTime.Now;
                    invtm.Remark    = adjustd.Reason;

                    invtm = InventoryTransactionRepo.CreateInventoryTransaction(invtm, out error);
                }


                entities.SaveChanges();
                adjm = GetAdjustmentByID(adj.adjid, out error);

                nom.Deptid   = DepartmentRepo.GetDepartmentByUserid(adj.raisedto ?? default(int), out error).Deptid;
                nom.Role     = UserRepo.GetUserByUserID(adj.raisedby ?? default(int)).Role;
                nom.Title    = "Adjustment Approval";
                nom.NotiType = ConNotification.NotiType.Adjustment;
                nom.ResID    = adj.adjid;
                nom          = NotificationRepo.CreatNotification(nom, out error);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(adjm);
        }
Esempio n. 9
0
        //Create new Adjustment
        public static AdjustmentModel CreateAdjustment(AdjustmentModel adjm, out string error)
        {
            error = "";
            LUSSISEntities entities = new LUSSISEntities();
            adjustment     adj      = new adjustment();

            try
            {
                adj.raisedby   = adjm.Raisedby;
                adj.issueddate = adjm.Issueddate;
                adj.status     = ConAdjustment.Active.PENDING;
                List <AdjustmentDetailModel> adjds = adjm.Adjds;

                //check item price
                foreach (AdjustmentDetailModel adjd in adjds)
                {
                    adj.raisedto = 0;
                    SupplierItemModel supp  = SupplierItemRepo.GetSupplierItemByItemId(adjd.Itemid, out error);
                    double?           price = Math.Abs((Int32)adjd.Adjustedqty) * supp.Price;

                    //Check total price of each item to consider who to report to
                    if (price >= ConAdjustment.Active.REPORTMANAGER)
                    {
                        user user = entities.users.Where(u => u.role == ConUser.Role.MANAGER).First();
                        adj.raisedto = user.userid;
                    }
                    else
                    {
                        user user = entities.users.Where(u => u.role == ConUser.Role.SUPERVISOR).First();
                        adj.raisedto = user.userid;
                    }
                }
                adj = entities.adjustments.Add(adj);
                entities.SaveChanges();

                foreach (AdjustmentDetailModel adjdm in adjds)
                {
                    adjustmentdetail adjd = new adjustmentdetail
                    {
                        adjid       = adj.adjid,
                        itemid      = adjdm.Itemid,
                        adjustedqty = adjdm.Adjustedqty,
                        reason      = adjdm.Reason
                    };
                    adjd = entities.adjustmentdetails.Add(adjd);
                    entities.SaveChanges();
                }

                adjm = GetAdjustmentByID(adj.adjid, out error);

                NotificationModel nom = new NotificationModel();
                nom.Deptid   = DepartmentRepo.GetDepartmentByUserid(adj.raisedto ?? default(int), out error).Deptid;
                nom.Role     = UserRepo.GetUserByUserID(adj.raisedto ?? default(int)).Role;
                nom.Title    = "New Adjustment";
                nom.NotiType = ConNotification.NotiType.Adjustment;
                nom.ResID    = adj.adjid;
                nom.Remark   = "A new adjustment has been raised by clerk!";
                nom          = NotificationRepo.CreatNotification(nom, out error);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(adjm);
        }
Esempio n. 10
0
    public IEnumerator generate(Vector2 start)
    {
        start = start * MAX_CHUNK_SIZE;
        Vector2Int startInt = new Vector2Int((int)start.x, (int)start.y);

        if (start == Vector2Int.zero)
        {
            LoadDefault();
        }
        int        selName    = 0;
        Vector3Int chunkStart = new Vector3Int((int)start.x, 0, (int)start.y);
        GameObject newChunk   = Instantiate(empty, chunkStart,
                                            Quaternion.identity, GridObject.transform);
        Chunk ch = newChunk.GetComponent <Chunk>();

        ch.setPos(startInt);
        newChunk.name = "chunk" + start.x + " " + start.y + "";
        ChunkManager.chunks.Add(startInt, ch);
        Vector2 scaleS   = ((Vector2)start) / 10f;
        float   halfSize = (MAX_CHUNK_SIZE / 2) / 10f;
        int     at1      = 0;

        float[,] heights = new float[MAX_CHUNK_SIZE, MAX_CHUNK_SIZE];
        for (float z = -halfSize; z <= halfSize; z += .1f, at1++)
        {
            z = (float)Math.Round(z, 2);
            float[] prevTiles = new float[MAX_CHUNK_SIZE + 1];
            int     at        = 0;
            for (float x = -halfSize; x <= halfSize; x += .1f, at++)
            {
                Loader.loading = true;
                x = (float)Math.Round(x, 2);
                float tile = 0f, tile2 = 0f;
                tile  = Mathf.PerlinNoise((x + scaleS.x + randX + randZ), (z + scaleS.y + randY + randZ)) * 5f;
                tile2 = Mathf.PerlinNoise((x + scaleS.x + gRandX + gRandZ), (z + scaleS.y + gRandY + gRandZ)) * 4f;
                //tile = (float)Math.Round(tile, 3);
                tile         += prevTiles[at];
                prevTiles[at] = tile;

                int t = (int)clampF(tile2, 0, 3);
                if (tile <= 0f)
                {
                    tile = 0.01f;
                }
                Vector3 pos = new Vector3(x * 10f, tile, z * 10f);
                if (x == 0f && z == 0f && start == Vector2.zero)
                {
                    playerLocation.position = Vector3.up * (tile + 1f);
                }

                /*if (x %1f == 0f && z == 1f){
                 *      GameObject newPickup = Instantiate (PickupPrefab, pos, Quaternion.identity, newChunk.transform);
                 *      newPickup.transform.localPosition = new Vector3 (pos.x, tile + .5f, pos.z);
                 *      int type = UnityEngine.Random.Range (0, items.Length);
                 *      Item copy = items [type].copy (1);
                 *      addPickup (newPickup, copy, Vector3.zero);
                 *      pickups.Add (new Pos(newPickup));
                 *      //newPickup.SetActive (false);
                 * }*/
                GameObject newTile = Instantiate(TilePrefab, pos, Quaternion.identity, newChunk.transform);
                adjustment adj     = newTile.GetComponent <adjustment> ();

                adj.type = t;
                newTile.transform.localPosition = pos;
                GameObject arrSel = newTile.transform.GetChild(3).gameObject;
                arrSel.name = start.x + "" + start.y + selName;
                selName++;
                heights[at, at1] = tile;

                float chance = (tile + tile2);
                if (chance >= 3.595f && chance <= 3.6f)
                {
                    adj.SetPlacer(items["Path1"] as IPlaceable);
                    int        id         = (int)map(chance, 3.595f, 3.6f, 0, enemyPrefabs.Count() - 1);
                    GameObject enemySpawn = Instantiate(enemyPrefabs[(EnemyType)id]);
                    enemySpawn.GetComponent <Rigidbody>().isKinematic = false;
                    Vector3 pp = Vector3.up * 2f;
                    enemySpawn.transform.position = pos + (chunkStart) + pp;
                    enemySpawn.SetActive(false);
                    enemiesL.Add(new Pos(enemySpawn));
                }
            }
            yield return(null);
        }
        ch.setAllHeights(heights);
        yield return(null);

        Loader.loading = false;
        if (start == Vector2.zero)
        {
            ChunkManager.worldInfo.playerPos = GManager.playerLocation.position;
            ChunkManager.currAreas.Add(new ChunkArea(0, 0));
            ChunkManager.self.SaveWorld();
            LoadPlayerInfo();
            playerLocation.gameObject.GetComponent <Rigidbody>().isKinematic = false;
            ChunkManager.doneFirstload = true;
            GSState = GS.N;
        }
        yield return(null);
    }