Esempio n. 1
0
 private void detach_PartSafeties(PartSafety entity)
 {
     this.SendPropertyChanging();
     entity.PartInfo = null;
 }
Esempio n. 2
0
    protected void ProcessSafety(long piId)
    {
        long wId;

        foreach (GridViewRow row in gvSafeties.Rows)
        {
            TextBox txt = (TextBox)row.FindControl("txtSafetyQuantity");
            long.TryParse(txt.Attributes["WHID"], out wId);

            PartSafety ps = PartInfoDAO.GetPartSafety(piId, wId);
            if (ps == null && (wId > 0) && (piId > 0))
            {
                ps = new PartSafety() { PartInfoId = piId, WarehouseId = wId };
                PartInfoDAO.PartDC.PartSafeties.InsertOnSubmit(ps);
            }
            if (ps != null)
            {
                int qty;
                int.TryParse(txt.Text, out qty);
                ps.SafetyQuantity = qty;
            }
        }
    }
Esempio n. 3
0
 private void attach_PartSafeties(PartSafety entity)
 {
     this.SendPropertyChanging();
     entity.Warehouse = this;
 }
Esempio n. 4
0
 public PartSafetySetting(PartSafety ps)
 {
     this.PartCode = ps.PartInfo.PartCode;
     this.PartInfo = ps.PartInfo;
     this.PartInfoId = ps.PartInfoId;
     this.SafetyQuantity = ps.SafetyQuantity;
     this.CurrentStock = ps.CurrentStock;
     this.Warehouse = ps.Warehouse;
     this.WarehouseId = ps.WarehouseId;
 }
Esempio n. 5
0
        public static PartSafety CreatePartSafety(PartInfo pInfo, long warehouseId, int quantity, int safeQty)
        {
            //Warehouse wh = PartDC.ActiveWarehouses.SingleOrDefault(w => w.WarehouseId == warehouseId);
            //if (wh == null) return null;

            //PartInfo pi = PartDC.PartInfos.SingleOrDefault(p => p.PartCode == partCode && p.DealerCode == wh.DealerCode);
            //if (pi == null) return null;

            var db = DCFactory.GetDataContext<PartDataContext>();
            PartSafety ps = null;
            if (pInfo.PartInfoId != 0) ps = db.PartSafeties.SingleOrDefault(p => p.PartInfoId == pInfo.PartInfoId);
            if (ps != null)
                ps.CurrentStock += quantity;
            else
            {
                ps = new PartSafety
                {
                    CurrentStock = quantity,
                    SafetyQuantity = safeQty,
                    WarehouseId = warehouseId
                };
                db.PartSafeties.InsertOnSubmit(ps);
            }
            return ps;
        }
Esempio n. 6
0
 public PartSafetySetting(PartSafety ps, string vName, string eName)
     : this(ps)
 {
     this.EnglishName = eName;
     this.VietNameName = vName;
 }
Esempio n. 7
0
        /// <summary>
        /// Inc Current Stock n Create "part safety" if needed
        /// </summary>
        /// <param name="pi"></param>
        /// <param name="Quantity"></param>
        /// <param name="warehouseId"></param>
        public static void IncCurrentStock(PartInfo pi, int Quantity, long warehouseId)
        {
            var ps = PartInfoDAO.GetPartSafety(pi.PartInfoId, warehouseId);
            if (ps == null)
            {
                var db = new PartDataContext(); // must create another data context
                ps = new PartSafety
                {
                    WarehouseId = warehouseId,
                    PartInfoId = pi.PartInfoId,
                    CurrentStock = 0,
                    SafetyQuantity = 0
                };
                db.PartSafeties.InsertOnSubmit(ps);
                db.SubmitChanges();
                //db.Dispose();

            }

            ps = PartInfoDAO.GetPartSafety(pi.PartInfoId, warehouseId);
            if (ps != null)
            {
                ps.CurrentStock += Quantity;
                if (ps.CurrentStock < 0)
                {
                    throw new Exception(string.Format("On hand quantity of \"{0}\" will be negative!", pi.PartCode));
                }
            }
            else throw new Exception(string.Format("Cannot create safatyStock to inc current stock for {0}!", pi.PartCode));
        }
Esempio n. 8
0
    protected void txtSafetyQuantity_OnTextChanged(object sender, EventArgs e)
    {
        try
        {
            TextBox txt = (TextBox)sender;
            long piId, wId;

            long.TryParse(txt.Attributes["WHID"], out wId);
            long.TryParse(txt.Attributes["PIID"], out piId);

            PartSafety ps = PartInfoDAO.GetPartSafety(piId, wId);
            if (ps == null && (wId > 0) && (piId > 0))
            {
                ps = new PartSafety() { PartInfoId = piId, WarehouseId = wId };
                PartInfoDAO.PartDC.PartSafeties.InsertOnSubmit(ps);
            }
            if (ps != null)
            {
                int qty;
                int.TryParse(txt.Text, out qty);
                ps.SafetyQuantity = qty;
            }
        }
        catch (Exception ex) { AddErrorMsg(ex.Message); }
    }
 private void detach_PartSafeties(PartSafety entity)
 {
     this.SendPropertyChanging("PartSafeties");
     entity.Warehouse = null;
 }
 private void attach_PartSafeties(PartSafety entity)
 {
     this.SendPropertyChanging("PartSafeties");
     entity.PartInfo = this;
 }