Пример #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));
            }
        }
Пример #2
0
        public ENResult update(uspGEProductSearch_Result data, IList <ENProductProperty> listProperty, IList <ENProductProperty> listPropertyDelete)
        {
            try
            {
                using (erpStoreEntities db = new erpStoreEntities())
                {
                    db.uspGEProductUpdate(data.idProduct, data.idCategory, data.idBrand, data.codeUnit, data.name, data.divisible,
                                          data.divisibleCodeUnit, data.divisibleNumberParts, data.perishable, data.traceable, data.barcodeType,
                                          PUser, PReturnCode, PReturnMessage);
                    if (Convert.ToInt32(PReturnCode.Value) == 0)
                    {
                        if (listProperty != null)
                        {
                            for (int i = 0; i < listProperty.Count; i++)
                            {
                                ENProductProperty temp = listProperty[i];
                                if (temp.idProperty == 0)
                                {
                                    db.uspGEProductPropertyInsert(data.idProduct, temp.name, temp.abbreviation, temp.required, PUser, PReturnCode, PReturnMessage);
                                }
                                else
                                {
                                    db.uspGEProductPropertyUpdate(temp.idProperty, data.idProduct, temp.name, temp.abbreviation, temp.required, PUser, PReturnCode, PReturnMessage);
                                }
                                if (Convert.ToInt32(PReturnCode.Value) != 0)
                                {
                                    break;
                                }
                            }
                        }
                        if (listPropertyDelete != null)
                        {
                            for (int i = 0; i < listPropertyDelete.Count; i++)
                            {
                                ENProductProperty temp = listPropertyDelete[i];
                                db.uspGEProductPropertyDelete(data.idProduct, temp.idProperty, PUser, PReturnCode, PReturnMessage);

                                if (Convert.ToInt32(PReturnCode.Value) != 0)
                                {
                                    break;
                                }
                            }
                        }
                        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));
            }
        }
Пример #3
0
 public ENResult insert(uspSEProfileActionSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspSEProfileActionInsert(data.idProfile, data.code, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #4
0
 public ENResult update(uspSEActionSearch_Result data, string codeNew)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspSEActionUpdate(data.code, codeNew, data.name, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #5
0
 public ENResult updatePassword(uspSEUserLogin_Result data, string passwordNew)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspSEUserUpdatePassword(data.userName, passwordNew, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #6
0
 public ENResult delete(uspGEStoreSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEStoreDelete(data.idStore, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #7
0
 public ENResult insert(uspGEStoreSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEStoreInsert(data.name, data.address, data.processSale, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #8
0
 public ENResult insert(uspGEProductPropertySearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEProductPropertyInsert(data.idProduct, data.name, data.abbreviation, data.required, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #9
0
 public ENResult search()
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             List <uspGEStoreSearch_Result> result = db.uspGEStoreSearch(PUser, PReturnCode, PReturnMessage).ToList();
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), result));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #10
0
 public ENResult update(uspSEUserLogin_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspSEUserUpdate(data.userName, data.idProfile, data.idStore, data.name, data.lastname, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #11
0
 public ENResult searchDetail(int idEntry)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             List <uspWAEntryDetailSearch_Result> detail = db.uspWAEntryDetailSearch(idEntry, PUser, PReturnCode, PReturnMessage).ToList();
             ENResult propertyResult = searchDetailProperty(idEntry);
             List <uspWAEntryDetailPropertySearch_Result> listProperty = (List <uspWAEntryDetailPropertySearch_Result>)propertyResult.result;
             List <ENEntryDetail> listProduct = new List <ENEntryDetail>();
             for (int i = 0; i < detail.Count; i++)
             {
                 ENEntryDetail temp = new ENEntryDetail();
                 temp.idEntry       = detail[i].idEntry;
                 temp.idProduct     = (int)detail[i].idProduct;
                 temp.idEntryDetail = detail[i].idEntryDetail;
                 temp.name          = detail[i].name;
                 temp.perishable    = (bool)detail[i].perishable;
                 temp.quantity      = detail[i].quantity;
                 temp.purchasePrice = detail[i].purchasePrice;
                 if (detail[i].dueDate != null)
                 {
                     temp.dueDate = (DateTime)detail[i].dueDate;
                 }
                 List <ENEntryDetailProperty> tempListProperty = new List <ENEntryDetailProperty>();
                 List <uspWAEntryDetailPropertySearch_Result> tempListPropertySelect = listProperty.Where(row => row.idEntry == temp.idEntry && row.idEntryDetail == temp.idEntryDetail).ToList();
                 for (int j = 0; j < tempListPropertySelect.Count; j++)
                 {
                     ENEntryDetailProperty tempProperty = new ENEntryDetailProperty();
                     tempProperty.idEntry       = tempListPropertySelect[j].idEntry;
                     tempProperty.idEntryDetail = tempListPropertySelect[j].idEntryDetail;
                     tempProperty.idProduct     = tempListPropertySelect[j].idProduct;
                     tempProperty.idProperty    = tempListPropertySelect[j].idProperty;
                     tempProperty.value         = tempListPropertySelect[j].value;
                     tempProperty.name          = tempListPropertySelect[j].name;
                     tempListProperty.Add(tempProperty);
                 }
                 temp.listDetailProperty = tempListProperty;
                 listProduct.Add(temp);
             }
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), listProduct));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #12
0
 public ENResult update(uspSASaleSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspSASaleUpdate(data.idSale, data.documentType, data.documentNumber, data.date,
                                data.status, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #13
0
 public ENResult update(uspPUSupplierSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspPUSupplierUpdate(data.idSupplier, data.name, data.documentType, data.documentNumber, data.address,
                                    data.phoneNumber, data.email, data.contactPerson, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #14
0
 public ENResult update(uspGEGlobalParametersSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEGlobalParametersUpdate(data.IGV, data.percentageMinWholesalePrice, data.percentageMinRetailPrice,
                                            PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #15
0
 public ENResult update(uspTRCashMovementSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspTRCashMovementUpdate(data.idMovement, data.idCash, data.idSale, data.date, data.movementType,
                                        data.amount, data.amountOpening, data.amountClosing, data.concept, data.userUpdated, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #16
0
 public ENResult update(uspGEProductPriceSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEProductPriceUpdate(data.idProduct, data.purchasePrice, data.wholesalePrice, data.wholesaleMinPrice,
                                        data.retailPrice, data.retailMinPrice, data.partPrice, data.userUpdated, PReturnCode, PReturnMessage);
             db.uspGEProductPriceAuditInsert(data.idProduct, data.purchasePrice, data.wholesalePrice, data.wholesaleMinPrice,
                                             data.retailPrice, data.retailMinPrice, data.partPrice, data.userUpdated, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #17
0
 public ENResult searchProductById(int idProduct)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             List <uspGEProductSearchById_Result> result = db.uspGEProductSearchById(idProduct, PUser, PReturnCode, PReturnMessage).ToList();
             if (result.Count == 1)
             {
                 return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), result[0]));
             }
             else
             {
                 return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), null));
             }
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }
Пример #18
0
        public ENResult login(string userName, string password)
        {
            try
            {
                using (erpStoreEntities db = new erpStoreEntities())
                {
                    List <uspSEUserLogin_Result> result = db.uspSEUserLogin(userName, password, PUser, PReturnCode, PReturnMessage).ToList();
                    if (result.Count > 0 && Convert.ToInt32(PReturnCode.Value) == 0)
                    {
                        ENUser user = new ENUser();
                        user.userName    = result[0].userName;
                        user.idProfile   = result[0].idProfile;
                        user.idStore     = result[0].idStore;
                        user.name        = result[0].name;
                        user.lastname    = result[0].lastname;
                        user.profileName = result[0].profileName;
                        user.storeName   = result[0].storeName;
                        user.actions     = new List <ENUserAction>();
                        List <uspSEUserProfileActionSearch_Result> actions = db.uspSEUserProfileActionSearch(userName, PUser, PReturnCode, PReturnMessage).ToList();

                        for (int i = 0; i < actions.Count; i++)
                        {
                            user.actions.Add(new ENUserAction(actions[i].code, actions[i].name));
                        }

                        return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value), user));
                    }
                    else
                    {
                        return(new ENResult(3, "Usuario o clave incorrecta"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(PUnexpectedError(ex));
            }
        }
Пример #19
0
 public ENResult insert(uspSASaleSearch_Result data, List <uspSASaleDetailSearch_Result> detail)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             ObjectParameter objIdSale = new ObjectParameter("idSale", 0);
             db.uspSASaleInsert(data.documentType, data.documentNumber, data.date, data.ticket,
                                data.status, PUser, objIdSale, PReturnCode, PReturnMessage);
             if (Convert.ToInt32(PReturnCode.Value) == 0)
             {
                 int    codeTemp    = 0;
                 string messageTemp = "";
                 for (int i = 0; i < detail.Count; i++)
                 {
                     db.uspSASaleDetailInsert(Convert.ToInt32(objIdSale), detail[i].idProduct, detail[i].quantity, detail[i].unitPrice, detail[i].partSale, PUser, PReturnCode, PReturnMessage);
                     codeTemp    = Convert.ToInt32(PReturnCode.Value);
                     messageTemp = Convert.ToString(PReturnMessage.Value);
                     if (codeTemp != 0)
                     {
                         break;
                     }
                 }
                 return(new ENResult(codeTemp, messageTemp));
             }
             else
             {
                 return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
             }
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }