Exemplo n.º 1
0
        public dtoResult Save(dtoProduct objProduct)
        {
            dtoResult objResult = new dtoResult();

            try
            {
                if (objProduct == null)
                    throw new Exception("Please provide valid Product details.");

                objProduct.productCode = ("" + objProduct.productCode).Trim();

                if (objProduct.productCode == string.Empty)
                    throw new Exception("Please provide valid Product Code.");

                if (objProduct.productId == 0)
                {
                    if (objProduct.createdBy < 1)
                        throw new Exception("Please provide valid User ID.");
                    objResult = repo.Insert(objProduct);
                }
                else
                {
                    if (objProduct.modifiedBy < 1)
                        throw new Exception("Please provide valid User ID.");
                    objResult = repo.Update(objProduct);
                }
            }
            catch (Exception ex)
            {
                objResult.isSuccessful = false;
                objResult.errorMsg = ex.Message;
            }

            return objResult;
        }
Exemplo n.º 2
0
 public dtoResult Update(dtoProduct product)
 {
     return repo.Update(product);
 }
Exemplo n.º 3
0
 public dtoResult InLineUpdate(dtoProduct product)
 {
     return repo.InLineUpdate(product);
 }
Exemplo n.º 4
0
 public dtoResult Insert(dtoProduct product)
 {
     return repo.Insert(product);
 }
Exemplo n.º 5
0
        public dtoResult Update(dtoProduct t)
        {
            dtoResult objResult = new dtoResult();
            List<object> parameterList = new List<object>();
            object[] parameters1 = null;

            try
            {
                string sQuery = string.Format(@"UPDATE tbl_product SET categoryId = @P0
                                                , productCode = @P1
                                                , productDescription=@P2
                                                , UOM=@P3
                                                , unitPrice=@P4
                                                , reorderLevel=@P5
                                                , modifiedBy=@P6
                                                , dateLastModified=GETDATE()
                                                , beginning=@P8
                                                , incoming=@P9
                                                , outgoing=@P10
                                                , ending =@P11
                                                WHERE productId=@P7");

                parameterList.Add(t.categoryId);
                parameterList.Add(t.productCode);
                parameterList.Add(t.productDescription);
                parameterList.Add(t.UOM);
                parameterList.Add(t.unitPrice);
                parameterList.Add(t.reorderLevel);
                parameterList.Add(t.modifiedBy);
                parameterList.Add(t.productId);
                parameterList.Add(t.beginning);
                parameterList.Add(t.incoming);
                parameterList.Add(t.outgoing);
                parameterList.Add(t.beginning + t.incoming - t.outgoing);
                parameters1 = parameterList.ToArray();

                DBContext.Database.ExecuteSqlCommand(sQuery, parameters1);
                objResult.isSuccessful = true;
            }
            catch (Exception ex)
            {
                objResult.isSuccessful = false;
                objResult.errorMsg = ex.Message;
            }

            parameterList = null;
            parameters1 = null;

            return objResult;
        }
Exemplo n.º 6
0
 public dtoResult SoftDelete(dtoProduct t)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        public dtoResult Insert(dtoProduct t)
        {
            dtoResult objResult = new dtoResult();
            List<object> parameterList = new List<object>();
            object[] parameters1 = null;

            try
            {
                string sQuery = string.Format(@"INSERT INTO tbl_product(categoryId
                                                , productCode
                                                , productDescription
                                                , UOM
                                                , unitPrice
                                                , reorderLevel
                                                , branchId
                                                , createdBy
                                                , dateCreated
                                                , beginning
                                                , incoming
                                                , outgoing
                                                , ending)
                                                VALUES(@P0, @P1, @P2, @P3, @P4, @P5, @P6, @P7, GETDATE(), @P8, @P9, @P10, @P11)");

                parameterList.Add(t.categoryId);
                parameterList.Add(t.productCode);
                parameterList.Add(t.productDescription);
                parameterList.Add(t.UOM);
                parameterList.Add(t.unitPrice);
                parameterList.Add(t.reorderLevel);
                parameterList.Add(t.branchId);
                parameterList.Add(t.createdBy);
                parameterList.Add(t.beginning);
                parameterList.Add(t.incoming);
                parameterList.Add(t.outgoing);
                parameterList.Add(t.beginning + t.incoming - t.outgoing);
                parameters1 = parameterList.ToArray();

                DBContext.Database.ExecuteSqlCommand(sQuery, parameters1);
                objResult.isSuccessful = true;
            }
            catch (Exception ex)
            {
                objResult.isSuccessful = false;
                objResult.errorMsg = ex.Message;
            }

            parameterList = null;
            parameters1 = null;

            return objResult;
        }
Exemplo n.º 8
0
        public dtoResult InLineUpdate(dtoProduct t)
        {
            dtoResult objResult = new dtoResult();
            List<object> parameterList = new List<object>();
            object[] parameters1 = null;

            try
            {
                string sQuery = string.Format(@"UPDATE tbl_product SET
                                                modifiedBy=@P0
                                                , dateLastModified=GETDATE()
                                                , beginning=@P1
                                                , incoming=@P2
                                                , outgoing=@P3
                                                , ending =@P4
                                                WHERE productId=@P5");

                parameterList.Add(t.modifiedBy);
                parameterList.Add(t.beginning);
                parameterList.Add(t.incoming);
                parameterList.Add(t.outgoing);
                parameterList.Add(t.beginning + t.incoming - t.outgoing);
                parameterList.Add(t.productId);
                parameters1 = parameterList.ToArray();

                DBContext.Database.ExecuteSqlCommand(sQuery, parameters1);
                objResult.isSuccessful = true;
            }
            catch (Exception ex)
            {
                objResult.isSuccessful = false;
                objResult.errorMsg = ex.Message;
            }

            return objResult;
        }
Exemplo n.º 9
0
 public dtoProduct Get(dtoProduct t)
 {
     throw new NotImplementedException();
 }