Exemplo n.º 1
0
        public static bool update(Guid Id, DateTime Timestamp, Guid?Customers_Id, Guid?Vendors_Id, string No, decimal DPP, decimal PPN, string Notes)
        {
            FakturPajak objOld = new FakturPajak(Id);
            string      log    = "";

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

            string newCustomerName = new Customer(Customers_Id).Name;

            if (objOld.Customers_Name != newCustomerName)
            {
                log = Util.appendChange(log, objOld.Customers_Name, newCustomerName, "Customer: '{0}' to '{1}'");
                if (!Util.displayMessageBoxYesNo("Sale Invoices and Returns will be removed because customer is changed"))
                {
                    return(false);
                }
            }

            string newVendorName = new Vendor(Vendors_Id).Name;

            if (objOld.Vendors_Name != newVendorName)
            {
                log = Util.appendChange(log, objOld.Vendors_Name, newVendorName, "Vendor: '{0}' to '{1}'");
                if (!Util.displayMessageBoxYesNo("Vendor Invoices and Returns will be removed because vendor is changed"))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "FakturPajaks_update",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id),
                    new SqlQueryParameter(COL_DB_Timestamp, SqlDbType.DateTime, 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)
                {
                    ActivityLog.submit(Id, String.Format("Updated: {0}", log));
                }

                return(result.IsSuccessful);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static void update_Kontrabons_Id(Guid Id, Guid?Kontrabons_Id)
        {
            FakturPajak objOld = new FakturPajak(Id);
            string      log    = "";

            log = ActivityLog.appendChange(log, objOld.Kontrabons_No, new Kontrabon(Kontrabons_Id).No, "Kontrabon: '{0}' to '{1}'");

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "FakturPajaks_update_Kontrabons_Id",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, Id),
                    new SqlQueryParameter(COL_DB_Kontrabons_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Kontrabons_Id))
                    );

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

                    //update faktur pajak log
                    if (Kontrabons_Id == null)
                    {
                        ActivityLog.submit((Guid)objOld.Kontrabons_Id, String.Format("Removed FP: {0}", objOld.No));
                    }
                    else
                    {
                        ActivityLog.submit((Guid)Kontrabons_Id, String.Format("Added FP: {0}", objOld.No));
                    }

                    //remove sale invoices
                    DataTable saleInvoices = Sale.get_by_FakturPajaks_Id(Id);
                    foreach (DataRow row in saleInvoices.Rows)
                    {
                        Sale.update_Kontrabons_Id(Util.wrapNullable <Guid>(row, Sale.COL_ID), Kontrabons_Id);
                    }

                    //remove sale returns
                    DataTable saleReturns = SaleReturn.get_by_FakturPajaks_Id(Id);
                    foreach (DataRow row in saleReturns.Rows)
                    {
                        SaleReturn.update_Kontrabons_Id(Util.wrapNullable <Guid>(row, SaleReturn.COL_ID), Kontrabons_Id);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void update_Kontrabons_Id(Guid Id, Guid?Kontrabons_Id)
        {
            SaleReturn objOld = new SaleReturn(Id);
            string     log    = "";

            log = ActivityLog.appendChange(log, objOld.Kontrabons_No, new Kontrabon(Kontrabons_Id).No, "Kontrabon: '{0}' to '{1}'");

            if (!string.IsNullOrEmpty(log))
            {
                SqlQueryResult result = DBConnection.query(
                    false,
                    DBConnection.ActiveSqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "salereturn_update_Kontrabons_Id",
                    new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Id),
                    new SqlQueryParameter(COL_DB_Kontrabons_Id, SqlDbType.UniqueIdentifier, Util.wrapNullable(Kontrabons_Id))
                    );

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

                    //update faktur pajak log
                    if (Kontrabons_Id == null)
                    {
                        ActivityLog.submit((Guid)objOld.Kontrabons_Id, String.Format("Removed: {0}", objOld.barcode));
                    }
                    else
                    {
                        ActivityLog.submit((Guid)Kontrabons_Id, String.Format("Added: {0}", objOld.barcode));
                    }

                    //remove faktur pajak and all items related to it
                    Guid?FakturPajaks_Id = new SaleReturn(Id).FakturPajaks_Id;
                    if (FakturPajaks_Id != null)
                    {
                        FakturPajak.update_Kontrabons_Id((Guid)FakturPajaks_Id, Kontrabons_Id);
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void populateGridFakturPajak()
 {
     Util.setGridviewDataSource(gridFakturPajak, FakturPajak.get_Reminder());
     tpFP.Text = string.Format("Faktur Pajak: {0}", gridFakturPajak.Rows.Count);
 }