Exemple #1
0
        public ENResult insert(uspWAEntrySearch_Result data, IList <ENEntryDetail> listDetail)
        {
            try
            {
                using (erpStoreEntities db = new erpStoreEntities())
                {
                    ObjectParameter objIdEntry = new ObjectParameter("idEntry", 0);
                    db.uspWAEntryInsert(data.idStore, data.idSupplier, data.entryType, data.date, PUser, objIdEntry, PReturnCode, PReturnMessage);
                    if (Convert.ToInt32(PReturnCode.Value) == 0)
                    {
                        if (listDetail != null)
                        {
                            for (int i = 0; i < listDetail.Count; i++)
                            {
                                ENEntryDetail temp = listDetail[i];
                                string        due  = "";
                                if (temp.dueDate.Year != 1)
                                {
                                    due = temp.dueDate.ToString("yyyy-MM-dd");
                                }
                                // objIdEntryDetail out put * faltaa
                                ObjectParameter objIdEntryDetail = new ObjectParameter("idEntryDetail", 0);
                                db.uspWAEntryDetailInsert(Convert.ToInt32(objIdEntry.Value), temp.idProduct, temp.quantity, temp.purchasePrice, due, PUser, objIdEntryDetail, PReturnCode, PReturnMessage);
                                int    codeTemp    = Convert.ToInt32(PReturnCode.Value);
                                string messageTemp = Convert.ToString(PReturnMessage.Value);
                                if (listDetail[i].listDetailProperty != null)
                                {
                                    for (int j = 0; j < listDetail[i].listDetailProperty.Count; j++)
                                    {
                                        ENEntryDetailProperty tempProperty = listDetail[i].listDetailProperty[j];
                                        db.uspWAEntryDetailPropertyInsert(Convert.ToInt32(objIdEntry.Value), Convert.ToInt32(objIdEntryDetail.Value), tempProperty.idProduct, tempProperty.idProperty, tempProperty.value, PUser, PReturnCode, PReturnMessage);

                                        if (Convert.ToInt32(PReturnCode.Value) != 0)
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (Convert.ToInt32(PReturnCode.Value) != 0)
                                {
                                    break;
                                }
                            }
                            return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
                        }
                        return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
                    }
                    else
                    {
                        return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
                    }
                }
            }
            catch (Exception ex)
            {
                return(PUnexpectedError(ex));
            }
        }
Exemple #2
0
 public ENResult delete(uspWAEntrySearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspWAEntryDelete(data.idEntry, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }