private void deleteDetails(JObject value, PurchaseDelivery obj)
 {
     try
     {
         #region delete details
         string detalclassname = "PurchaseDeliveryDetail";
         bool   isnew          = false;
         int    intkeyvalue    = -1;
         JArray jarray         = (JArray)value[detalclassname];
         foreach (JObject Jdtl in jarray.Children())
         {
             isnew = false;
             if (Jdtl.ContainsKey("Oid"))
             {
                 if (Jdtl["Oid"] == null)
                 {
                     isnew = true;
                 }
                 else
                 {
                     if (int.TryParse(Jdtl["Oid"].ToString(), out intkeyvalue))
                     {
                         if (intkeyvalue == -1)
                         {
                             isnew = true;
                         }
                     }
                 }
             }
             else
             {
                 isnew = true;
             }
             if (!isnew)
             {
                 if (Jdtl.ContainsKey("IsBeingDelete"))
                 {
                     if (Jdtl["IsBeingDelete"].ToString() == "1" || Jdtl["IsBeingDelete"].ToString().ToUpper() == "TRUE")
                     {
                         PurchaseDeliveryDetail dtl = obj.PurchaseDeliveryDetail.Where(pp => pp.Oid == intkeyvalue).FirstOrDefault();
                         if (dtl != null)
                         {
                             dtl.Delete();
                         }
                         //obj.PurchaseDeliveryDetail.Remove(dtl);
                     }
                 }
             }
         }
         #endregion
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #2
0
        public ActionResult Add([FromBody] JObject values)
        {
            try
            {
                GenHelper.WriteLog("[Log]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Post:[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");

                PurchaseDeliveryDetail employee = objectSpace.CreateObject <PurchaseDeliveryDetail>();
                JsonParser.ParseJObjectXPO <PurchaseDeliveryDetail>(values, employee, objectSpace);
                objectSpace.CommitChanges();
                return(Ok(employee));
            }
            catch (Exception ex)
            {
                GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Post:[" + ex.Message + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                throw new Exception(ex.Message);
            }
        }
Пример #3
0
        public ActionResult Get(int id)
        {
            try
            {
                GenHelper.WriteLog("[Log]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Get(" + id.ToString() + "):[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");

                PurchaseDeliveryDetail existing = objectSpace.GetObjectByKey <PurchaseDeliveryDetail>(id);
                if (existing == null)
                {
                    NotFound();
                }
                return(Ok(existing));
            }
            catch (Exception ex)
            {
                GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Get(" + id.ToString() + "):[" + ex.Message + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                throw new Exception(ex.Message);
            }
        }
Пример #4
0
        public ActionResult Update(int id, [FromBody] JObject values)
        {
            try
            {
                GenHelper.WriteLog("[Log]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Put(" + id.ToString() + "):[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");

                PurchaseDeliveryDetail employee = objectSpace.GetObjectByKey <PurchaseDeliveryDetail>(id);
                if (employee != null)
                {
                    JsonParser.ParseJObjectXPO <PurchaseDeliveryDetail>(values, employee, objectSpace);
                    objectSpace.CommitChanges();
                    return(Ok(employee));
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-Put(" + id.ToString() + "):[" + ex.Message + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                throw new Exception(ex.Message);
            }
        }
//[HttpGet]
//public List<DocTypeSeries> Get()
//{
//    List<DocTypeSeries> result = null;
//    XPQuery<DocTypeSeries> query = (XPQuery<DocTypeSeries>)_uow.Query<DocTypeSeries>();
//    result = query.ToList<DocTypeSeries>();

//    return result;
//}

        private void addNewDetailsOnly(JObject value, PurchaseDelivery obj, bool IsNewHeader)
        {
            try
            {
                #region add details
                string detalclassname = "PurchaseDeliveryDetail";
                bool   isnew          = false;
                int    intkeyvalue    = -1;
                JArray jarray         = (JArray)value[detalclassname];
                foreach (JObject Jdtl in jarray.Children())
                {
                    isnew = false;
                    if (IsNewHeader)
                    {
                        isnew = true;
                    }
                    else
                    {
                        if (Jdtl.ContainsKey("Oid"))
                        {
                            if (Jdtl["Oid"] == null)
                            {
                                isnew = true;
                            }
                            else
                            {
                                if (int.TryParse(Jdtl["Oid"].ToString(), out intkeyvalue))
                                {
                                    if (intkeyvalue == -1)
                                    {
                                        isnew = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            isnew = true;
                        }
                    }
                    if (isnew)
                    {
                        if (Jdtl.ContainsKey("IsBeingDelete"))
                        {
                            if (Jdtl["IsBeingDelete"].ToString() == "1" || Jdtl["IsBeingDelete"].ToString().ToUpper() == "TRUE")
                            {
                                isnew = false;
                            }
                        }
                        if (isnew)
                        {
                            PurchaseDeliveryDetail dtl = JsonPopulateObjectHelper.PopulateObject <PurchaseDeliveryDetail>(Jdtl.ToString(), _uow);
                            obj.PurchaseDeliveryDetail.Add(dtl);
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #6
0
        public IActionResult GenGRN([FromBody] JObject values)
        {
            try
            {
                GenHelper.WriteLog("[Log]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                GenHelper.WriteLog("[Json]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[" + Environment.NewLine + values.ToString() + Environment.NewLine + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");

                //
                //JsonParser.ParseJObjectXPO<PurchaseDelivery>(values, employee, objectSpace);
                string           temp = "";
                JToken           token;
                PurchaseDelivery employee = objectSpace.CreateObject <PurchaseDelivery>();
                token              = values["CardCode"];
                temp               = token["BoKey"].ToString();
                employee.CardCode  = objectSpace.FindObject <vwBusinessPartners>(CriteriaOperator.Parse("BoKey=?", temp));
                employee.NumAtCard = values["NumAtCard"].ToString();

                //JsonPopulateObjectHelper.PopulateObjectWODetail(values.ToString(), employee.Session, employee);

                string detalclassname = "PurchaseDeliveryDetail";
                int    intkeyvalue    = -1;
                JArray jarray         = (JArray)values[detalclassname];
                int    cnt            = 0;
                foreach (JObject Jdtl in jarray.Children())
                {
                    if (Jdtl.ContainsKey("Oid"))
                    {
                        if (int.TryParse(Jdtl["Oid"].ToString(), out intkeyvalue))
                        {
                            PurchaseDeliveryDetail dtl = objectSpace.GetObjectByKey <PurchaseDeliveryDetail>(intkeyvalue);
                            cnt++;
                            dtl.VisOrder = cnt;
                            dtl.VerNo    = 1;
                            employee.PurchaseDeliveryDetail.Add(dtl);
                        }
                        else
                        {
                            GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[Details Key value is invalid][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                            throw new Exception("Details Key value is invalid");
                        }
                    }
                    else
                    {
                        GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[Details Key Column Not found][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                        throw new Exception("Details Key Column Not found");
                    }
                }
                if (employee.DocTypeSeries == null)
                {
                    GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[Document series is not found][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                    throw new Exception("Document series is not found");
                }
                employee.DocStatus.AddDocStatus(DocStatus.Accepted, "WebApi Generated");
                employee.DocStatus.CurrDocStatus = DocStatus.Accepted;
                employee.VerNo = 1;
                employee.AssignDocNumber();
                objectSpace.CommitChanges();
                return(Ok(employee.DocNum));
            }
            catch (Exception ex)
            {
                GenHelper.WriteLog("[Error]", "[" + securityProvider.GetUserName() + "]" + controllername + "-GenGRN:[" + ex.Message + "][" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "]");
                throw new Exception(ex.Message);
            }
        }
Пример #7
0
        private void Controller_ObjectCreated(object sender, ObjectCreatedEventArgs e)
        {
            ListView lv = ((ListView)View);

            if (lv.CollectionSource is PropertyCollectionSource)
            {
                PropertyCollectionSource collectionSource = (PropertyCollectionSource)lv.CollectionSource;
                if (collectionSource.MasterObject != null)
                {
                    int minvalue    = 0;
                    int maxvisorder = 0;

                    if (collectionSource.MasterObjectType == typeof(StockTransferRequest) && e.CreatedObject.GetType() == typeof(StockTransferRequestDetail))
                    {
                        StockTransferRequest       masterobject  = (StockTransferRequest)collectionSource.MasterObject;
                        StockTransferRequestDetail currentobject = (StockTransferRequestDetail)e.CreatedObject;

                        copyCon.GetStockDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;

                        if (sDtlS != null)
                        {
                            copyCon.copyClassStockTransferDocumentDetail(sDtlS, currentobject, e.ObjectSpace);
                        }
                    }
                    else if (collectionSource.MasterObjectType == typeof(PurchaseOrder))
                    {
                        PurchaseOrder       masterobject  = (PurchaseOrder)collectionSource.MasterObject;
                        PurchaseOrderDetail currentobject = (PurchaseOrderDetail)e.CreatedObject;

                        copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;
                        currentobject.DocCur   = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey);

                        if (sDtl != null)
                        {
                            copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace);
                        }
                    }
                    else if (collectionSource.MasterObjectType == typeof(PurchaseRequest))
                    {
                        PurchaseRequest       masterobject  = (PurchaseRequest)collectionSource.MasterObject;
                        PurchaseRequestDetail currentobject = (PurchaseRequestDetail)e.CreatedObject;

                        copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;

                        if (masterobject.DocCur != null)
                        {
                            currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey);
                        }

                        if (sDtl != null)
                        {
                            copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace);
                        }
                    }
                    else if (collectionSource.MasterObjectType == typeof(PurchaseDelivery))
                    {
                        PurchaseDelivery       masterobject  = (PurchaseDelivery)collectionSource.MasterObject;
                        PurchaseDeliveryDetail currentobject = (PurchaseDeliveryDetail)e.CreatedObject;

                        copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;

                        if (masterobject.DocCur != null)
                        {
                            currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey);
                        }

                        if (sDtl != null)
                        {
                            copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace);
                        }
                    }
                    else if (collectionSource.MasterObjectType == typeof(PurchaseReturn))
                    {
                        PurchaseReturn       masterobject  = (PurchaseReturn)collectionSource.MasterObject;
                        PurchaseReturnDetail currentobject = (PurchaseReturnDetail)e.CreatedObject;

                        copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;

                        if (masterobject.DocCur != null)
                        {
                            currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey);
                        }

                        if (sDtl != null)
                        {
                            copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace);
                        }
                    }
                    else if (collectionSource.MasterObjectType == typeof(PurchaseQuotation))
                    {
                        PurchaseQuotation       masterobject  = (PurchaseQuotation)collectionSource.MasterObject;
                        PurchaseQuotationDetail currentobject = (PurchaseQuotationDetail)e.CreatedObject;

                        copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder);

                        currentobject.Oid      = minvalue;
                        currentobject.VisOrder = maxvisorder;

                        if (masterobject.DocCur != null)
                        {
                            currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey);
                        }

                        if (sDtl != null)
                        {
                            copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace);
                        }
                    }
                }
            }

            sDtl  = null;
            sDtlS = null;
        }