protected void Page_Load(object sender, EventArgs e)
        {
            //if (Session["EMAILID"] != null)
            //{
            //    Master.UserID = Session["EMAILID"].ToString();
            //}

            if ((Session["EMAILID"] != null) || (Session["PortfolioFolder"] != null))
            {
                if (!IsPostBack)
                {
                    StockManager stockManager = new StockManager();

                    DataTable portfolioTable = stockManager.getPortfolioMaster(Session["EMAILID"].ToString());
                    if ((portfolioTable != null) && (portfolioTable.Rows.Count > 0))
                    {
                        //ViewState["STOCKMASTER"] = portfolioTable;
                        ListItem li = new ListItem("Select Portfolio", "-1");
                        ddlFiles.Items.Add(li);
                        foreach (DataRow rowitem in portfolioTable.Rows)
                        {
                            li = new ListItem(rowitem["PORTFOLIO_NAME"].ToString(), rowitem["ROWID"].ToString());
                            ddlFiles.Items.Add(li);
                        }
                    }
                }
            }
            else
            {
                //Response.Write("<script language=javascript>alert('" + common.noLogin + "')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noLogin + "');", true);
                Response.Redirect("~/Default.aspx");
            }
        }
Exemple #2
0
        public ActionResult EnterDetail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("请输入正确的入库单编号")));
            }

            int eId = 0;

            int.TryParse(id, out eId);

            if (eId <= 0)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("请输入正确的入库单编号")));
            }
            string      uid     = HttpContext.User.Identity.Name;
            BEnterStock stock   = null;
            UserManager userMgr = new UserManager(int.Parse(uid), null);
            BUser       user    = userMgr.CurrentUser;

            try
            {
                StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
                stock = stockManager.GetEnterStockFullInfo(eId);
            }
            catch (KMJXCException kex)
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode(kex.Message)));
            }
            catch
            {
                return(Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("未知错误")));
            }
            return(View(stock));
        }
 protected void buttonDelete_Click(object sender, EventArgs e)
 {
     //if (deletePortfolioName.Equals("-1") == false)
     if (ddlFiles.SelectedIndex > 0)
     {
         string       portfolioMasterId = ddlFiles.SelectedValue;
         StockManager stockManager      = new StockManager();
         if (stockManager.DeletePortfolio(portfolioMasterId))
         {
             if (stockManager.getPortfolioCount(Session["EMAILID"].ToString()) > 0)
             {
                 Response.Redirect("~/mselectportfolio.aspx");
             }
             else
             {
                 Response.Redirect("~/mnewportfolio.aspx");
             }
         }
         else
         {
             labelSelectedFile.Text = "Problem encountered while trying to delete portfolio. Please try again later";
             //Response.Write("<script language=javascript>alert('"+ common.noPortfolioSelectedToDelete +"')</script>");
             Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Problem encountered while trying to delete portfolio. Please try again later');", true);
         }
     }
     else
     {
         labelSelectedFile.Text = "Selected File: Please select portfolio to delete";
         //Response.Write("<script language=javascript>alert('"+ common.noPortfolioSelectedToDelete +"')</script>");
         Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noPortfolioSelectedToDelete + "');", true);
     }
 }
        private void btnCagar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtCant.Text[0] == ',')
                {
                    txtCant.Text = "0" + txtCant.Text;
                }
                if (txtCant.Text == ",")
                {
                    txtCant.Text = "0";
                }
                if (txtCant.Text == "")
                {
                    MessageBox.Show("Por favor inserte un numero valido.");
                }
                else
                {
                    StockManager stock = new StockManager();
                    txtCant.Text.Replace(',', '.');
                    BindingList <Ingrediente> lista = stock.Cargarstocks(int.Parse(cmbIngrediente.SelectedValue.ToString()), float.Parse(txtCant.Text));
                    lista = stock.ListarStock(txtsearch.Text);

                    dgvstock.DataSource = lista;
                    dgvstock.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #5
0
        public PQGridData SearchBatches()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            string keyword = request["product_key"];
            int    total   = 0;

            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 30;
            }

            data.data     = stockManager.SearchBatches(0, null, keyword, page, pageSize, out total);
            data.curPage  = page;
            data.pageSize = pageSize;
            return(data);
        }
Exemple #6
0
        private void Form3_FormClosing(object sender, FormClosingEventArgs e)
        {
            Form frm = new StockManager();

            frm.FormClosing += new FormClosingEventHandler(this.Form2_FormClosing);
            frm.Show();
        }
Exemple #7
0
        public static String GetStockLabel(string stockId)
        {
            StockItem item;

            StockManager.LookupItem(stockId, out item);
            return(item.Label);
        }
        protected void ddlExchange_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownListStock.Items.Clear();
            TextBoxSearch.Text          = "";
            textboxSelectedSymbol.Text  = "";
            ViewState["GraphScript"]    = "";
            ddlPortfolios.SelectedIndex = 0;

            StockManager stockManager = new StockManager();

            DataTable tableStockMaster = stockManager.getStockMaster(ddlExchange.SelectedValue.ToString());

            if ((tableStockMaster != null) && (tableStockMaster.Rows.Count > 0))
            {
                DropDownListStock.Items.Clear();
                ViewState["STOCKMASTER"] = tableStockMaster;
                ListItem li = new ListItem("Select Stock", "-1");
                DropDownListStock.Items.Add(li);
                foreach (DataRow rowitem in tableStockMaster.Rows)
                {
                    li = new ListItem(rowitem["COMP_NAME"].ToString(), rowitem["SYMBOL"].ToString());// + "." + ddlExchange.SelectedValue); ;//rowitem["EXCHANGE"].ToString());
                    DropDownListStock.Items.Add(li);
                }
            }
            else
            {
                ViewState["STOCKMASTER"] = null;
                //Response.Write("<script language=javascript>alert('" + common.noSymbolFound +"')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noSymbolFound + "');", true);
            }
        }
Exemple #9
0
        protected void buttonDeleteSelectedScript_Click(object sender, EventArgs e)
        {
            try
            {
                if ((GridViewPortfolio.SelectedRow != null) && (Session["STOCKPORTFOLIOROWID"] != null))
                {
                    string portfolioRowId = Session["STOCKPORTFOLIOROWID"].ToString();

                    StockManager stockManager = new StockManager();
                    stockManager.deletePortfolioRow(portfolioRowId);

                    if (this.MasterPageFile.Contains("Site.Master"))
                    {
                        Response.Redirect("~/openportfolio.aspx");
                    }
                    else if (this.MasterPageFile.Contains("Site.Mobile.Master"))
                    {
                        Response.Redirect("~/mopenportfolio.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/mopenportfolio.aspx");
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noTxnSelected + "');", true);
                }
            }
            catch (Exception ex)
            {
                //Response.Write("<script language=javascript>alert('Exception while delering script entry: " + ex.Message + "')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Exception while deleting script:" + ex.Message + "');", true);
            }
        }
        protected void sellButton_Click(object sender, EventArgs e)
        {
            //int companyId = Convert.ToInt32(companyDropDownList.SelectedValue);
            //int itemId = Convert.ToInt32(itemDropDownList.SelectedValue);
            //string quantity = stockOutQuantityTextBox.Text;
            //Item item = new Item(itemId, companyId, quantity);
            //StockOutQuantitySell(item);
            //BindAllCompany();

            //BindAllItem(itemId);
            List <Stockout> stockouts = new List <Stockout>();

            foreach (GridViewRow row in stockOutGridView.Rows)
            {
                Stockout stockout    = new Stockout();
                string   itemName    = row.Cells[0].Text;
                string   companyName = row.Cells[1].Text;
                string   Quantity    = row.Cells[2].Text;
                stockout.ItemName    = itemName;
                stockout.CompanyName = companyName;
                stockout.Quantity    = Quantity;
                stockouts.Add(stockout);
            }
            StockManager stockManager = new StockManager();

            stockManager.StockOutQuantity(stockouts);
        }
        protected void ddlExchange_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownListStock.Items.Clear();
            TextBoxSearch.Text       = "";
            labelSelectedSymbol.Text = "";
            LabelCompanyName.Text    = "";
            textboxQuantity.Text     = "0.00";
            textboxCommission.Text   = "0.00";
            labelTotalCost.Text      = "0.00";

            StockManager stockManager = new StockManager();

            DataTable tableStockMaster = stockManager.getStockMaster(ddlExchange.SelectedValue.ToString());

            if ((tableStockMaster != null) && (tableStockMaster.Rows.Count > 0))
            {
                ViewState["STOCKMASTER"] = tableStockMaster;
                ListItem li = new ListItem("Select Stock", "-1");
                DropDownListStock.Items.Add(li);
                foreach (DataRow rowitem in tableStockMaster.Rows)
                {
                    li = new ListItem(rowitem["COMP_NAME"].ToString(), rowitem["SYMBOL"].ToString() + "." + ddlExchange.SelectedValue);//rowitem["EXCHANGE"].ToString());
                    DropDownListStock.Items.Add(li);
                }
            }
            else
            {
                ViewState["STOCKMASTER"] = null;
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noSymbolFound + "');", true);
            }
        }
Exemple #12
0
        public async Task <IHttpActionResult> PostDispatch(DispatchCreateDTO dispatchData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string       reg      = User.Identity.GetUserId();
            Profile      prof     = db.Profiles.Where(b => b.userid == reg).SingleOrDefault();
            StockManager manager  = db.StockManagers.Where(b => b.profileId == prof.id).SingleOrDefault();
            Dispatch     dispatch = new Dispatch()
            {
                orderId = dispatchData.orderId, stockManagerId = manager.id, date = DateTime.Now
            };
            Order order = db.Orders.Find(dispatchData.orderId);

            if (order == null)
            {
                return(NotFound());
            }
            order.status          = "dispatched";
            db.Entry(order).State = EntityState.Modified;
            db.Dispatches.Add(dispatch);
            await db.SaveChangesAsync();

            return(Ok());
        }
Exemple #13
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                //Get the button that raised the event
                LinkButton btn = (LinkButton)sender;

                //Get the row that contains this button
                GridViewRow gvr = (GridViewRow)btn.NamingContainer;

                if (gvr.RowIndex >= 0)
                {
                    DataTable    tableSource       = (DataTable)ViewState["MASTER_DATA"];
                    string       portfolioMasterId = tableSource.Rows[gvr.RowIndex]["ROWID"].ToString();
                    StockManager stockManager      = new StockManager();
                    if (stockManager.DeletePortfolio(portfolioMasterId))
                    {
                        Session["STOCKPORTFOLIOMASTERROWID"]   = null;
                        Session["STOCKPORTFOLIONAME"]          = null;
                        Session["STOCKSELECTEDINDEXPORTFOLIO"] = null;
                        ViewState["MASTER_DATA"] = null;
                        GetPortfolios();
                    }
                }
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Error occurred while deleting portfolio. Please try again. :" + ex.Message + "');", true);
            }
            gvPortfolioMaster.EditIndex          = -1;
            gvPortfolioMaster.Columns[3].Visible = false;
        }
        protected void addButton_Click(object sender, EventArgs e)
        {
            int    companyId = Convert.ToInt32(companyDropDownList.SelectedValue);
            int    itemId    = Convert.ToInt32(itemDropDownList.SelectedValue);
            string quantity  = stockOutQuantityTextBox.Text;
            Item   item      = new Item(itemId, companyId, quantity);

            ItemCompanyWIseView items        = new ItemCompanyWIseView();
            StockManager        stockManager = new StockManager();

            if (stockManager.IsGeaterQuanity(item))
            {
                messageLabel.Text = "Available quantity is less than stock out quantity";
            }
            else
            {
                items = stockManager.GetStcokOutItem(item);
                //dr = dt.NewRow();
                //dr["Item"] = items.ItemName;
                //dr["Company"] = items.Companyname;
                //dr["Quantity"] = item.Quantity;
                dt = (DataTable)ViewState["Records"];

                dt.Rows.Add(items.ItemName, items.Companyname, items.Quantity);
                stockOutGridView.DataSource = dt;
                stockOutGridView.DataBind();
            }

            BindAllCompany();
            BindAllItem(itemId);
        }
 public void StockSelectedAction()
 {
     if (DropDownListStock.SelectedIndex > 0)
     {
         ViewState["GraphScript"] = DropDownListStock.SelectedValue;
         //labelSelectedSymbol.Text = DropDownListStock.SelectedValue;
         textboxSelectedSymbol.Text = DropDownListStock.SelectedValue;
         StockManager stockManager = new StockManager();
         DataTable    stockTable   = stockManager.SearchStock(DropDownListStock.SelectedValue);
         if ((stockTable != null) && (stockTable.Rows.Count > 0))
         {
             ddlExchange.SelectedValue       = stockTable.Rows[0]["EXCHANGE"].ToString();
             ddlInvestmentType.SelectedValue = stockTable.Rows[0]["SERIES"].ToString();
         }
         else
         {
             ddlExchange.SelectedIndex       = 0;
             ddlInvestmentType.SelectedIndex = 0;
         }
     }
     else
     {
         ViewState["GraphScript"] = null;
         //labelSelectedSymbol.Text = "Search & Select script";
         textboxSelectedSymbol.Text = "Search & Select investment";
     }
 }
        public async Task <IHttpActionResult> PutStockManager(int id, StockManager stockManager)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stockManager.id)
            {
                return(BadRequest());
            }

            db.Entry(stockManager).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StockManagerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        protected void ButtonSearch_Click(object sender, EventArgs e)
        {
            //first try & find the user given string in currently loaded stock drop down
            bool bfound = false; //SearchPopulateStocksDropDown(TextBoxSearch.Text);

            if (bfound == false)
            {
                //if not found in current drop down then try and search online and insert new result in db and then re-load the exchange & stock dropdown
                StockManager stockManager = new StockManager();
                bfound = stockManager.SearchOnlineInsertInDB(TextBoxSearch.Text.ToUpper());
                if (bfound)
                {
                    FillSymbolList();
                    FillExchangeList();
                    FillInvestmentTypeList();

                    bfound = SearchPopulateStocksDropDown(TextBoxSearch.Text);
                }
            }

            if (bfound == false)
            {
                //if we still do not find the user given search string then show error message
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noSymbolFound + "');", true);
            }
        }
        public void FillSymbolList()
        {
            DropDownListStock.Items.Clear();
            textboxSelectedSymbol.Text      = "";
            ViewState["GraphScript"]        = "";
            ddlExchange.SelectedIndex       = 0;
            ddlInvestmentType.SelectedIndex = 0;

            StockManager stockManager = new StockManager();
            DataTable    tableStockMaster;

            tableStockMaster = stockManager.getStockMaster();

            if ((tableStockMaster != null) && (tableStockMaster.Rows.Count > 0))
            {
                ViewState["STOCKMASTER"] = tableStockMaster;
                DropDownListStock.Items.Clear();
                DropDownListStock.DataTextField  = "COMP_NAME";
                DropDownListStock.DataValueField = "SYMBOL";
                DropDownListStock.DataSource     = tableStockMaster;
                DropDownListStock.DataBind();
                ListItem li = new ListItem("Select Investment", "-1");
                DropDownListStock.Items.Insert(0, li);
            }
        }
 public void LoadPortfolioList()
 {
     try
     {
         StockManager stockManager       = new StockManager();
         DataTable    tablePortfolioList = stockManager.getPortfolioMaster(Session["EMAILID"].ToString());
         if ((tablePortfolioList != null) && (tablePortfolioList.Rows.Count > 0))
         {
             ddlPortfolios.Enabled         = true;
             ButtonSearchPortfolio.Enabled = true;
             ddlPortfolios.Items.Clear();
             ListItem li = new ListItem("Filter By Portfolio", "-1");
             ddlPortfolios.Items.Insert(0, li);
             foreach (DataRow rowPortfolio in tablePortfolioList.Rows)
             {
                 li = new ListItem(rowPortfolio["PORTFOLIO_NAME"].ToString(), rowPortfolio["ROWID"].ToString());
                 ddlPortfolios.Items.Add(li);
             }
         }
         else
         {
             //ButtonSearchPortfolio.Enabled = false;
             ddlPortfolios.Enabled         = false;
             ButtonSearchPortfolio.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Error: " + ex.Message + "');", true);
     }
 }
Exemple #20
0
        public static TillSoilJob FindTillSoilJobForSeed(FarmManager farmManager, Character character)
        {
            TillSoilJob tillSoilJob = farmManager.FindTillSoilJob(character);

            if (tillSoilJob == null)
            {
                return(null);
            }
            Vector3     position    = tillSoilJob.Position;
            Map         map         = GnomanEmpire.Instance.Map;
            MapCell     cell        = map.GetCell(position);
            Designation designation = cell.Designation;
            Farm        farm        = designation as Farm;

            if (farm != null)
            {
                int          seedMaterial = farm.SeedMaterial;
                StockManager stockManager = GnomanEmpire.Instance.Fortress.StockManager;
                if (stockManager.FindClosestItem(position, ItemID.Seed, seedMaterial) != null)
                {
                    return(tillSoilJob);
                }
            }
            tillSoilJob.Cancel();
            return(null);
        }
        protected void DropDownListStock_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownListStock.SelectedValue.Equals("-1") == false)
            {
                labelSelectedSymbol.Text = DropDownListStock.SelectedValue;
                LabelCompanyName.Text    = DropDownListStock.SelectedItem.Text.Trim();
                textboxQuantity.Text     = "0.00";
                textboxCommission.Text   = "0.00";
                labelTotalCost.Text      = "0.00";
                StockManager stockManager = new StockManager();
                DataTable    quoteTable   = stockManager.GetQuote(DropDownListStock.SelectedValue);
                if ((quoteTable != null) && (quoteTable.Rows.Count > 0))
                {
                    //textboxPurchaseDate.Text = System.Convert.ToDateTime(quoteTable.Rows[0]["latestDay"].ToString()).ToString("yyyy-MM-ddThh:mm:ss");
                    textboxPurchaseDate.Text  = System.Convert.ToDateTime(quoteTable.Rows[0]["latestDay"].ToString()).ToString("yyyy-MM-dd");
                    textboxPurchasePrice.Text = quoteTable.Rows[0]["price"].ToString();
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Not able to fetch quote at this moment. You can enter date & price manually or please try again later.');", true);
                    textboxPurchaseDate.TextMode = TextBoxMode.Date;
                }

                DataTable stockTable = stockManager.SearchStock(labelSelectedSymbol.Text.Split('.')[0], ddlExchange.SelectedValue);
                if ((stockTable != null) && (stockTable.Rows.Count > 0))
                {
                    ViewState["StockPortfolioScriptId"] = stockTable.Rows[0]["ROWID"];
                    //Session["STOCKPORTFOLIOSCRIPTID"] = stockTable.Rows[0]["ROWID"];
                }
                else
                {
                    ViewState["StockMasterRowId"] = null;
                }
            }
        }
Exemple #22
0
        public void ShowNSE()
        {
            StockManager stockManager = new StockManager();
            string       fromDate     = Master.textboxFromDate.Text;
            DataTable    niftyTable   = stockManager.GetStockPriceData("^NSEI", fromDate: fromDate);

            if ((niftyTable != null) && (niftyTable.Rows.Count > 0))
            {
                if (chartAdvGraph.Series.FindByName("^NSEI") == null)
                {
                    chartAdvGraph.Series.Add("^NSEI");

                    chartAdvGraph.Series["^NSEI"].Name      = "^NSEI";
                    chartAdvGraph.Series["^NSEI"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                    chartAdvGraph.Series["^NSEI"].ChartArea = chartAdvGraph.ChartAreas[0].Name;

                    chartAdvGraph.Series["^NSEI"].Legend        = chartAdvGraph.Legends[0].Name;
                    chartAdvGraph.Series["^NSEI"].LegendText    = "NIFTY 50";
                    chartAdvGraph.Series["^NSEI"].LegendToolTip = "NIFTY 50";

                    chartAdvGraph.Series["^NSEI"].XAxisType = AxisType.Secondary;
                    chartAdvGraph.Series["^NSEI"].YAxisType = AxisType.Primary;

                    (chartAdvGraph.Series["^NSEI"]).YValuesPerPoint = 4;
                    chartAdvGraph.Series["^NSEI"].ToolTip           = "^NSEI" + ": Date:#VALX; Close:#VALY1 (Click to see details)";
                    chartAdvGraph.Series["^NSEI"].PostBackValue     = "^NSEI" + ",#VALX,#VALY1,#VALY2,#VALY3,#VALY4";
                }
                else
                {
                    chartAdvGraph.Series["^NSEI"].Enabled = true;
                }
                chartAdvGraph.Series["^NSEI"].Points.Clear();
                chartAdvGraph.Series["^NSEI"].Points.DataBindXY(niftyTable.Rows, "TIMESTAMP", niftyTable.Rows, "CLOSE,OPEN,HIGH,LOW");
            }
        }
Exemple #23
0
        public async Task <IHttpActionResult> GetDispatchedOrders()
        {
            string       reg     = User.Identity.GetUserId();
            StockManager manager = await db.StockManagers.Where(b => b.profile.userid == reg).SingleOrDefaultAsync();

            var order = from d in db.Dispatches.Where(d => d.stockManagerId == manager.id && d.order.status == "dispatched").OrderByDescending(d => d.id)
                        select new OrderDTO()
            {
                id     = d.order.id,
                status = d.order.status,
                branch = new BranchDTO {
                    id = d.order.branch.id, address = d.order.branch.address, name = d.order.branch.name, email = d.order.branch.email, regionId = d.order.branch.regionId, telephone = d.order.branch.telephone
                },
                customer = new CustomerDTO {
                    id = d.order.branch.customer.id, tradingName = d.order.branch.customer.tradingName, registrationDate = d.order.branch.customer.registrationDate
                },
                date              = d.order.date,
                orderNumber       = d.order.orderNumber,
                price             = d.order.price,
                invoiceNumber     = d.order.invoiceNumber,
                warehouseLocation = d.order.warehouseLocation
            };

            return(Ok(order));
        }
Exemple #24
0
    /**
     * Coroutine à lancer pour trier selon leur distance (sur le réseau
     * routier) à cette route les bâtiments capable de recevoir des commandes.
     **/
    public IEnumerator SortOrderManagersByDistance(Cell <PriorityQueue <float, OrderManager> > rslt)
    {
        PriorityQueue <float, OrderManager> rsltQueue = new PriorityQueue <float, OrderManager>();
        StockManager stockManager = GameManager.instance.cityBuilderData.stockManager;
        IEnumerator <OrderManager> allOrderManagers = stockManager.AllOrderManagers();

        while (allOrderManagers.MoveNext())
        {
            OrderManager orderManager = allOrderManagers.Current;

            if (orderManager != null)
            {
                float realDistanceToOrderManager = RoadsPathfinding.RealDistanceBetween(this, orderManager.freightAreaData.freightAreaOut.road);
                if (realDistanceToOrderManager > 0.0f)
                {
                    rsltQueue.Push(realDistanceToOrderManager, orderManager);
                }
            }

            yield return(null);
        }

        rslt.value = rsltQueue;

        yield return(null);
    }
Exemple #25
0
        public ApiMessage UpdateProductsWastage()
        {
            ApiMessage message = new ApiMessage()
            {
                Status = "ok"
            };
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            try
            {
                string ws = request["wastages"];
                if (string.IsNullOrEmpty(ws))
                {
                    message.Status  = "failed";
                    message.Message = "输入错误";
                    return(message);
                }
                ws = HttpUtility.UrlDecode(ws);
                JArray ps = (JArray)JArray.Parse(ws);
                if (ps != null && ps.Count > 0)
                {
                    List <BProduct> products = new List <BProduct>();
                    for (int i = 0; i < ps.Count; i++)
                    {
                        BProduct product = new BProduct();
                        JObject  json    = (JObject)ps[i];
                        if (json["product_id"] != null)
                        {
                            product.ID = (int)json["product_id"];
                        }
                        if (json["quantity"] != null)
                        {
                            product.Quantity = (int)json["quantity"];
                        }
                        if (json["parent_id"] != null)
                        {
                            product.ParentID = (int)json["parent_id"];
                        }
                        products.Add(product);
                    }
                    stockManager.UpdateProductsWastage(products);
                }
            }
            catch (KMJXCException kex)
            {
                message.Status  = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status  = "failed";
                message.Message = "未知错误";
            }
            return(message);
        }
Exemple #26
0
        public ApiMessage GetProductsWastageDetail()
        {
            ApiMessage data = new ApiMessage()
            {
                Status = "ok"
            };
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            try
            {
                int[] products = base.ConvertToIntArrar(request["product_ids"]);
                data.Item = stockManager.GetProductsWastageDetail(products);
            }
            catch (KMJXCException kex)
            {
                data.Status  = "failed";
                data.Message = kex.Message;
            }
            catch (Exception ex)
            {
                data.Status  = "failed";
                data.Message = "未知错误";
            }
            return(data);
        }
Exemple #27
0
        public PQGridData SearchEnterStock()
        {
            PQGridData      data         = new PQGridData();
            HttpContextBase context      = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request      = context.Request;
            string          user_id      = User.Identity.Name;
            UserManager     userMgr      = new UserManager(int.Parse(user_id), null);
            BUser           user         = userMgr.CurrentUser;
            StockManager    stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            BuyManager      buyManager   = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            int             page         = 1;
            int             pageSize     = 30;
            int             category     = 0;
            int             storeHouse   = 0;


            int.TryParse(request["cid"], out category);
            int.TryParse(request["house"], out storeHouse);
            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);
            string keyword = request["keyword"];
            int    total   = 0;

            data.data         = stockManager.SearchEnterStocks(0, 0, 0, 0, 0, 0, storeHouse, page, pageSize, out total);
            data.curPage      = page;
            data.totalRecords = total;
            return(data);
        }
Exemple #28
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string typee = "";

            if (cmbSearch.Text == "Product Name")
            {
                typee = "Product.ProductName";
            }
            else if (cmbSearch.Text == "Unit Price")
            {
                typee = "UnitPrice";
            }
            else if (cmbSearch.Text == "Tax")
            {
                typee = "Tax";
            }
            else if (cmbSearch.Text == "Piece")
            {
                typee = "Piece";
            }


            if (cmbSearch.Text == "All")
            {
                FillGrid();
            }
            else
            {
                stockManager = new StockManager();
                var list = stockManager.Search(typee, txtSearch.Text.ToString());
                dgvStock.DataSource = list;
            }
        }
        public void LoadPortfolioStockList()
        {
            if (ddlPortfolios.SelectedIndex > 0)
            {
                DropDownListStock.Items.Clear();
                TextBoxSearch.Text              = "";
                textboxSelectedSymbol.Text      = "";
                ViewState["GraphScript"]        = "";
                ddlExchange.SelectedIndex       = 0;
                ddlInvestmentType.SelectedIndex = 0;
                //ViewState["STOCKMASTER"] = null;

                StockManager stockManager = new StockManager();
                DataTable    symbolTable  = stockManager.getSymbolListFromPortfolio(ddlPortfolios.SelectedValue);
                if ((symbolTable != null) && (symbolTable.Rows.Count > 0))
                {
                    //ViewState["STOCKMASTER"] = symbolTable;
                    DropDownListStock.Items.Clear();
                    DropDownListStock.DataTextField  = "COMP_NAME";
                    DropDownListStock.DataValueField = "SYMBOL";
                    DropDownListStock.DataSource     = symbolTable;
                    DropDownListStock.DataBind();

                    ListItem li = new ListItem("Select Investment", "-1");
                    DropDownListStock.Items.Insert(0, li);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noScriptsInPortfolio + "');", true);
                }
            }
        }
Exemple #30
0
 // Start is called before the first frame update
 void Start()
 {
     theDate   = FindObjectOfType <DateManager>();
     theNotice = FindObjectOfType <NoticeManager>();
     theStock  = FindObjectOfType <StockManager>();
     newsList  = new List <News>();
     SetAlert();
 }
        public void UpdateStock_AddNew()
        {
            var newStock = new Stock();
            var addedStock = new Stock { Id = 1 };

            Mock<IDataRepositoryFactory> mockDataRepositoryFactory = new Mock<IDataRepositoryFactory>();
            mockDataRepositoryFactory.Setup(mock => mock.GetDataRepository<IStockRepository>().Add(newStock)).Returns(addedStock);

            StockManager manager = new StockManager(mockDataRepositoryFactory.Object);
            var resultedStock = manager.UpdateStock(newStock);

            Assert.AreEqual(addedStock, resultedStock);
        }
 private void DeductItems(StockManager stock, CuttingInstructions cuttingInstructions)
 {
     stock.DeductFromStock(cuttingInstructions.StockLength,
                           cuttingInstructions.Cost,
                           cuttingInstructions.Quantity);
     foreach (var cutItem in cuttingInstructions.Items)
     {
         var item = Items.SingleOrDefault(i => i.Length == cutItem.Length);
         if (item == null)
             throw new InvalidOperationException("No item of that length " + cutItem.Length + " exists.");
         item.ReduceQuantityBy(cutItem.Quantity * cuttingInstructions.Quantity);
     }
 }
        public void UpdateStock_UpdateExisting()
        {
            var existingStock = new Stock { Id = 1 };
            var updatedStock = new Stock { Id = 1 };

            Mock<IDataRepositoryFactory> mockDataRepositoryFactory = new Mock<IDataRepositoryFactory>();
            mockDataRepositoryFactory.Setup(mock => mock.GetDataRepository<IStockRepository>().Update(existingStock)).Returns(updatedStock);

            StockManager manager = new StockManager(mockDataRepositoryFactory.Object);
            var resultedStock = manager.UpdateStock(existingStock);

            Assert.AreEqual(updatedStock, resultedStock);
        }
 public IEnumerable<CuttingInstructions> OptimizeFromStock(StockManager stock)
 {
     var results = new List<CuttingInstructions>();
     CuttingInstructions instructions;
     do
     {
         instructions = GetBestInstructionsForRemainingPieces(stock);
         if (instructions != null)
         {
             results.Add(instructions);
         }
     } while (instructions != null);
     return results;
 }
        public void Stock_GetAll()
        {
            var stocks = new[]
            {
                new Stock {Id = 1, Notes = "Stock 1"},
                new Stock {Id = 2, Notes = "Stock 2"}
            };

            Mock<IDataRepositoryFactory> mockDataRepositoryFactory = new Mock<IDataRepositoryFactory>();
            mockDataRepositoryFactory.Setup(mock => mock.GetDataRepository<IStockRepository>().Get()).Returns(stocks);

            StockManager manager = new StockManager(mockDataRepositoryFactory.Object);
            var resultedStock = manager.GetAllStocks();

            Assert.AreEqual(stocks.Length, resultedStock.Length);
        }
        public static void RunExample()
        {
            Console.WriteLine("Select a Company to lookup stocks.{0}(M for Microsoft, G for Google, A for Apple):", Environment.NewLine);

            ConsoleKeyInfo pressed;

            do
            {
                pressed = Console.ReadKey();
                Console.WriteLine();
                if (pressed.Key == ConsoleKey.Escape) break;

                StockMessageFactory messageFactory = new StockMessageFactory(new DatabaseStockRepository(), new OnlineStockRepository(), new StockComparer(), pressed.KeyChar);
                StockManager manager = new StockManager(messageFactory, new PostalNotification());

                manager.NotifyCustomer();

            } while (pressed.Key != ConsoleKey.Escape);
        }
 private CuttingInstructions GetBestInstructionsForRemainingPieces(StockManager stock)
 {
     if (!HasRemainingPieces)
         return null;
     CuttingInstructions best = null;
     foreach (var stockItem in stock.Items)
     {
         var current = new CuttingInstructions(stock.ShapeId,
                                               stockItem.Length,
                                               stockItem.Cost,
                                               stockItem.Kerf,
                                               Items.Where(i => i.Quantity > 0)
                                                   .Select(i => i.Clone()));
         current.Optimize();
         if (best == null)
         {
             best = current;
         }
         else
         {
             if (current.Waste < best.Waste)
             {
                 best = current;
             }
             else if (current.Waste == best.Waste)
             {
                 var currentNumberOfCuts = current.Items.Sum(i => i.Quantity);
                 var bestNumberOfCuts = best.Items.Sum(i => i.Quantity);
                 if (currentNumberOfCuts < bestNumberOfCuts)
                     best = current;
                 else if (currentNumberOfCuts == bestNumberOfCuts && current.StockLength > best.StockLength)
                     best = current;
             }
         }
     }
     if (best != null)
         DeductItems(stock, best);
     return best;
 }
 public static bool On_StockManager_IsItemInStocks(StockManager self, Item item)
 {
     return item.InStockpile;
 }
 public static int On_StockManager_QuantityInStock(StockManager self, ItemID itemID, int material)
 {
     ItemsByQuality itemsByQuality = ((ItemsByQuality[])StockManager_ItemsByQuality_InStockItems.GetValue(self))[(int)itemID];
     if (itemsByQuality == null)
     {
         return 0;
     }
     var largeItems = myClasses[itemsByQuality];
     if (largeItems == null)
     {
         return 0;
     }
     var count = 0;
     foreach (var cat in largeItems)
     {
         if (material == 80)
         {
             foreach (var list in cat.Value.Items)
             {
                 count += list.Value.Count;
             }
         }
         else
         {
             HashSet<Item> list;
             if (cat.Value.Items.TryGetValue(material, out list))
             {
                 count += list.Count;
             }
         }
     }
     return count;
 }
 public static bool On_StockManager_AreItemsAvailable(StockManager self, Vector3 pos, ItemID itemID, uint quantity, int material, ItemQuality itemQuality, bool atLeastQuality)
 {
     if (GnomanEmpire.Instance.Map.GetCell(pos).NavGraphNode == null)
     {
         return false;
     }
     ItemsByQuality itemsByQuality = ((ItemsByQuality[])StockManager_ItemsByQuality_InStockItems.GetValue(self))[(int)itemID];
     if (itemsByQuality == null)
     {
         return false;
     }
     ItemsByMaterial itemsByMaterial = itemsByQuality.ItemsOfQuality(itemQuality, atLeastQuality);
     return itemsByMaterial != null && itemsByMaterial.AreItemsAvailable(pos, quantity, material);
 }
        public static bool On_StockManager_IsItemInStocks(StockManager self, Item item)
        {
            var inStockItems = (ItemsByQuality[])StockManager_ItemsByQuality_InStockItems.GetValue(self);

            ItemsByQuality itemsByQuality = inStockItems[(int)item.ItemID];
            if (itemsByQuality == null)
            {
                return false;
            }
            var items = myClasses[itemsByQuality];
            foreach (var el in items)
            {
                foreach (var el2 in el.Value.Items)
                {
                    if (el2.Value.Contains(item))
                    {
                        return true;
                    }
                }
            }
            return false;
        }