Ejemplo n.º 1
0
        public static Guid?add(Guid?ProductStoreNameID, Guid?GradeID, Guid?ProductWidthID, Guid?LengthUnitID, decimal TagPrice, string Notes,
                               Guid?InventoryID, Guid?ColorID, decimal?BuyPrice)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "productprice_new",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_PRODUCTSTORENAMEID, SqlDbType.UniqueIdentifier, Util.wrapNullable(ProductStoreNameID)),
                new SqlQueryParameter(COL_DB_GRADEID, SqlDbType.UniqueIdentifier, Util.wrapNullable(GradeID)),
                new SqlQueryParameter(COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier, Util.wrapNullable(ProductWidthID)),
                new SqlQueryParameter(COL_DB_LENGTHUNITID, SqlDbType.UniqueIdentifier, Util.wrapNullable(LengthUnitID)),
                new SqlQueryParameter(COL_DB_INVENTORYID, SqlDbType.UniqueIdentifier, Util.wrapNullable(InventoryID)),
                new SqlQueryParameter(COL_DB_COLORID, SqlDbType.UniqueIdentifier, Util.wrapNullable(ColorID)),
                new SqlQueryParameter(COL_DB_SELLPRICE, SqlDbType.Decimal, TagPrice),
                new SqlQueryParameter(COL_DB_BuyPrice, SqlDbType.Decimal, Util.wrapNullable(BuyPrice)),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(Notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 2
0
        public static void update(Guid id, string name)
        {
            State objOld = new State(id);

            //generate log description
            string logDescription = "";

            if (objOld.Name != name)
            {
                logDescription = Tools.append(logDescription, String.Format("Name: '{0}' to '{1}'", objOld.Name, name), ",");
            }

            if (!string.IsNullOrEmpty(logDescription))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "state_update",
                    new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_NAME, SqlDbType.VarChar, name)
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.submitUpdate(id, logDescription);
                }
            }
        }
Ejemplo n.º 3
0
        public void Should_be_possible_to_transform_a_sqlQueryResult_with_empty_field_into_a_list_of_ovalRecordType()
        {
            var fakeSqlQueryResult = new SqlQueryResult();

            fakeSqlQueryResult.AddRecord(CreateFakeRecord(new string[] { "id", "name" }, new object[] { null, null }));
            fakeSqlQueryResult.AddRecord(CreateFakeRecord(new string[] { "id", "name" }, new object[] { 1, null }));
            fakeSqlQueryResult.AddRecord(CreateFakeRecord(new string[] { "id", "name" }, new object[] { null, "John" }));
            fakeSqlQueryResult.AddRecord(CreateFakeRecord(new string[] { "id", "name" }, new object[] { 2, "Michael" }));

            var ovalRecords = fakeSqlQueryResult.ToOvalRecordTypeList();

            Assert.IsNotNull(ovalRecords);
            Assert.AreEqual(4, ovalRecords.Count());

            var firstRecord = ovalRecords.ElementAt(0);

            AssertField(firstRecord.field.First(), "id", null);
            AssertField(firstRecord.field.Last(), "name", null);

            var secondRecord = ovalRecords.ElementAt(1);

            AssertField(secondRecord.field.First(), "id", "1");
            AssertField(secondRecord.field.Last(), "name", null);

            var thirdRecord = ovalRecords.ElementAt(2);

            AssertField(thirdRecord.field.First(), "id", null);
            AssertField(thirdRecord.field.Last(), "name", "John");

            var fourthRecord = ovalRecords.ElementAt(3);

            AssertField(fourthRecord.field.First(), "id", "2");
            AssertField(fourthRecord.field.Last(), "name", "Michael");
        }
Ejemplo n.º 4
0
        public static bool add(Guid id, Guid customerId, string customerInfo, List <SaleOrderItem> items, string notes, DateTime targetDate, string customerPONo)
        {
            bool           isSuccess = false;
            SqlQueryResult result    = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "SaleOrders_add",
                new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                new SqlQueryParameter(COL_DB_Customers_Id, SqlDbType.UniqueIdentifier, customerId),
                new SqlQueryParameter(COL_DB_CustomerInfo, SqlDbType.VarChar, customerInfo),
                new SqlQueryParameter(COL_DB_TargetDate, SqlDbType.DateTime, targetDate),
                new SqlQueryParameter(COL_DB_CustomerPONo, SqlDbType.VarChar, customerPONo),
                new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                );

            if (result.IsSuccessful)
            {
                ActivityLog.submitCreate(id);

                //submit items
                if (SaleOrderItem.add(items))
                {
                    isSuccess = true;
                }
            }

            return(isSuccess);
        }
Ejemplo n.º 5
0
        public static void update(Guid id, Guid pettyCashRecordsCategories_Id, decimal amount, string notes)
        {
            PettyCashRecord objOld = new PettyCashRecord(id);
            string          log    = "";

            log = ActivityLog.appendChange(log, objOld.PettyCashRecordsCategories_Name, new PettyCashRecordsCategory(pettyCashRecordsCategories_Id).Name, "Category: '{0}' to '{1}'");
            log = ActivityLog.appendChange(log, objOld.Amount, amount, "Amount: '{0:N2}' to '{1:N2}'");
            log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "PettyCashRecords_update",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_PettyCashRecordsCategories_Id, SqlDbType.UniqueIdentifier, pettyCashRecordsCategories_Id),
                    new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, amount),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    if (GlobalData.UserAccount.role != Roles.Super)
                    {
                        ActivityLog.submit(id, "UPDATE: " + log, (int)Roles.Super);
                    }
                    else
                    {
                        ActivityLog.submit(id, "UPDATE: " + log);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public static Guid?add(Guid storeNameID, string nameVendor, Guid vendorID, decimal percentageOfPercentCommission, decimal?maxCommissionAmount, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "product_new",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_STORENAMEID, SqlDbType.UniqueIdentifier, storeNameID),
                new SqlQueryParameter(COL_DB_NAMEVENDOR, SqlDbType.VarChar, nameVendor),
                new SqlQueryParameter(COL_DB_VENDORID, SqlDbType.UniqueIdentifier, vendorID),
                new SqlQueryParameter(COL_DB_PercentageOfPercentCommission, SqlDbType.Decimal, percentageOfPercentCommission),
                new SqlQueryParameter(COL_DB_MaxCommissionAmount, SqlDbType.Decimal, Util.wrapNullable(maxCommissionAmount)),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
        public static void delete(Guid id)
        {
            CustomerSaleAdjustment obj = new CustomerSaleAdjustment(id);

            //generate log description
            string logDescription = "";

            logDescription = Tools.append(logDescription, String.Format("Customer Name: '{0}'", obj.CustomerName), ",");
            logDescription = Tools.append(logDescription, String.Format("Product Store Name: '{0}'", obj.ProductStoreName), ",");
            logDescription = Tools.append(logDescription, String.Format("Grade: '{0}'", obj.GradeName), ",");
            logDescription = Tools.append(logDescription, String.Format("Product Width: '{0}'", obj.ProductWidthName), ",");
            logDescription = Tools.append(logDescription, String.Format("Unit: '{0}'", obj.LengthUnitName), ",");
            logDescription = Tools.append(logDescription, String.Format("Adjustment: '{0}'", obj.AdjustmentPerUnit), ",");
            logDescription = Tools.append(logDescription, String.Format("Notes: '{0}'", obj.Notes), ",");

            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "customersaleadjustment_delete",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id)
                );

            if (result.IsSuccessful)
            {
                ActivityLog.submit(id, String.Format("Item deleted: {0}", logDescription));
            }
        }
Ejemplo n.º 8
0
        /*******************************************************************************************************/
        #region STATIC DATABASE METHODS

        public static bool add(List <SaleOrderItem> items)
        {
            foreach (SaleOrderItem item in items)
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "SaleOrderItems_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, item.Id),
                    new SqlQueryParameter(COL_DB_SaleOrders_Id, SqlDbType.UniqueIdentifier, item.SaleOrders_Id),
                    new SqlQueryParameter(COL_DB_Ref_Inventory_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(item.Ref_Inventory_Id)),
                    new SqlQueryParameter(COL_DB_PricePerUnit, SqlDbType.Decimal, item.PricePerUnit),
                    new SqlQueryParameter(COL_DB_ProductDescription, SqlDbType.VarChar, item.ProductDescription),
                    new SqlQueryParameter(COL_DB_Qty, SqlDbType.Decimal, item.Qty),
                    new SqlQueryParameter(COL_DB_UnitName, SqlDbType.VarChar, item.UnitName),
                    new SqlQueryParameter(COL_DB_LineNo, SqlDbType.TinyInt, item.LineNo),
                    new SqlQueryParameter(COL_DB_Status_enum_id, SqlDbType.TinyInt, SaleOrderItemStatus.New),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(item.Notes))
                    );

                if (!result.IsSuccessful)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        /*******************************************************************************************************/
        #region DATABASE METHODS

        public static Guid add(Guid userAccountID, List <PaymentInfo> paymentInfoList,
                               Guid source_BankAccounts_Id, Guid target_BankAccounts_Id, decimal amount,
                               string confirmationNumber, string notes)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "Payments_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Source_BankAccounts_Id, SqlDbType.UniqueIdentifier, source_BankAccounts_Id),
                    new SqlQueryParameter(COL_DB_Target_BankAccounts_Id, SqlDbType.UniqueIdentifier, target_BankAccounts_Id),
                    new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, Util.wrapNullable(amount)),
                    new SqlQueryParameter(COL_DB_ConfirmationNumber, SqlDbType.NVarChar, Util.wrapNullable(confirmationNumber)),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.add(sqlConnection, userAccountID, id, "Added");

                    for (int i = 0; i < paymentInfoList.Count; i++)//notes nya untuk Payment Item didapat dr mana ya pak?
                    {
                        PaymentItem.add(sqlConnection, userAccountID, id, paymentInfoList[i].Transaction_RefId, paymentInfoList[i].Amount, null);
                    }
                }
            }

            return(id);
        }
Ejemplo n.º 10
0
        public static void update(Guid userAccountID, Guid id, string name, string notes, List <int> userAccountAccessEnum)
        {
            UserAccountRole objOld = new UserAccountRole(id);
            string          log    = "";

            log = Util.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                if (!string.IsNullOrEmpty(log))
                {
                    SqlQueryResult result = DBConnection.query(
                        sqlConnection,
                        QueryTypes.ExecuteNonQuery,
                        "UserAccountRoles_update",
                        new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                        new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, Util.wrapNullable(name))
                        );

                    if (result.IsSuccessful)
                    {
                        LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, String.Format("Updated: {0}", log));
                    }
                }

                UserAccountAccessRoleAssignment.update(sqlConnection, userAccountID, id, userAccountAccessEnum);
            }
        }
Ejemplo n.º 11
0
        public static void update(Guid userAccountID, Guid id, string name, string notes)
        {
            WorkshiftCategory objOld = new WorkshiftCategory(id);
            string            log    = "";

            log = Util.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            if (string.IsNullOrEmpty(log))
            {
                Util.displayMessageBoxError("No changes to record");
            }
            else
            {
                using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
                {
                    SqlQueryResult result = DBConnection.query(
                        sqlConnection,
                        QueryTypes.ExecuteNonQuery,
                        "WorkshiftCategories_update",
                        new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                        new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, name),
                        new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, notes)
                        );

                    if (result.IsSuccessful)
                    {
                        ActivityLog.add(sqlConnection, userAccountID, id, String.Format("Updated: {0}", log));
                    }
                }
            }
        }
        public static void update(Guid id, string name, string notes)
        {
            PettyCashRecordsCategory objOld = new PettyCashRecordsCategory(id);
            string log = "";

            log = ActivityLog.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'");
            log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "PettyCashRecordsCategories_update",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Name, SqlDbType.VarChar, Util.wrapNullable(name)),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.submit(id, "UPDATE: " + log);
                }
            }
        }
Ejemplo n.º 13
0
        public static Guid add(Guid userAccountID, string name, Guid owner_RefId, string bankName, string accountNumber, string notes)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "BankAccounts_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, name),
                    new SqlQueryParameter(COL_DB_Owner_RefId, SqlDbType.UniqueIdentifier, owner_RefId),
                    new SqlQueryParameter(COL_DB_BankName, SqlDbType.NVarChar, bankName),
                    new SqlQueryParameter(COL_DB_AccountNumber, SqlDbType.NVarChar, accountNumber),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.add(sqlConnection, userAccountID, id, "Added");
                }
            }

            return(id);
        }
Ejemplo n.º 14
0
        public static Guid?add(Guid customerID, decimal debtLimit, int termDays, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "CustomerTerms_add",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_CUSTOMERS_ID, SqlDbType.UniqueIdentifier, customerID),
                new SqlQueryParameter(COL_DB_DEBTLIMIT, SqlDbType.Decimal, debtLimit),
                new SqlQueryParameter(COL_DB_TERMDAYS, SqlDbType.Int, termDays),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 15
0
        public static void delete(Guid id)
        {
            InventoryStockLevel obj = new InventoryStockLevel(id);

            //generate log description
            string logDescription = "";

            logDescription = Tools.append(logDescription, String.Format("Product Store Name: '{0}'", obj.ProductStoreName), ",");
            logDescription = Tools.append(logDescription, String.Format("Grade: '{0}'", obj.GradeName), ",");
            logDescription = Tools.append(logDescription, String.Format("Product Width: '{0}'", obj.ProductWidthName), ",");
            logDescription = Tools.append(logDescription, String.Format("Length Unit: '{0}'", obj.LengthUnitName), ",");
            logDescription = Tools.append(logDescription, String.Format("Vendor: '{0}'", obj.VendorName), ",");
            logDescription = Tools.append(logDescription, String.Format("Qty: '{0}'", obj.Qty), ",");
            logDescription = Tools.append(logDescription, String.Format("PO Notes: '{0}'", obj.PONotes), ",");
            logDescription = Tools.append(logDescription, String.Format("Notes: '{0}'", obj.Notes), ",");

            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "inventorystocklevel_delete",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id)
                );

            if (result.IsSuccessful)
            {
                ActivityLog.submit(id, String.Format("Deleted: {0}", logDescription));
            }
        }
        public static bool update(Guid Id, DateTime Timestamp, string Notes)
        {
            VendorInvoicePayment objOld = new VendorInvoicePayment(Id);
            string log = "";

            log = Util.appendChange(log, objOld.Timestamp, Timestamp, "Date: '{0:dd/MM/yy}' to '{1:dd/MM/yy}'");
            log = Util.appendChange(log, objOld.Notes, Notes, "Notes: '{0}' to '{1}'");

            if (string.IsNullOrEmpty(log))
            {
                return(Util.displayMessageBoxError("No changes to record"));
            }
            else
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "VendorInvoicePayments_update",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id),
                    new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Timestamp),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.submit(Id, String.Format("Updated: {0}", log));
                }

                return(result.IsSuccessful);
            }
        }
Ejemplo n.º 17
0
        public static Guid?add(Guid gradeID, Guid productID, Guid productWidthID, Guid lengthUnitID, Guid colorID, int qty, int orderLotQty, string poNotes, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "inventorystocklevel_add",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_GRADEID, SqlDbType.UniqueIdentifier, gradeID),
                new SqlQueryParameter(COL_DB_PRODUCTID, SqlDbType.UniqueIdentifier, productID),
                new SqlQueryParameter(COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier, productWidthID),
                new SqlQueryParameter(COL_DB_LENGTHUNITID, SqlDbType.UniqueIdentifier, lengthUnitID),
                new SqlQueryParameter(COL_DB_COLORID, SqlDbType.UniqueIdentifier, colorID),
                new SqlQueryParameter(COL_DB_ORDERLOTQTY, SqlDbType.Int, orderLotQty),
                new SqlQueryParameter(COL_DB_QTY, SqlDbType.Int, qty),
                new SqlQueryParameter(COL_DB_PONOTES, SqlDbType.VarChar, Util.wrapNullable(poNotes)),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 18
0
        public static Guid?add(string name, string address, string phone1, string phone2, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "vendor_new",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_NAME, SqlDbType.VarChar, name),
                new SqlQueryParameter(COL_DB_ADDRESS, SqlDbType.VarChar, address),
                new SqlQueryParameter(COL_DB_PHONE1, SqlDbType.VarChar, phone1),
                new SqlQueryParameter(COL_DB_PHONE2, SqlDbType.VarChar, phone2),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
        public static void update(Guid id, Guid customerID, Guid gradeID, Guid productStoreNameID, Guid productWidthID, Guid lengthUnitID, Guid?colorID, decimal adjustmentPerUnit, string notes)
        {
            CustomerSaleAdjustment objOld = new CustomerSaleAdjustment(id);

            //generate log description
            string logDescription = "";

            if (objOld.CustomerID != customerID)
            {
                Customer customer = new Customer(customerID); logDescription = Tools.append(logDescription, String.Format("Customer Name: '{0}' to '{1}'", objOld.CustomerName, customer.Name), ",");
            }
            if (objOld.ProductStoreNameID != productStoreNameID)
            {
                logDescription = Tools.append(logDescription, String.Format("Product Store Name: '{0}' to '{1}'", objOld.ProductStoreName, new ProductStoreName(productStoreNameID).Name), ",");
            }
            if (objOld.GradeID != gradeID)
            {
                logDescription = Tools.append(logDescription, String.Format("Grade: '{0}' to '{1}'", objOld.GradeID, new Grade(gradeID).Name), ",");
            }
            if (objOld.ProductWidthID != productWidthID)
            {
                logDescription = Tools.append(logDescription, String.Format("Product Width: '{0}' to '{1}'", objOld.ProductWidthName, new ProductWidth(productWidthID).Name), ",");
            }
            if (objOld.LengthUnitID != lengthUnitID)
            {
                logDescription = Tools.append(logDescription, String.Format("Length Unit: '{0}' to '{1}'", objOld.LengthUnitID, new LengthUnit(lengthUnitID).Name), ",");
            }
            if (objOld.AdjustmentPerUnit != adjustmentPerUnit)
            {
                logDescription = Tools.append(logDescription, String.Format("Adjustment: '{0}' to '{1}'", objOld.AdjustmentPerUnit, adjustmentPerUnit), ",");
            }
            if (objOld.Notes != notes)
            {
                logDescription = Tools.append(logDescription, String.Format("Notes: '{0}' to '{1}'", objOld.Notes, notes), ",");
            }

            if (!string.IsNullOrEmpty(logDescription))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "customersaleadjustment_update",
                    new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_CUSTOMERID, SqlDbType.UniqueIdentifier, customerID),
                    new SqlQueryParameter(COL_DB_GRADEID, SqlDbType.UniqueIdentifier, gradeID),
                    new SqlQueryParameter(COL_DB_PRODUCSTORENAMEID, SqlDbType.UniqueIdentifier, productStoreNameID),
                    new SqlQueryParameter(COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier, productWidthID),
                    new SqlQueryParameter(COL_DB_LENGTHUNITID, SqlDbType.UniqueIdentifier, lengthUnitID),
                    new SqlQueryParameter(COL_DB_COLORID, SqlDbType.UniqueIdentifier, Util.wrapNullable(colorID)),
                    new SqlQueryParameter(COL_DB_ADJUSTMENTPERUNIT, SqlDbType.Decimal, adjustmentPerUnit),
                    new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.submitUpdate(id, logDescription);
                }
            }
        }
Ejemplo n.º 20
0
        public static Guid add(Guid userAccountID, string name, Guid Clients_Id, Guid WorkshiftCategories_Id, DayOfWeek dayOfWeek, string start, int durationMinutes, string notes)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "WorkshiftTemplates_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, name),
                    new SqlQueryParameter(COL_DB_Clients_Id, SqlDbType.UniqueIdentifier, Clients_Id),
                    new SqlQueryParameter(COL_DB_WorkshiftCategories_Id, SqlDbType.UniqueIdentifier, WorkshiftCategories_Id),
                    new SqlQueryParameter(COL_DB_DayOfWeek, SqlDbType.Int, (int)dayOfWeek),
                    new SqlQueryParameter(COL_DB_Start, SqlDbType.Time, Util.wrapNullable <TimeSpan?>(start)),
                    new SqlQueryParameter(COL_DB_DurationMinutes, SqlDbType.Int, Util.wrapNullable <int>(durationMinutes)),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.add(sqlConnection, userAccountID, id, "Added");
                }
            }

            return(id);
        }
        public static Guid?add(Guid customerID, Guid gradeID, Guid productStoreNameID, Guid productWidthID, Guid lengthUnitID, Guid?colorID, decimal adjustmentPerUnit, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "customersaleadjustment_add",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_CUSTOMERID, SqlDbType.UniqueIdentifier, customerID),
                new SqlQueryParameter(COL_DB_GRADEID, SqlDbType.UniqueIdentifier, gradeID),
                new SqlQueryParameter(COL_DB_PRODUCSTORENAMEID, SqlDbType.UniqueIdentifier, productStoreNameID),
                new SqlQueryParameter(COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier, productWidthID),
                new SqlQueryParameter(COL_DB_LENGTHUNITID, SqlDbType.UniqueIdentifier, lengthUnitID),
                new SqlQueryParameter(COL_DB_COLORID, SqlDbType.UniqueIdentifier, Util.wrapNullable(colorID)),
                new SqlQueryParameter(COL_DB_ADJUSTMENTPERUNIT, SqlDbType.Decimal, adjustmentPerUnit),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 22
0
        public static Guid?add(string name, string address, Guid cityID, Guid?defaultTransportID, string phone1, string phone2, string notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "customer_new",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_NAME, SqlDbType.VarChar, name),
                new SqlQueryParameter(COL_DB_ADDRESS, SqlDbType.VarChar, address),
                new SqlQueryParameter(COL_DB_CITYID, SqlDbType.UniqueIdentifier, cityID),
                new SqlQueryParameter(COL_DB_DEFAULTTRANSPORTID, SqlDbType.UniqueIdentifier, Util.wrapNullable(defaultTransportID)),
                new SqlQueryParameter(COL_DB_PHONE1, SqlDbType.VarChar, phone1),
                new SqlQueryParameter(COL_DB_PHONE2, SqlDbType.VarChar, phone2),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, notes),
                new SqlQueryParameter(COL_DB_SALESUSERID, SqlDbType.UniqueIdentifier, GlobalData.UserAccount.id)
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 23
0
        public static void update(Guid Id, string Code, string Description)
        {
            QueueCategory objOld = new QueueCategory(Id);
            string        log    = "";

            log = Util.appendChange(log, objOld.Code, Code, "Code: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Description, Description, "Description: '{0}' to '{1}'");

            if (string.IsNullOrEmpty(log))
            {
                Util.displayMessageBoxError("No changes to record");
            }
            else
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "QueueCategories_update",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id),
                    new SqlQueryParameter(COL_DB_Code, SqlDbType.NVarChar, Util.wrapNullable(Code)),
                    new SqlQueryParameter(COL_DB_Description, SqlDbType.NVarChar, Util.wrapNullable(Description))
                    );
            }
        }
Ejemplo n.º 24
0
        /*******************************************************************************************************/
        #region CONSTRUCTORS
        #endregion CONSTRUCTORS
        /*******************************************************************************************************/
        #region DATABASE STATIC METHODS

        public static Guid?submitNew(Guid customerID, decimal creditAmount, Guid?salePaymentID, string notes, PaymentMethod?paymentMethod)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "customercredit_new",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_CUSTOMERID, SqlDbType.UniqueIdentifier, customerID),
                new SqlQueryParameter(COL_DB_AMOUNT, SqlDbType.Decimal, creditAmount),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, notes),
                new SqlQueryParameter(COL_DB_SALEPAYMENTID, SqlDbType.UniqueIdentifier, Util.wrapNullable(salePaymentID)),
                new SqlQueryParameter(COL_DB_USERID, SqlDbType.UniqueIdentifier, GlobalData.UserAccount.id),
                new SqlQueryParameter(COL_DB_METHODENUMID, SqlDbType.TinyInt, Util.wrapNullable(paymentMethod))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 25
0
        public static Guid add(Guid userAccountID, string companyName, string address, string billingAddress,
                               string contactPersonName, string phone1, string phone2, string npwp, string npwpAddress, string notes)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(sqlConnection,
                                                           QueryTypes.ExecuteNonQuery,
                                                           "Clients_add",
                                                           new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                                                           new SqlQueryParameter(COL_DB_CompanyName, SqlDbType.NVarChar, companyName),
                                                           new SqlQueryParameter(COL_DB_Address, SqlDbType.NVarChar, Util.wrapNullable(address)),
                                                           new SqlQueryParameter(COL_DB_BillingAddress, SqlDbType.NVarChar, Util.wrapNullable(billingAddress)),
                                                           new SqlQueryParameter(COL_DB_ContactPersonName, SqlDbType.NVarChar, Util.wrapNullable(contactPersonName)),
                                                           new SqlQueryParameter(COL_DB_Phone1, SqlDbType.NVarChar, Util.wrapNullable(phone1)),
                                                           new SqlQueryParameter(COL_DB_Phone2, SqlDbType.NVarChar, Util.wrapNullable(phone2)),
                                                           new SqlQueryParameter(COL_DB_NPWP, SqlDbType.NVarChar, Util.wrapNullable(npwp)),
                                                           new SqlQueryParameter(COL_DB_NPWPAddress, SqlDbType.NVarChar, Util.wrapNullable(npwpAddress)),
                                                           new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                                                           );

                if (result.IsSuccessful)
                {
                    ActivityLog.add(sqlConnection, userAccountID, id, "Added");
                }
            }
            return(id);
        }
Ejemplo n.º 26
0
        public static Guid?add(string storageName, string vendorName, string vendorInfo, string description, DateTime?priceDate, decimal?pricePerUnit, DateTime?discontinueDate, string notes, Guid?lengthUnitID, decimal?sellPricePerUnit)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "sample_add",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_STORAGENAME, SqlDbType.VarChar, storageName),
                new SqlQueryParameter(COL_DB_VENDORNAME, SqlDbType.VarChar, vendorName),
                new SqlQueryParameter(COL_DB_VENDORINFO, SqlDbType.VarChar, vendorInfo),
                new SqlQueryParameter(COL_DB_DESCRIPTION, SqlDbType.VarChar, description),
                new SqlQueryParameter(COL_DB_PRICEDATE, SqlDbType.DateTime, Util.wrapNullable(priceDate)),
                new SqlQueryParameter(COL_DB_PRICEPERUNIT, SqlDbType.Decimal, Util.wrapNullable(pricePerUnit)),
                new SqlQueryParameter(COL_DB_DISCONTINUEDATE, SqlDbType.DateTime, Util.wrapNullable(discontinueDate)),
                new SqlQueryParameter(COL_DB_LENGTHUNITID, SqlDbType.UniqueIdentifier, Util.wrapNullable(lengthUnitID)),
                new SqlQueryParameter(COL_DB_SELLPRICEPERUNIT, SqlDbType.Decimal, Util.wrapNullable(sellPricePerUnit)),
                new SqlQueryParameter(COL_DB_NOTES, SqlDbType.VarChar, Util.wrapNullable(notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                ActivityLog.submitCreate(Id);
                return(Id);
            }
        }
Ejemplo n.º 27
0
        public static void update(Guid userAccountID, Guid id, int priorityNo, int priorityQty, DateTime?expectedDeliveryDate)
        {
            POItem objOld = new POItem(id);

            //generate log description
            string log = "";

            log = ActivityLog.appendChange(log, objOld.ExpectedDeliveryDate, expectedDeliveryDate, "Expected Delivery: '{0}' to '{1}'");
            log = ActivityLog.appendChange(log, objOld.PriorityNo, priorityNo, "Priority No: '{0}' to '{1}'");
            log = ActivityLog.appendChange(log, objOld.PriorityQty, priorityQty, "Priority Qty: '{0}' to '{1}'");

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "poitem_update",
                    new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_PriorityNo, SqlDbType.SmallInt, Util.wrapNullable(priorityNo)),
                    new SqlQueryParameter(COL_DB_PriorityQty, SqlDbType.Int, Util.wrapNullable(priorityQty)),
                    new SqlQueryParameter(COL_DB_ExpectedDeliveryDate, SqlDbType.Date, Util.wrapNullable(expectedDeliveryDate))
                    );

                if (result.IsSuccessful)
                {
                    ActivityLog.submit(id, log);
                }
            }
        }
Ejemplo n.º 28
0
        public static bool updateSaleOrderItem(Guid id, Guid?SaleOrderItems_Id, string description)
        {
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "poitem_update_SaleOrderItems_Id",
                new SqlQueryParameter(COL_DB_ID, SqlDbType.UniqueIdentifier, id),
                new SqlQueryParameter(COL_DB_SaleOrderItems_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(SaleOrderItems_Id))
                );

            if (!result.IsSuccessful)
            {
                return(false);
            }
            else if (SaleOrderItems_Id == null)
            {
                ActivityLog.submit(id, "Sale Order Item removed");
            }
            else
            {
                ActivityLog.submit(id, "Sale Order Item Updated to: " + description);
            }

            return(true);
        }
Ejemplo n.º 29
0
        public static DataTable get(Guid?Id, DateTime?dateStart, DateTime?dateEnd, Guid?inventoryID, Guid?customerID, Guid?saleReturnID,
                                    bool onlyWithCommission, Guid?FakturPajaks_Id, Guid?BrowsingForFakturPajak_Customers_Id, bool showOnlyReminder, Guid?Kontrabons_Id)
        {
            Guid?salesUserId = null;

            if (onlyWithCommission)
            {
                salesUserId = GlobalData.UserAccount.id;
            }

            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.FillByAdapter,
                "SaleReturns_get",
                new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter("date_start", SqlDbType.DateTime, Util.wrapNullable(dateStart)),
                new SqlQueryParameter("date_end", SqlDbType.DateTime, Util.wrapNullable(dateEnd)),
                new SqlQueryParameter("inventory_item_id", SqlDbType.UniqueIdentifier, Util.wrapNullable(inventoryID)),
                new SqlQueryParameter(COL_Customers_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(customerID)),
                new SqlQueryParameter("salereturn_id", SqlDbType.UniqueIdentifier, Util.wrapNullable(saleReturnID)),
                new SqlQueryParameter(COL_DB_FakturPajaks_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(FakturPajaks_Id)),
                new SqlQueryParameter(COL_DB_Kontrabons_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Kontrabons_Id)),
                new SqlQueryParameter(FILTER_BrowsingForFakturPajak_Customers_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(BrowsingForFakturPajak_Customers_Id)),
                new SqlQueryParameter(FILTER_ShowOnlyReminder, SqlDbType.Bit, showOnlyReminder),
                new SqlQueryParameter(COL_SALESMANID, SqlDbType.UniqueIdentifier, Util.wrapNullable(salesUserId))
                );

            return(result.Datatable);
        }
Ejemplo n.º 30
0
        /*******************************************************************************************************/
        #region DATABASE METHODS

        public static Guid?add(DateTime Timestamp, Guid?Customers_Id, Guid?Vendors_Id, string No, decimal DPP, decimal PPN, string Notes)
        {
            Guid           Id     = Guid.NewGuid();
            SqlQueryResult result = DBConnection.query(
                false,
                DBConnection.ActiveSqlConnection,
                QueryTypes.ExecuteNonQuery,
                "TableName_add",
                new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id),
                new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, Util.getAsStartDate(Timestamp)),
                new SqlQueryParameter(COL_DB_Customers_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Customers_Id)),
                new SqlQueryParameter(COL_DB_Vendors_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Vendors_Id)),
                new SqlQueryParameter(COL_DB_No, SqlDbType.VarChar, No),
                new SqlQueryParameter(COL_DB_DPP, SqlDbType.Decimal, DPP),
                new SqlQueryParameter(COL_DB_PPN, SqlDbType.Decimal, PPN),
                new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(Notes))
                );

            if (!result.IsSuccessful)
            {
                return(null);
            }
            else
            {
                //ActivityLog.submit(Id, "Added");
                return(Id);
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// A thread for executing query within each database
        /// </summary>
        private void DatabaseThread(object db)
        {
            var database = (WorkerDb)db;

            var queryResult = new SqlQueryResult();
            queryResult.QueryId = _query.Id;
            queryResult.DatabaseId = database.Id;

            try
            {
                var adapter = new SqlDataAdapter(_query.Sql, database.ConnectionString);
                adapter.SelectCommand.CommandTimeout = 0;
                var table = new DataTable();
                adapter.Fill(table);

                var result = new WorkerResult();
                result.DatabaseId = database.Id;

                foreach (DataColumn column in table.Columns)
                    result.AppendColumn(column.Caption);

                foreach (DataRow row in table.Rows)
                    result.AppendRow(row.ItemArray);

                _results.Add(result);
                queryResult.Result = JsonConvert.SerializeObject(result);
            }
            catch (Exception ex)
            {
                var result = new WorkerResult();
                result.DatabaseId = database.Id;
                result.AppendColumn("error");
                result.AppendRow(new object[] { ex.Message });

                queryResult.Result = JsonConvert.SerializeObject(result);
            }
            finally
            {
                using (var dbContext = new OctopusDbContext())
                {
                    dbContext.QueryResults.Add(queryResult);
                    dbContext.SaveChanges();
                }
                Interlocked.Decrement(ref _countdown);
            }
        }